/* ===== پایه ===== */
:root {
  --sky: #8fc4e8;
  --grass: #6f9a4e;
  --ink: #12180f;
  --paper: rgba(16, 22, 14, 0.72);
  --line: rgba(255, 255, 255, 0.16);
  --good: #7ed957;
  --warn: #f0b429;
  --bad: #e5484d;
  --woman: #ff9ecf;
  --man: #7ec8ff;
  --font: "Vazirmatn", "IRANSans", "Segoe UI", "Tahoma", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0b0f0a;
  color: #fff;
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; }

#scene { display: block; width: 100%; height: 100%; touch-action: none; }

/* وینیت سینمایی ملایم روی لبه‌های قاب — بدون هزینه GPU، بالای صحنه و زیر HUD */
#game::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(
    ellipse at center,
    transparent 58%,
    rgba(8, 12, 6, 0.22) 82%,
    rgba(8, 12, 6, 0.45) 100%
  );
}

/* پالس قرمز لبه‌ها وقتی سلامتی زیر ۳۰٪ است */
#low-hp {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.5s;
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgba(150, 10, 10, 0.3) 100%
  );
}
#game.low-hp #low-hp {
  opacity: 1;
  animation: low-hp-pulse 1.6s ease-in-out infinite;
}
@keyframes low-hp-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.hidden { display: none !important; }

/* ===== برچسب نام کاراکترها (بالای وینیت) ===== */
#labels {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}

.nameplate {
  position: absolute;
  top: 0;
  right: 0;
  transform-origin: center bottom;
  will-change: transform, opacity;
  text-align: center;
  white-space: nowrap;
  line-height: 1.1;
}

.nameplate .np-name {
  display: inline-block;
  padding: 2px 9px 3px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  background: rgba(10, 14, 9, 0.66);
  border: 1px solid var(--line);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(2px);
}

.nameplate.woman .np-name { border-color: var(--woman); color: #ffe6f4; }
.nameplate.man   .np-name { border-color: var(--man);   color: #e2f3ff; }

.nameplate .np-tag {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.95;
  margin-inline-start: 4px;
}
.nameplate.woman .np-tag { color: var(--woman); }
.nameplate.man   .np-tag { color: var(--man); }

.nameplate .np-hp {
  width: 62px;
  height: 5px;
  margin: 3px auto 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.nameplate .np-hp > i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--good), #b6f07a);
  transition: width 0.12s linear;
}

.nameplate.hurt .np-hp > i { background: linear-gradient(90deg, var(--warn), #ffd97a); }
.nameplate.critical .np-hp > i { background: linear-gradient(90deg, var(--bad), #ff8a8a); }

.nameplate.down { opacity: 0.45; }
.nameplate.down .np-name { text-decoration: line-through; }

/* اعداد شناور آسیب/امتیاز */
.float-num {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 20px;
  font-weight: 800;
  pointer-events: none;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  animation: floatUp 1s ease-out forwards;
  will-change: transform, opacity;
}
.float-num.plus { color: var(--good); }
.float-num.minus { color: var(--bad); }

@keyframes floatUp {
  0%   { opacity: 0; transform: translate(50%, 0) scale(0.7); }
  18%  { opacity: 1; transform: translate(50%, -14px) scale(1.12); }
  100% { opacity: 0; transform: translate(50%, -70px) scale(0.95); }
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
}

.hud-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
}

.panel {
  min-width: 92px;
  padding: 6px 12px 7px;
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  text-align: center;
  backdrop-filter: blur(4px);
}

.panel-title {
  display: block;
  font-size: 11px;
  opacity: 0.72;
  margin-bottom: 1px;
}

.panel-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-value b { font-size: 21px; }

#land-panel .panel-value b { color: var(--good); }

#timer-panel .panel-value { font-size: 22px; letter-spacing: 1px; }

#timer-panel.warn {
  border-color: var(--bad);
  animation: pulse 1s steps(2, end) infinite;
}
#timer-panel.warn .panel-value { color: var(--bad); }

@keyframes pulse { 50% { opacity: 0.45; } }

#land-panel.bump .panel-value b { animation: bump 0.32s ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); color: #fff; }
  100% { transform: scale(1); }
}

#health-wrap {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom));
  right: 50%;
  transform: translateX(50%);
  width: min(260px, 54vw);
  text-align: center;
}

.health-label { font-size: 11px; opacity: 0.75; }

#health-bar {
  height: 9px;
  margin-top: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--line);
  overflow: hidden;
}

#health-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good), #cdf58e);
  transition: width 0.18s ease-out, background 0.2s linear;
}

#health-fill.mid { background: linear-gradient(90deg, var(--warn), #ffdf94); }
#health-fill.low { background: linear-gradient(90deg, var(--bad), #ff9c9c); }

/* جان‌های باقی‌مانده کریم */
#lives {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1;
}
#lives .life {
  color: #ff6b81;
  opacity: 0.18;
  filter: grayscale(1);
  transition: opacity 0.25s, filter 0.25s, transform 0.25s;
  transform: scale(0.85);
}
#lives .life.on {
  opacity: 1;
  filter: none;
  transform: scale(1);
  text-shadow: 0 0 6px rgba(255, 107, 129, 0.6);
}

#msg {
  position: absolute;
  top: 42%;
  right: 0;
  left: 0;
  text-align: center;
  font-size: clamp(18px, 4.4vw, 30px);
  font-weight: 800;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.25s;
}
#msg.show { opacity: 1; }

#kill-feed {
  position: absolute;
  top: calc(74px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 46vw;
}

.feed-item {
  padding: 4px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(10, 14, 9, 0.7);
  border: 1px solid var(--line);
  animation: feedIn 0.25s ease-out;
}
.feed-item.plus { border-color: var(--good); color: #d6ffb8; }
.feed-item.minus { border-color: var(--bad); color: #ffd0d1; }
.feed-item.fade { opacity: 0; transition: opacity 0.4s; }

@keyframes feedIn {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: none; }
}

/* ===== نشانه‌گیر ===== */
#crosshair {
  position: absolute;
  top: 50%;
  right: 50%;
  width: 30px;
  height: 30px;
  transform: translate(50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#crosshair.on { opacity: 0.92; }
#crosshair.hot .ch { background: var(--bad); }

.ch {
  position: absolute;
  background: #fff;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  transition: background 0.1s;
}
.ch-t, .ch-b { right: 50%; width: 2px; height: 9px; transform: translateX(50%); }
.ch-t { top: 0; }
.ch-b { bottom: 0; }
.ch-l, .ch-r { top: 50%; width: 9px; height: 2px; transform: translateY(-50%); }
.ch-l { right: 0; }
.ch-r { left: 0; }
.ch-dot {
  position: absolute;
  top: 50%;
  right: 50%;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  transform: translate(50%, -50%);
}

#hitmarker {
  position: absolute;
  top: 50%;
  right: 50%;
  width: 26px;
  height: 26px;
  transform: translate(50%, -50%) rotate(45deg);
  pointer-events: none;
  opacity: 0;
}
#hitmarker::before, #hitmarker::after {
  content: "";
  position: absolute;
  background: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
}
#hitmarker::before { top: 0; right: 50%; width: 3px; height: 100%; transform: translateX(50%); }
#hitmarker::after { top: 50%; right: 0; width: 100%; height: 3px; transform: translateY(-50%); }
#hitmarker.on { animation: hitPop 0.2s ease-out; }
@keyframes hitPop {
  0% { opacity: 1; transform: translate(50%, -50%) rotate(45deg) scale(0.5); }
  100% { opacity: 0; transform: translate(50%, -50%) rotate(45deg) scale(1.5); }
}

#hurt-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(190, 20, 24, 0.82) 100%);
}
#hurt-flash.on { animation: hurt 0.5s ease-out; }
@keyframes hurt { 0% { opacity: 1; } 100% { opacity: 0; } }

#muzzle-flash {
  position: absolute;
  bottom: 14%;
  left: 22%;
  width: 15vmin;
  height: 15vmin;
  pointer-events: none;
  opacity: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 246, 190, 0.95) 0%, rgba(255, 176, 46, 0.55) 40%, transparent 72%);
}
#muzzle-flash.on { animation: muzzle 0.09s ease-out; }
@keyframes muzzle { 0% { opacity: 1; } 100% { opacity: 0; } }


/* ===== کنترل‌های لمسی ===== */
#touch { position: absolute; inset: 0; pointer-events: none; display: none; }
#touch.on { display: block; }

#stick-left {
  position: absolute;
  bottom: calc(22px + env(safe-area-inset-bottom));
  right: calc(20px + env(safe-area-inset-right));
  width: 34vmin;
  max-width: 158px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(10, 14, 9, 0.34);
  border: 2px solid rgba(255, 255, 255, 0.24);
  pointer-events: auto;
  touch-action: none;
}

#stick-knob {
  position: absolute;
  top: 50%;
  right: 50%;
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  border: 2px solid rgba(255, 255, 255, 0.62);
  transform: translate(50%, -50%);
  will-change: transform;
}

#btn-fire, #btn-crouch {
  position: absolute;
  border-radius: 50%;
  font-family: var(--font);
  font-weight: 800;
  color: #fff;
  pointer-events: auto;
  touch-action: none;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(200, 40, 40, 0.44);
  backdrop-filter: blur(2px);
}

#btn-fire {
  bottom: calc(30px + env(safe-area-inset-bottom));
  left: calc(22px + env(safe-area-inset-left));
  width: 24vmin;
  max-width: 116px;
  aspect-ratio: 1;
  font-size: clamp(15px, 3.6vmin, 22px);
}

#btn-crouch {
  bottom: calc(30vmin + 34px + env(safe-area-inset-bottom));
  left: calc(26px + env(safe-area-inset-left));
  width: 16vmin;
  max-width: 78px;
  aspect-ratio: 1;
  font-size: clamp(11px, 2.6vmin, 15px);
  background: rgba(30, 60, 110, 0.46);
}


/* ===== صفحه‌های شروع و پایان ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow-y: auto;
  background: linear-gradient(160deg, rgba(9, 14, 8, 0.93), rgba(20, 33, 16, 0.97));
  backdrop-filter: blur(3px);
  z-index: 10;
}

/* ===== پوستر اصلی صفحه شروع (پشت متن‌ها) ===== */
#start-screen {
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* لایه پوستر: تمام‌صفحه با زوم بسیار آهسته (کن‌برنز سینمایی) */
#start-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #0d130a url('./poster.jpg') center 25% / cover no-repeat;
  pointer-events: none;
  animation: poster-drift 32s ease-in-out infinite alternate;
  will-change: transform;
}

/* پرده خوانایی: تیره در بالا و پایین + وینیت ملایم؛ پوستر در میان‌قاب واضح می‌ماند */
#start-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg,
      rgba(7, 11, 6, 0.60) 0%,
      rgba(7, 11, 6, 0.16) 30%,
      rgba(7, 11, 6, 0.20) 56%,
      rgba(7, 11, 6, 0.80) 100%),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(6, 10, 5, 0.42) 100%);
}

@keyframes poster-drift {
  from { transform: scale(1) translateY(0); }
  to   { transform: scale(1.08) translateY(-1.2%); }
}

@media (prefers-reduced-motion: reduce) {
  #start-screen::before { animation: none; }
}

/* کارت شیشه‌ای روی پوستر */
#start-screen .card {
  position: relative;
  background: rgba(10, 16, 9, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
}

#start-screen .card h1 {
  font-size: clamp(26px, 7vw, 44px);
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.85));
}

.card {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(16px, 3.4vw, 26px);
  border-radius: 18px;
  background: rgba(12, 18, 10, 0.88);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
  -webkit-overflow-scrolling: touch;
}

.card h1 {
  font-size: clamp(24px, 6.6vw, 38px);
  letter-spacing: -0.4px;
  background: linear-gradient(90deg, #dff5b8, #8fd14f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card .sub { margin: 14px; font-size: 13px; opacity: 0.78; }

.rules { display: grid; gap: 6px; margin: 16px 0; }

.rule {
  padding: 8px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  text-align: right;
  background: rgba(255, 255, 255, 0.05);
  border-right: 3px solid var(--good);
}
.rule b { color: var(--good); }
.rule.bad { border-right-color: var(--bad); }
.rule.bad b { color: var(--bad); }
.rule.warn { border-right-color: var(--warn); }
.rule.warn b { color: var(--warn); }

.enemy-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 7px;
  margin-bottom: 16px;
}

.ecard {
  padding: 9px 6px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.ecard .en { display: block; font-weight: 800; font-size: 15px; }
.ecard .ed { display: block; font-size: 10.5px; opacity: 0.72; margin-top: 2px; }
.ecard .ep { display: block; font-size: 12px; font-weight: 800; margin-top: 4px; }
.ecard.woman { border-color: rgba(255, 158, 207, 0.5); }

.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: right; }
@media (max-width: 430px) { .keys { grid-template-columns: 1fr; } }

.keys-col {
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
.keys-col h3 { font-size: 13px; margin-bottom: 5px; color: #cfe9a8; }
.keys-col ul { list-style: none; display: grid; gap: 3px; }
.keys-col li { font-size: 11.5px; opacity: 0.82; padding-right: 11px; position: relative; }
.keys-col li::before { content: "•"; position: absolute; right: 0; color: var(--good); }

.tip {
  margin: 14px 0 16px;
  font-size: 12px;
  line-height: 1.65;
  opacity: 0.75;
  text-align: right;
}

button.primary {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 13px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  color: #10200a;
  background: linear-gradient(180deg, #a9e26b, #74b83e);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(116, 184, 62, 0.35);
  touch-action: manipulation;
}
button.primary:active { transform: translateY(2px); box-shadow: 0 2px 8px rgba(116, 184, 62, 0.3); }
button.primary:disabled { opacity: 0.55; cursor: default; }

.loading { margin-top: 10px; font-size: 11.5px; opacity: 0.6; }

.result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  margin-bottom: 7px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.result span { font-size: 13px; opacity: 0.8; }
.result b { font-size: 24px; color: var(--good); font-variant-numeric: tabular-nums; }
.result.small { padding: 8px 14px; }
.result.small b { font-size: 16px; color: #fff; }

#end-breakdown { display: grid; gap: 5px; margin: 12px 0 16px; }

.bd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  text-align: right;
}
.bd-name { font-weight: 800; font-size: 12.5px; }
.bd-chip {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.bd-chip.bad { border-color: rgba(229, 72, 77, 0.5); color: #ffd0d1; }
.bd-chip.good { border-color: rgba(126, 217, 87, 0.5); color: #d6ffb8; }
.bd-chip.zero { opacity: 0.55; }
.bd bdi { font-variant-numeric: tabular-nums; }

/* ===== صفحه مرگ کریم ===== */
#death-screen .card.death {
  border-color: #7a2b2b;
  background: linear-gradient(170deg, rgba(52, 10, 10, 0.96), rgba(24, 8, 8, 0.96));
  box-shadow: 0 0 70px rgba(150, 20, 20, 0.35);
}
#death-screen .death-title {
  color: #ff8484;
  text-shadow: 0 0 22px rgba(255, 60, 60, 0.5);
}
#death-screen .death-sub {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.8;
}
#death-breakdown { display: grid; gap: 5px; margin: 12px 0 16px; }

#rotate-hint {
  position: absolute;
  bottom: calc(6px + env(safe-area-inset-bottom));
  right: 50%;
  transform: translateX(50%);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--line);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#rotate-hint.on { opacity: 0.9; }

/* ===== ریسپانسیو ===== */
@media (max-height: 460px) {
  .panel { min-width: 78px; padding: 4px 9px 5px; }
  .panel-value b { font-size: 18px; }
  #timer-panel .panel-value { font-size: 18px; }
  #health-wrap { width: min(200px, 40vw); bottom: calc(8px + env(safe-area-inset-bottom)); }
}

@media (hover: hover) and (pointer: fine) {
  #rotate-hint { display: none; }
  /* دسکتاپ: راهنمای لمسی بی‌معنی است — فقط راهنمای کیبورد */
  #start-screen .keys { grid-template-columns: 1fr; }
  .keys-col.touch { display: none; }
}

.ecard.woman .en, .ecard.woman .ep { color: var(--woman); }
.ecard.man { border-color: rgba(126, 200, 255, 0.5); }
.ecard.man .en, .ecard.man .ep { color: var(--man); }

#btn-fire:active { background: rgba(230, 60, 60, 0.75); transform: scale(0.94); }
#btn-crouch:active, #btn-crouch.active { background: rgba(60, 120, 200, 0.8); }


/* ---------- نشانگرهای وضعیت: دیده شدن و نشستن ---------- */
#status-tags {
  position: absolute;
  top: calc(50% + 44px);
  right: 50%;
  transform: translate(50%, 0);
  display: flex;
  gap: 8px;
  pointer-events: none;
  z-index: 30;
}

#status-tags span {
  display: none;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

#crouch-tag {
  background: rgba(40, 60, 90, 0.8);
  color: #cfe3ff;
}

#status-tags span.on {
  display: inline-block;
}

/* ===== اورلی‌ها روی موبایل: همه‌چیز بدون اسکرول جا شود ===== */
@media (max-width: 640px) {
  .overlay {
    padding:
      calc(10px + env(safe-area-inset-top, 0px))
      calc(10px + env(safe-area-inset-right, 0px))
      calc(10px + env(safe-area-inset-bottom, 0px))
      calc(10px + env(safe-area-inset-left, 0px));
  }

  .card {
    padding: 13px 14px;
    border-radius: 14px;
  }

  .card h1 { font-size: clamp(21px, 6vw, 27px); }
  #start-screen .card h1 { font-size: clamp(22px, 6.4vw, 30px); }

  .card .sub { margin: 8px 4px; font-size: 12px; }

  .keys { gap: 8px; }
  .keys-col { padding: 8px 10px; }
  .keys-col h3 { font-size: 12px; margin-bottom: 3px; }
  .keys-col li { font-size: 11px; }

  .tip { margin: 10px 2px 12px; font-size: 11px; }

  button.primary { padding: 12px; font-size: 16px; }

  /* این خط ثابت است و در JS به‌روز نمی‌شود — روی موبایل فقط جا می‌گیرد */
  .loading { display: none; }

  /* صفحه پایان: سه آمار کوچک به‌شکل چیپ‌های کنار هم */
  .result { padding: 9px 12px; margin-bottom: 6px; }
  .result b { font-size: 20px; }
  .result.small {
    display: inline-flex;
    width: auto;
    gap: 8px;
    padding: 6px 11px;
    margin: 0 2px 6px;
    white-space: nowrap;
  }

  #end-breakdown,
  #death-breakdown { gap: 4px; margin: 9px 0 12px; }
  .bd { padding: 6px 9px; gap: 4px 7px; }
  .bd-chip { font-size: 10.5px; padding: 3px 8px; }

  #death-screen .death-sub { font-size: 12px; }
}

/* گوشی افقی و صفحه‌های خیلی کوتاه: فقط ضروری‌ها */
@media (max-height: 520px) {
  #start-screen .sub,
  #start-screen .tip,
  .loading { display: none; }

  #start-screen .card { width: min(620px, 100%); }
  #start-screen .card h1 { font-size: clamp(20px, 4.4vw, 26px); }

  .card h1 { font-size: 21px; }

  .result { padding: 7px 12px; margin-bottom: 5px; }
  #end-breakdown,
  #death-breakdown { margin: 7px 0 10px; }
  .bd { padding: 5px 9px; }
  .bd-chip { font-size: 10px; padding: 2px 7px; }

  button.primary { padding: 10px; font-size: 15px; }
}

/* موبایل/تبلت لمسی: راهنمای کیبورد بی‌معنی است */
@media (hover: none) and (pointer: coarse) {
  #start-screen .keys { grid-template-columns: 1fr; }
  .keys-col.pc { display: none; }
}
