/* ══════════════════════════════════════════════════════════════════════════════
   Ghost Run — styles
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #07071a;
  color: #e0e0ff;
  font-family: 'Segoe UI', system-ui, sans-serif;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ── Screens ────────────────────────────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100vh; align-items: center; justify-content: center; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes spin        { to { transform: rotate(360deg); } }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulseTurn   { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

@keyframes shotFlash {
  0%   { background: rgba(255,60,60,0.85); border-color: #ff3c3c; box-shadow: 0 0 12px #ff3c3c; }
  60%  { background: rgba(255,60,60,0.35); border-color: #ff3c3c80; box-shadow: none; }
  100% { background: #1e0a0a; border-color: #3a1010; }
}
@keyframes moveFlash {
  0%   { background: rgba(0,255,163,0.65); border-color: #00ffa3; box-shadow: 0 0 10px #00ffa3; }
  100% { background: rgba(0,255,163,0.18); border-color: #00ffa3; box-shadow: none; }
}
@keyframes goalGlow {
  0%,100% { box-shadow: 0 0 6px #007bff55; }
  50%      { box-shadow: 0 0 14px #007bff; }
}
@keyframes urgentPulse {
  0%,100% { box-shadow: none; }
  50%      { box-shadow: 0 0 0 3px rgba(255,80,80,0.4); }
}

/* ── Center layout (lobby / waiting / result) ───────────────────────────────── */
.center-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fadeSlideIn 0.3s ease;
}

/* ── Logo ───────────────────────────────────────────────────────────────────── */
.logo {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 900;
  letter-spacing: 10px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #00ffa3, #007bff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline {
  color: #333355;
  letter-spacing: 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: #10102a;
  border: 1px solid #1e1e44;
  border-radius: 16px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

/* ── Inputs ─────────────────────────────────────────────────────────────────── */
input[type="text"] {
  width: 100%;
  background: #07071a;
  border: 1px solid #1e1e44;
  border-radius: 8px;
  padding: 11px 14px;
  color: #e0e0ff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus { border-color: #00ffa3; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
button {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
#btn-find, #btn-again {
  background: linear-gradient(135deg, #00ffa3, #007bff);
  color: #07071a;
}
#btn-find:hover, #btn-again:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 255, 163, 0.3);
}
.btn-secondary {
  background: transparent;
  border: 1px solid #1e1e44;
  color: #555577;
}
.btn-secondary:hover { border-color: #444466; color: #9999bb; }

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  width: 44px; height: 44px;
  border: 3px solid #1e1e44;
  border-top-color: #00ffa3;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.waiting-text { color: #555577; font-size: 0.9rem; }

/* ══════════════════════════════════════════════════════════════════════════════
   GAME SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */

.game-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 100vh;
  padding: 10px 16px 10px;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.game-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 700px;
  background: #10102a;
  border: 1px solid #1e1e44;
  border-radius: 12px;
  padding: 10px 16px;
  flex-shrink: 0;
}

.hdr-player {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 110px;
}
.hdr-right { align-items: flex-end; }
.hdr-name { font-size: 0.9rem; font-weight: 600; }

.role-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  width: fit-content;
}
.badge-runner  { background: rgba(0,255,163,0.12); color: #00ffa3; border: 1px solid rgba(0,255,163,0.3); }
.badge-shooter { background: rgba(255,80,80,0.12);  color: #ff5050; border: 1px solid rgba(255,80,80,0.3); }

.hdr-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

/* Timer ring */
.timer-ring {
  position: relative;
  width: 48px; height: 48px;
}
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: #1e1e44; stroke-width: 3.2; }
.ring-fill {
  fill: none; stroke: #00ffa3; stroke-width: 3.2; stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.4s;
}
.ring-fill.urgent {
  stroke: #ff5050;
  animation: urgentPulse 0.5s ease-in-out infinite;
}
#timer-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.turn-label {
  font-size: 0.7rem; color: #444466;
  letter-spacing: 1px; text-transform: uppercase;
}
.turn-num {
  font-size: 0.65rem; color: #333355;
  letter-spacing: 0.5px;
}
.turn-label.my-turn-runner { color: #00ffa3; animation: pulseTurn 1.4s ease-in-out infinite; }
.turn-label.my-turn-shooter { color: #ff5050; animation: pulseTurn 1.4s ease-in-out infinite; }

/* Help button */
.btn-help {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid #1e1e44;
  color: #444466;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.btn-help:hover { border-color: #555577; color: #9999bb; }

/* ── Game main (grid + log side by side) ────────────────────────────────────── */
.game-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

/* ── Grid section ───────────────────────────────────────────────────────────── */
.grid-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Grid with embedded number labels */
.grid {
  display: grid;
  /* first col = row labels (16px), then 15 game cols */
  grid-template-columns: 16px repeat(15, 1fr);
  /* first row = col labels (16px), then 15 game rows */
  grid-template-rows: 16px repeat(15, 1fr);
  gap: 2px;
  width: min(72vh, 510px);
  height: min(72vh, 510px);
  background: #0d0d24;
  border: 1px solid #1e1e44;
  border-radius: 10px;
  padding: 6px;
}

/* Number label cells */
.num-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.52rem;
  color: #2a2a4a;
  font-variant-numeric: tabular-nums;
  border-radius: 2px;
}
.num-cell.goal-col { color: #007bff44; }
.num-cell.corner   { /* empty */ }

/* Game cells */
.game-cell {
  border-radius: 3px;
  background: #12122e;
  border: 1px solid #181834;
  transition: background 0.1s, border-color 0.1s;
  position: relative;
  cursor: default;
  min-width: 0; min-height: 0;
}

/* Goal row (row 1) */
.game-cell.goal-row {
  background: #0e0e22;
  border-top: 1px solid #007bff40;
  animation: goalGlow 2.5s ease-in-out infinite;
}

/* Start position */
.game-cell.start-pos {
  border-color: #2a2a4a;
}

/* Blocked / shot */
.game-cell.blocked {
  background: #1a0808;
  border-color: #2e1010;
}
.game-cell.blocked::after {
  content: '×';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #ff505050;
  font-size: clamp(0.5rem, 1.5vw, 0.8rem);
  font-weight: 700;
}

/* Shot flash animation */
.game-cell.shot-anim {
  animation: shotFlash 0.7s ease-out forwards;
}

/* Runner position (shown to runner only) */
.game-cell.runner-here {
  background: rgba(0,255,163,0.18);
  border-color: #00ffa3;
}
.game-cell.runner-here::after {
  content: '●';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #00ffa3;
  font-size: clamp(0.55rem, 1.8vw, 0.9rem);
}
.game-cell.runner-here.move-anim {
  animation: moveFlash 0.6s ease-out forwards;
}

/* Valid moves (runner sees these) */
.game-cell.can-move {
  background: rgba(0,255,163,0.06);
  border-color: #00ffa325;
  cursor: pointer;
}
.game-cell.can-move:hover {
  background: rgba(0,255,163,0.18);
  border-color: #00ffa3;
}

/* Shooter aim cursor */
.game-cell.can-fire { cursor: crosshair; }
.game-cell.can-fire:hover:not(.blocked) {
  background: rgba(255,80,80,0.18);
  border-color: rgba(255,80,80,0.5);
}

/* Final reveal */
.game-cell.runner-reveal {
  background: rgba(255,200,0,0.18);
  border-color: #ffc800;
}
.game-cell.runner-reveal::after {
  content: '◉';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #ffc800;
  font-size: clamp(0.55rem, 1.8vw, 0.9rem);
}

/* ── Log panel ──────────────────────────────────────────────────────────────── */
.log-panel {
  width: 172px;
  flex-shrink: 0;
  background: #0d0d24;
  border: 1px solid #1e1e44;
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: min(72vh, 462px);
  overflow: hidden;
}
.log-title {
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: #333355;
  text-transform: uppercase;
  text-align: center;
  padding-bottom: 6px;
  border-bottom: 1px solid #1a1a38;
  flex-shrink: 0;
}
.log-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-list::-webkit-scrollbar { width: 3px; }
.log-list::-webkit-scrollbar-track { background: transparent; }
.log-list::-webkit-scrollbar-thumb { background: #1e1e44; border-radius: 2px; }

.log-entry {
  font-size: 0.68rem;
  line-height: 1.4;
  padding: 5px 7px;
  border-radius: 5px;
  background: #10102a;
  border-left: 2px solid transparent;
  animation: fadeSlideIn 0.25s ease;
  word-break: break-word;
}
.log-entry .log-turn { color: #2a2a4a; font-size: 0.58rem; }
.log-entry.log-system { border-left-color: #333366; color: #444466; }
.log-entry.log-runner { border-left-color: #00ffa350; color: #00ffa3cc; }
.log-entry.log-shot   { border-left-color: #ff505050; color: #ff5050cc; }
.log-entry.log-event  { border-left-color: #ffc80050; color: #ffc800cc; }

/* ── Trap cells ─────────────────────────────────────────────────────────────── */
@keyframes trapTrigger {
  0%   { background: rgba(255,200,0,0.9); border-color: #ffc800; box-shadow: 0 0 18px #ffc800; }
  50%  { background: rgba(255,200,0,0.5); box-shadow: 0 0 8px #ffc80060; }
  100% { background: rgba(255,200,0,0.18); border-color: #ffc80070; box-shadow: none; }
}
/* Placed trap — subtle dot, only shooter sees */
.game-cell.trap-placed {
  border-color: #ffc80045;
  box-shadow: inset 0 0 0 1px #ffc80030;
}
.game-cell.trap-placed::before {
  content: '◆';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #ffc80055;
  font-size: 0.55rem;
  pointer-events: none;
}
/* Triggered trap — bright yellow, runner was here */
.game-cell.trap-triggered {
  background: rgba(255,200,0,0.18);
  border-color: #ffc80070;
}
.game-cell.trap-triggered::before {
  content: '◈';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #ffc800bb;
  font-size: clamp(0.5rem, 1.5vw, 0.82rem);
  pointer-events: none;
}
/* Trigger animation */
.game-cell.trap-trigger-anim {
  animation: trapTrigger 0.9s ease-out forwards;
}
/* Bounce animation — trap relocated here */
@keyframes trapBounce {
  0%   { background: rgba(255,200,0,0.0); transform: scale(0.4); }
  40%  { background: rgba(255,200,0,0.9); border-color: #ffc800; box-shadow: 0 0 20px #ffc800; transform: scale(1.15); }
  100% { background: rgba(255,200,0,0.12); border-color: #ffc80045; transform: scale(1); box-shadow: none; }
}
.game-cell.trap-bounce-anim {
  animation: trapBounce 0.85s ease-out forwards;
}

/* ── Shooter mode controls ───────────────────────────────────────────────────── */
.shooter-mode-wrap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mode-btn {
  background: #10102a;
  border: 1px solid #1e1e44;
  color: #555577;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.8rem;
  width: auto;
  letter-spacing: 0.3px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.mode-btn:hover:not(:disabled) { border-color: #333355; color: #9999bb; }
.mode-btn.mode-active {
  border-color: #ff505088;
  color: #ff5050;
  background: rgba(255,80,80,0.08);
}
.mode-btn.mode-active.mode-trap {
  border-color: #ffc80088;
  color: #ffc800;
  background: rgba(255,200,0,0.08);
}
.mode-btn.mode-active.mode-bazooka {
  border-color: #ff880088;
  color: #ff8800;
  background: rgba(255,136,0,0.08);
}
.mode-btn.mode-active.mode-wall {
  border-color: #a050ff88;
  color: #c080ff;
  background: rgba(160,80,255,0.08);
}
.mode-btn.mode-active.mode-stun {
  border-color: #ffee0088;
  color: #ffee00;
  background: rgba(255,238,0,0.08);
}
.mode-btn.mode-active.mode-sonar {
  border-color: #00dcff88;
  color: #00dcff;
  background: rgba(0,220,255,0.08);
}
.mode-btn:disabled { opacity: 0.25; cursor: not-allowed; }

/* ── Runner progress bar ────────────────────────────────────────────────────── */
.runner-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(72vh, 462px);
  flex-shrink: 0;
}
.prog-goal, .prog-start {
  font-size: 0.6rem;
  color: #333355;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.prog-goal { color: #007bff66; }
.prog-track {
  flex: 1;
  height: 4px;
  background: #1a1a38;
  border-radius: 2px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, #007bff, #00ffa3);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Controls ───────────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.move-btn {
  background: #10102a;
  border: 1px solid #1e1e44;
  color: #e0e0ff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0;
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.move-btn .btn-key   { font-size: 0.55rem; color: #333355; letter-spacing: 0.5px; }
.move-btn .btn-label { font-size: 0.82rem; color: #e0e0ff; }
.move-btn:hover:not(:disabled) {
  border-color: #00ffa3;
  background: rgba(0,255,163,0.07);
}
.move-btn:hover:not(:disabled) .btn-label { color: #00ffa3; }
.move-btn:disabled { opacity: 0.22; cursor: not-allowed; }

.move-btn.active-key {
  border-color: #00ffa3;
  background: rgba(0,255,163,0.1);
}

.shooter-hint-text {
  font-size: 0.82rem;
  color: #444466;
  letter-spacing: 0.5px;
}
.shooter-hint-text.active { color: #ff5050aa; }

/* ── Breached (cleared) cell ────────────────────────────────────────────────── */
.game-cell.cell-cleared {
  background: rgba(0,200,100,0.08);
  border-color: #00c86455;
}
.game-cell.cell-cleared::after {
  content: '◇';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: #00c86466;
}

/* ── Breach target cell ─────────────────────────────────────────────────────── */
@keyframes breachGlow {
  0%,100% { box-shadow: 0 0 5px #ff8800; }
  50%      { box-shadow: 0 0 14px #ff8800, 0 0 3px #ff8800 inset; }
}
.game-cell.can-breach {
  background: rgba(255,136,0,0.18);
  border-color: #ff880099;
  animation: breachGlow 0.8s ease-in-out infinite;
  cursor: pointer;
}
.game-cell.can-breach:hover { background: rgba(255,136,0,0.35); border-color: #ff8800; }

/* ── Runner booster buttons ─────────────────────────────────────────────────── */
.booster-sep {
  width: 1px;
  height: 32px;
  background: #1e1e44;
  flex-shrink: 0;
}
.booster-btn {
  background: #10102a;
  border: 1px solid #1e1e44;
  color: #9999bb;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0;
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  cursor: pointer;
}
.booster-btn .booster-icon  { font-size: 1rem; }
.booster-btn .booster-label { font-size: 0.65rem; color: #555577; letter-spacing: 0.4px; }
.booster-btn .booster-count {
  font-size: 0.65rem;
  background: #1a1a38;
  border-radius: 4px;
  padding: 1px 5px;
  color: #555577;
}
.booster-btn:hover:not(:disabled) {
  border-color: #4444aa;
  background: rgba(100,100,255,0.07);
  color: #aaaacf;
}
.booster-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.booster-btn.booster-active {
  border-color: #7755ff88;
  background: rgba(119,85,255,0.12);
}
.booster-btn.booster-active .booster-label { color: #aa99ff; }
.booster-btn.booster-active .booster-count { color: #aa99ff; background: rgba(119,85,255,0.15); }

/* ── Jump target cell ───────────────────────────────────────────────────────── */
@keyframes jumpGlow {
  0%,100% { box-shadow: 0 0 5px #ffe040; }
  50%      { box-shadow: 0 0 14px #ffe040, 0 0 3px #ffe040 inset; }
}
.game-cell.can-jump {
  background: rgba(255,224,64,0.14);
  border-color: #ffe04099;
  animation: jumpGlow 1s ease-in-out infinite;
  cursor: pointer;
}
.game-cell.can-jump:hover { background: rgba(255,224,64,0.3); border-color: #ffe040; }

/* ── Teleport target cell ───────────────────────────────────────────────────── */
@keyframes teleportGlow {
  0%,100% { box-shadow: 0 0 5px #aa55ff; }
  50%      { box-shadow: 0 0 14px #aa55ff, 0 0 3px #aa55ff inset; }
}
.game-cell.can-teleport {
  background: rgba(170,85,255,0.12);
  border-color: #aa55ff88;
  animation: teleportGlow 1s ease-in-out infinite;
  cursor: pointer;
}
.game-cell.can-teleport:hover { background: rgba(170,85,255,0.28); border-color: #aa55ff; }

/* ── Bazooka preview ────────────────────────────────────────────────────────── */
.game-cell.bazooka-preview {
  background: rgba(255,136,0,0.18);
  border-color: #ff880066;
}
.game-cell.can-fire.bazooka-preview {
  background: rgba(255,136,0,0.22);
  border-color: #ff8800aa;
}

/* ── Bazooka blast animation ────────────────────────────────────────────────── */
@keyframes bazookaBlast {
  0%   { background: rgba(255,136,0,0.0); transform: scale(0.5); }
  30%  { background: rgba(255,200,50,0.95); border-color: #ffaa00; box-shadow: 0 0 22px #ff8800; transform: scale(1.2); }
  70%  { background: rgba(255,80,0,0.6);   border-color: #ff4400; box-shadow: 0 0 10px #ff4400; transform: scale(1.05); }
  100% { background: #1e0a0a; border-color: #3a1010; transform: scale(1); box-shadow: none; }
}
.game-cell.bazooka-blast-anim {
  animation: bazookaBlast 0.9s ease-out forwards;
}

/* ── Runner hit animation ───────────────────────────────────────────────────── */
@keyframes runnerHit {
  0%   { background: rgba(255,50,50,0.0); }
  25%  { background: rgba(255,50,50,0.75); box-shadow: 0 0 20px #ff3232; }
  60%  { background: rgba(255,50,50,0.35); }
  100% { background: rgba(0,255,163,0.18); }
}
.game-cell.runner-hit-anim {
  animation: runnerHit 0.8s ease-out forwards;
}

/* ── Lives display ──────────────────────────────────────────────────────────── */
.game-lives {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  flex-shrink: 0;
}
.lives-label {
  font-size: 0.65rem;
  color: #333355;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.heart {
  font-size: 1rem;
  transition: color 0.3s;
}
.heart-full  { color: #ff4444; }
.heart-empty { color: #333355; }

/* ── Sprint target ──────────────────────────────────────────────────────────── */
@keyframes sprintGlow {
  0%, 100% { box-shadow: 0 0 4px #00ddff88; }
  50%      { box-shadow: 0 0 14px #00ddff, 0 0 3px #00ddff inset; }
}
.game-cell.can-sprint {
  background: rgba(0,221,255,0.14);
  border-color: #00ddff88;
  animation: sprintGlow 1s ease-in-out infinite;
  cursor: pointer;
}
.game-cell.can-sprint:hover { background: rgba(0,221,255,0.3); border-color: #00ddff; }

/* ── Shield on runner cell ──────────────────────────────────────────────────── */
.game-cell.runner-shielded::after {
  content: '🛡️';
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 0.55rem;
  line-height: 1;
}
.game-cell.runner-here { position: relative; }

/* ── Shield absorb animation ────────────────────────────────────────────────── */
@keyframes shieldAbsorb {
  0%   { box-shadow: 0 0 0 2px #00aaff; }
  40%  { box-shadow: 0 0 18px 6px #00aaff; background: rgba(0,170,255,0.35); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.game-cell.shield-absorb-anim {
  animation: shieldAbsorb 0.7s ease-out forwards;
}

/* ── Hit log entry ──────────────────────────────────────────────────────────── */
.log-entry.log-hit {
  color: #ff5555;
  border-left: 2px solid #ff3333;
  padding-left: 6px;
}

/* ── Status bar ─────────────────────────────────────────────────────────────── */
.status-bar {
  font-size: 0.8rem;
  color: #333355;
  min-height: 18px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESULT SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */
.res-icon   { font-size: 3rem; line-height: 1; }
#res-title  { font-size: 1.7rem; font-weight: 800; }
.res-desc   { color: #555577; font-size: 0.85rem; margin-top: -4px; }
.res-score  { font-size: 2rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.score-pos  { color: #00ffa3; }
.score-neg  { color: #ff5050; }
.score-neu  { color: #666; }
.res-stats  { font-size: 0.75rem; color: #555577; line-height: 1.6; }
.stats-total { color: #8888aa; }

/* ══════════════════════════════════════════════════════════════════════════════
   RULES MODAL
   ══════════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeSlideIn 0.2s ease;
}
.modal-box {
  background: #10102a;
  border: 1px solid #1e1e44;
  border-radius: 16px;
  padding: 28px 28px 24px;
  max-width: 520px;
  width: 90%;
  position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: 1px solid #1e1e44;
  border-radius: 50%; color: #666688;
  font-size: 1rem; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.modal-close:hover { color: #e0e0ff; border-color: #444466; }

.modal-title {
  font-size: 1.2rem; font-weight: 800;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #00ffa3, #007bff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.rules-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.rules-role {
  background: #0d0d24;
  border: 1px solid #1a1a38;
  border-radius: 10px;
  padding: 14px 12px;
}
.rules-role-title {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; padding: 3px 8px; border-radius: 4px;
  width: fit-content; margin-bottom: 10px;
}
.rules-role ul { padding-left: 14px; }
.rules-role li {
  font-size: 0.78rem; color: #888899;
  line-height: 1.7; margin-bottom: 2px;
}
.rules-role strong { color: #c0c0dd; }

.rules-footer {
  border-top: 1px solid #1a1a38;
  padding-top: 14px;
  text-align: center;
  display: flex; flex-direction: column; gap: 6px;
}
.rules-score-row { font-size: 0.85rem; color: #666688; }
.rules-draw-note, .rules-timer-note { font-size: 0.75rem; color: #333355; }

/* ── Wall preview ───────────────────────────────────────────────────────────── */
.game-cell.wall-preview {
  background: rgba(160,80,255,0.2);
  border-color: #a050ff99;
}

/* ── Wall place animation ───────────────────────────────────────────────────── */
@keyframes wallPlace {
  0%   { background: rgba(160,80,255,0.0); transform: scale(0.7); }
  35%  { background: rgba(160,80,255,0.9); border-color: #a050ff; box-shadow: 0 0 14px #a050ff; transform: scale(1.1); }
  100% { background: #1e0a2a; border-color: #3a1050; transform: scale(1); box-shadow: none; }
}
.game-cell.wall-place-anim {
  animation: wallPlace 0.75s ease-out forwards;
}

/* ── Sonar zone ─────────────────────────────────────────────────────────────── */
@keyframes sonarPulse {
  0%   { background: rgba(0,220,255,0.0); border-color: #181834; }
  20%  { background: rgba(0,220,255,0.3); border-color: #00dcff; box-shadow: 0 0 8px #00dcff inset; }
  100% { background: rgba(0,220,255,0.0); border-color: #181834; box-shadow: none; }
}
.game-cell.sonar-zone {
  animation: sonarPulse 3s ease-out forwards;
}

/* ── Responsive: hide log panel on narrow screens ───────────────────────────── */
@media (max-width: 680px) {
  .log-panel { display: none; }
  .rules-section { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   LEADERBOARD
   ══════════════════════════════════════════════════════════════════════════════ */
.lb-box { max-width: 480px; }

.lb-tabs {
  display: flex; gap: 8px;
  margin-bottom: 16px;
}
.lb-tab {
  flex: 1; padding: 7px 0;
  background: transparent;
  border: 1px solid #1e1e44;
  border-radius: 8px;
  color: #555577; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.lb-tab:hover { border-color: #444466; color: #aaaacc; }
.lb-tab-active {
  background: rgba(0,123,255,0.15);
  border-color: #007bff;
  color: #e0e0ff;
}

.lb-loading {
  text-align: center; padding: 24px 0;
  color: #666688; font-size: 0.9rem;
}
.lb-note {
  text-align: center; margin-top: 10px;
  font-size: 0.72rem; color: #333355;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.lb-table th {
  color: #555577; font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid #1e1e44;
  text-align: left;
}
.lb-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #0f0f28;
  color: #aaaacc;
}
.lb-table td:first-child { color: #555577; width: 32px; }
.lb-table td:nth-child(3) { font-weight: 700; }

.lb-me td { background: rgba(0,123,255,0.08); color: #e0e0ff !important; }
.lb-you  { font-size: 0.7rem; color: #007bff; vertical-align: middle; }

/* ══════════════════════════════════════════════════════════════════════════════
   PROFILE
   ══════════════════════════════════════════════════════════════════════════════ */
.profile-box { max-width: 380px; }

.profile-name {
  font-size: 1.3rem; font-weight: 800;
  color: #e0e0ff; text-align: center;
  margin-bottom: 20px;
}

.profile-score-row {
  display: flex; justify-content: space-around;
  margin-bottom: 20px;
}
.profile-stat-big {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.psb-val {
  font-size: 1.6rem; font-weight: 900;
  background: linear-gradient(135deg, #00ffa3, #007bff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.psb-label {
  font-size: 0.7rem; color: #444466; text-transform: uppercase; letter-spacing: 0.05em;
}

.profile-wld {
  display: flex; gap: 10px;
  margin-bottom: 14px;
}
.wld-cell {
  flex: 1; border-radius: 10px; padding: 12px 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #0c0c22;
}
.wld-num  { font-size: 1.4rem; font-weight: 900; }
.wld-label{ font-size: 0.7rem; color: #444466; text-transform: uppercase; }
.wld-w .wld-num { color: #00ffa3; }
.wld-l .wld-num { color: #ff5050; }
.wld-d .wld-num { color: #888899; }

.profile-games {
  text-align: center; font-size: 0.78rem; color: #444466;
  margin-bottom: 12px;
}

.profile-bar-wrap {
  width: 100%; height: 8px;
  background: #0c0c22; border-radius: 99px; overflow: hidden;
}
.profile-bar {
  height: 100%; border-radius: 99px;
  transition: width 0.6s ease;
}

/* ── Profile tabs ── */
.profile-tabs {
  display: flex; gap: 6px;
  margin: 16px 0 10px;
  border-bottom: 1px solid #1a1a3a;
  padding-bottom: 6px;
}
.profile-tab-btn {
  flex: 1; padding: 7px 0; font-size: 0.78rem; font-weight: 700;
  border: none; border-radius: 8px; cursor: pointer;
  background: transparent; color: #444466;
  transition: background 0.15s, color 0.15s;
}
.profile-tab-btn:hover { background: #12123a; color: #aaaacc; }
.profile-tab-btn.active { background: #12123a; color: #00ffa3; }

.profile-tab-content { animation: fadeIn 0.2s ease; }

/* ── Match history ── */
.history-table {
  width: 100%; border-collapse: collapse; font-size: 0.75rem;
}
.history-table th {
  color: #444466; font-weight: 600; text-transform: uppercase;
  font-size: 0.65rem; letter-spacing: 0.05em;
  padding: 4px 6px; text-align: left;
}
.history-table td { padding: 5px 6px; border-top: 1px solid #12123a; }
.history-table tr:hover td { background: #0c0c22; }
.history-win  { color: #00ffa3; font-weight: 700; }
.history-loss { color: #ff5050; font-weight: 700; }
.history-draw { color: #888899; font-weight: 700; }
.history-delta-pos { color: #00ffa3; }
.history-delta-neg { color: #ff5050; }
.history-empty { text-align: center; color: #444466; padding: 20px; font-size: 0.8rem; }

/* ── Achievements grid ── */
.ach-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; padding: 4px 0;
}
.ach-card {
  border-radius: 10px; padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #0c0c22; cursor: default;
  transition: transform 0.15s;
  position: relative;
}
.ach-card:hover { transform: scale(1.06); }
.ach-card.locked { opacity: 0.35; filter: grayscale(1); }
.ach-icon { font-size: 1.5rem; line-height: 1; }
.ach-name { font-size: 0.58rem; color: #aaaacc; text-align: center; font-weight: 700; line-height: 1.2; }
.ach-card:not(.locked) .ach-name { color: #00ffa3; }

/* Tooltip on hover */
.ach-card::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #1a1a3a; color: #ccc; font-size: 0.65rem;
  padding: 5px 8px; border-radius: 6px; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity 0.15s;
  z-index: 10; border: 1px solid #2a2a5a;
}
.ach-card:hover::after { opacity: 1; }

/* ── Achievement toast ── */
.ach-toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #12123a; border: 1px solid #00ffa3;
  border-radius: 14px; padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 4px 24px rgba(0,255,163,0.18);
  z-index: 9999; min-width: 220px;
  animation: toastSlide 0.3s ease;
}
.ach-toast.hidden { display: none; }
@keyframes toastSlide {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.ach-toast-icon { font-size: 2rem; line-height: 1; }
.ach-toast-label { font-size: 0.65rem; color: #00ffa3; text-transform: uppercase; font-weight: 700; letter-spacing: 0.08em; }
.ach-toast-name  { font-size: 0.9rem; color: #e0e0ff; font-weight: 800; }

/* Lobby row of secondary buttons */
.lobby-row {
  display: flex; gap: 8px; margin-top: 8px;
}
.lobby-row .btn-secondary {
  flex: 1; font-size: 0.8rem; padding: 9px 6px;
}

/* Lobby auth sections */
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0 8px; color: #333355; font-size: 0.78rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: #1a1a38;
}
.auth-btn-row {
  display: flex; gap: 8px; margin-bottom: 4px;
}
.auth-btn-row .btn-secondary { flex: 1; }

/* Logged-in badge */
.logged-badge {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,123,255,0.1);
  border: 1px solid rgba(0,123,255,0.25);
  border-radius: 10px; padding: 10px 14px;
  margin-bottom: 12px;
}
.logged-icon { font-size: 1.1rem; }
.logged-name { font-weight: 700; color: #e0e0ff; flex: 1; }
.logged-score { font-size: 0.82rem; color: #00ffa3; font-weight: 600; }

.btn-link {
  background: none; border: none; color: #444466;
  font-size: 0.78rem; cursor: pointer; padding: 6px 0;
  text-decoration: underline; transition: color 0.15s;
}
.btn-link:hover { color: #8888aa; }

/* Auth modal */
.auth-box { max-width: 360px; }

.auth-form {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 4px;
}
.auth-label {
  font-size: 0.75rem; color: #555577;
  margin-top: 6px; margin-bottom: 2px;
}
.auth-input {
  width: 100%; padding: 10px 12px;
  background: #0c0c22; border: 1px solid #1e1e44;
  border-radius: 8px; color: #e0e0ff; font-size: 0.95rem;
  outline: none; transition: border-color 0.15s;
}
.auth-input:focus { border-color: #007bff; }

.auth-hint {
  font-size: 0.7rem; color: #333355; margin: 2px 0 0;
}
.auth-error {
  background: rgba(255,50,50,0.12);
  border: 1px solid rgba(255,50,50,0.3);
  border-radius: 8px; padding: 8px 12px;
  color: #ff7070; font-size: 0.82rem; margin-top: 4px;
}
.captcha-row {
  display: flex; align-items: center; gap: 10px;
}
.captcha-question {
  flex-shrink: 0; font-size: 1rem; font-weight: 700;
  color: #00ffa3; letter-spacing: 0.5px;
  background: rgba(0,255,163,0.06); border: 1px solid rgba(0,255,163,0.2);
  border-radius: 8px; padding: 8px 12px; white-space: nowrap;
}
.captcha-input {
  width: 80px !important; flex-shrink: 0;
  text-align: center; font-size: 1.1rem; font-weight: 700;
}

.auth-submit {
  margin-top: 10px; padding: 11px;
  background: linear-gradient(135deg, #007bff, #0055cc);
  border: none; border-radius: 10px;
  color: #fff; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: opacity 0.15s;
}
.auth-submit:hover { opacity: 0.88; }

/* ── Bot button ─────────────────────────────────────────────────────────────── */
.btn-bot {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, #1a1a3a, #2a2a5a);
  border: 1px solid #4a4a8a; border-radius: 12px;
  color: #a0a0ff; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.btn-bot:hover { border-color: #7070cc; color: #c0c0ff; }

/* ── Tooltip bubble ──────────────────────────────────────────────────────────── */
.tip-bubble {
  position: fixed; z-index: 9999;
  max-width: 240px; padding: 8px 12px;
  background: #1a1a3a; border: 1px solid #3a3a6a;
  border-radius: 8px; color: #c0c0ff; font-size: 0.78rem;
  line-height: 1.4; pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: fadeSlideIn 0.12s ease;
}

/* ── Post-game reveal ────────────────────────────────────────────────────────── */
.btn-reveal-toggle {
  margin: 10px 0 6px; width: 100%;
}

.game-reveal {
  margin-top: 8px;
  animation: fadeSlideIn 0.2s ease;
}

.reveal-legend {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  justify-content: center; margin-bottom: 8px; font-size: 0.75rem;
}
.rl-item { display: flex; align-items: center; gap: 5px; color: #8888aa; }
.rl-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.rl-path { background: #00ffa3; }
.rl-shot { background: #ff4444; }
.rl-trap { background: #ffcc00; }
.rl-trig { background: #ff8800; }

.reveal-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 1px; background: #111128;
  border: 1px solid #1e1e3a; border-radius: 6px;
  overflow: hidden; margin: 0 auto;
  max-width: 320px;
}

.rv-cell {
  aspect-ratio: 1;
  background: #0d0d22; font-size: 0.45rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
  transition: background 0.15s;
}
.rv-cell.rv-goal   { background: #001833; border-bottom: 1px solid #007bff44; }
.rv-cell.rv-shot   { background: #2a0808; }
.rv-cell.rv-trap   { background: #2a2200; }
.rv-cell.rv-triggered { background: #2a1000; }
.rv-cell.rv-path   { background: rgba(0,255,163,0.18); color: #00ffa3; font-size: 0.5rem; }
.rv-cell.rv-final  { background: rgba(0,123,255,0.25); font-size: 0.7rem; }

.reveal-controls {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; margin-top: 8px;
}
.replay-turn { font-size: 0.78rem; color: #8888aa; }

/* ── Rules abilities section ─────────────────────────────────────────────────── */
.rules-abilities {
  display: flex; gap: 12px; margin-top: 12px;
  padding: 10px; background: rgba(255,255,255,0.03);
  border-radius: 10px;
}
.rules-abilities-col { flex: 1; }
.ra-title {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
  margin-bottom: 7px; padding: 2px 6px; border-radius: 4px;
  display: inline-block;
}
.ra-item {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 0.73rem; color: #b0b0cc; line-height: 1.35;
  margin-bottom: 5px;
}
.ra-icon { font-size: 0.95rem; flex-shrink: 0; margin-top: 0px; }

@media (max-width: 480px) {
  .rules-abilities { flex-direction: column; }
}
.auth-submit:disabled { opacity: 0.5; cursor: default; }

/* ── Rematch section ─────────────────────────────────────────────────────────── */
.rematch-section {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; width: 100%; margin-top: 4px;
}

.btn-rematch {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, #1a2a4a, #2a4a8a);
  border: 1px solid #4a70cc; border-radius: 12px;
  color: #80b0ff; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; transition: border-color 0.15s, color 0.15s, opacity 0.15s;
  letter-spacing: 0.5px;
}
.btn-rematch:hover:not(:disabled) { border-color: #7090ff; color: #b0d0ff; }
.btn-rematch:disabled { opacity: 0.45; cursor: default; }

.rematch-status {
  font-size: 0.78rem; color: #8888aa;
  animation: fadeSlideIn 0.2s ease;
}

.rematch-incoming {
  width: 100%; background: rgba(0,255,163,0.06);
  border: 1px solid rgba(0,255,163,0.2); border-radius: 10px;
  padding: 12px; text-align: center;
  animation: fadeSlideIn 0.2s ease;
}
.rematch-incoming-text { font-size: 0.85rem; color: #00ffa3; margin-bottom: 10px; }
.rematch-incoming-btns { display: flex; gap: 8px; }
.btn-rematch-accept {
  flex: 1; padding: 9px;
  background: linear-gradient(135deg, #00ffa3, #007bff);
  border: none; border-radius: 8px;
  color: #07071a; font-weight: 700; font-size: 0.85rem; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-rematch-accept:hover { opacity: 0.85; }
.btn-rematch-decline { flex: 1; padding: 9px; }

/* ── Private room waiting ────────────────────────────────────────────────────── */
.private-link-wrap {
  display: flex; gap: 6px; width: 100%;
}
.private-link-input {
  flex: 1; background: #07071a; border: 1px solid #1e1e44;
  border-radius: 8px; padding: 8px 10px;
  color: #8888cc; font-size: 0.7rem; outline: none;
  font-family: monospace;
}
.btn-copy {
  padding: 8px 14px; border: 1px solid #1e1e44;
  background: #10102a; border-radius: 8px;
  color: #8888cc; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
  width: auto;
}
.btn-copy:hover { border-color: #4a4a8a; color: #c0c0ff; }
.private-hint { font-size: 0.72rem; color: #444466; }

/* ── Sound toggle button ─────────────────────────────────────────────────────── */
.btn-sound {
  position: fixed; bottom: 14px; right: 14px; z-index: 200;
  width: 36px; height: 36px; padding: 0;
  background: #10102a; border: 1px solid #1e1e44;
  border-radius: 50%; color: #555577; font-size: 1rem;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-sound:hover { border-color: #555577; color: #9999bb; }

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE (B4)
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  /* Allow body to scroll on mobile */
  body { overflow-y: auto; height: auto; min-height: 100vh; }
  .screen { height: auto; min-height: 100svh; align-items: flex-start; padding-top: 16px; }

  /* Game wrap */
  .game-wrap { height: auto; gap: 6px; padding: 6px 8px 80px; }

  /* Grid fills screen width, log goes below */
  .game-main { flex-direction: column; align-items: center; gap: 6px; }
  .grid {
    width: min(96vw, 400px) !important;
    height: min(96vw, 400px) !important;
  }
  .log-panel {
    width: 100%; max-width: min(96vw, 400px);
    height: 90px; flex-shrink: 0;
  }

  /* Header: compact */
  .game-header { padding: 6px 10px; }
  .hdr-player { min-width: 80px; }
  .hdr-name { font-size: 0.78rem; }
  .timer-ring { width: 40px; height: 40px; }
  #timer-num { font-size: 0.88rem; }

  /* Controls: wrap better */
  .controls { flex-wrap: wrap; gap: 5px; justify-content: center; }
  .move-btn { padding: 13px 10px; min-width: 70px; }
  .booster-btn { padding: 9px 6px; min-width: 52px; }
  .mode-btn { padding: 9px 10px; font-size: 0.76rem; }

  /* Result card: fits mobile */
  .card { min-width: 280px; max-width: 95vw; padding: 20px 16px; }

  /* Log font */
  .log-entry { font-size: 0.63rem; }

  /* Runner progress bar: compact */
  .runner-progress { padding: 4px 8px; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   BOT ROLE PICKER
   ══════════════════════════════════════════════════════════════════════════════ */

.bot-role-picker {
  display: flex;
  gap: 8px;
  width: 100%;
  animation: fadeSlideIn 0.15s ease;
}

.btn-role-pick {
  flex: 1;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid #2a2a5a;
  background: #0f0f28;
  color: #c0c0ff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-role-runner { border-color: #00ffa333; color: #00ffa3; }
.btn-role-runner:hover { background: rgba(0,255,163,0.08); border-color: #00ffa3; }
.btn-role-hunter { border-color: #ff505033; color: #ff7070; }
.btn-role-hunter:hover { background: rgba(255,80,80,0.08); border-color: #ff5050; }

/* Bot button highlighted when picker is open */
.btn-bot-active {
  border-color: #7070cc !important;
  color: #c0c0ff !important;
  background: linear-gradient(135deg, #202040, #303060) !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   C1 — RANK BADGES
   ══════════════════════════════════════════════════════════════════════════════ */

.rank-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  flex-shrink: 0;
}
/* Larger variant for profile modal */
.rank-badge-lg {
  font-size: 0.78rem;
  padding: 3px 10px;
  margin-bottom: 4px;
}
/* Small variant inside leaderboard table */
.rank-badge-sm {
  font-size: 0.58rem;
  padding: 1px 5px;
  margin-left: 5px;
  vertical-align: middle;
}

.rank-bronze { background: rgba(205,127,50,0.18); border-color: #cd7f3266; color: #cd7f32; }
.rank-silver { background: rgba(192,192,192,0.15); border-color: #c0c0c066; color: #c0c0c0; }
.rank-gold   { background: rgba(255,215,0,0.15);   border-color: #ffd70066; color: #ffd700; }
.rank-master { background: rgba(168,85,247,0.18);  border-color: #a855f766; color: #c084fc; }

/* Profile nickname row — name + tier badge side by side */
.profile-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}
/* reset margin-bottom from old rule that got wrapped */
.profile-name-row .profile-name { margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════════════════════════
   C2 — SHARE BUTTON
   ══════════════════════════════════════════════════════════════════════════════ */

.btn-share {
  width: 100%;
  margin-top: 8px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RECONNECT OVERLAY
   ══════════════════════════════════════════════════════════════════════════════ */

.reconnect-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 7, 26, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  border-radius: inherit;
}

.reconnect-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 40px;
  background: #10102a;
  border: 1px solid #1e1e44;
  border-radius: 16px;
  animation: fadeSlideIn 0.2s ease;
}

.reconnect-msg {
  font-size: 1rem;
  font-weight: 700;
  color: #e0e0ff;
}

.reconnect-sub {
  font-size: 0.82rem;
  color: #555577;
}

.reconnect-sub span {
  color: #f0c040;
  font-weight: 700;
}

/* Make game-wrap position:relative so overlay works */
.game-wrap { position: relative; }

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE TOUCH
   ══════════════════════════════════════════════════════════════════════════════ */

/* Prevent double-tap zoom and reduce tap delay to 0 on all interactive elements */
button, .mode-btn, .game-cell, .lb-tab { touch-action: manipulation; }

/* Prevent the grid from triggering page scroll / pull-to-refresh while playing */
.grid { touch-action: none; }

/* Prevent pull-to-refresh on the game screen */
#screen-game { overscroll-behavior: none; }

/* Wall rotate button — hidden on desktop, shown on touch devices */
.btn-wall-rotate { display: none; }

/* Swipe hint — hidden on desktop, shown on touch devices */
.swipe-hint {
  display: none;
  align-items: center; justify-content: center;
  font-size: 0.7rem; color: #00ffa355; letter-spacing: 1.5px;
  font-weight: 700; text-transform: uppercase;
  padding: 2px 0 4px;
  width: 100%; flex-shrink: 0;
}

@media (pointer: coarse) {
  /* Show touch-specific elements */
  .btn-wall-rotate { display: inline-flex; }
  .swipe-hint { display: flex; }

  /* Hide keyboard shortcut hints inside move buttons */
  .move-btn .btn-key { display: none; }

  /* Bigger move buttons for fat fingers */
  .move-btn { padding: 16px 12px; min-width: 74px; min-height: 52px; }
  .booster-btn { padding: 12px 8px; min-width: 56px; min-height: 52px; }
  .mode-btn { padding: 10px 10px; min-height: 44px; }

  /* Bigger grid cells for easier tapping */
  .game-cell { min-width: 0; min-height: 0; }

  /* Slightly larger tap area on cells with actions */
  .game-cell.can-move,
  .game-cell.can-jump,
  .game-cell.can-teleport,
  .game-cell.can-breach,
  .game-cell.can-fire { cursor: pointer; }

  /* Shooter hint text: smaller so it fits */
  .shooter-hint-text { font-size: 0.72rem; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   REWARDED ADS
   ══════════════════════════════════════════════════════════════════════════════ */

.ad-reward-section {
  width: 100%; text-align: center;
  padding: 12px 0 4px;
  border-top: 1px solid rgba(255,200,0,0.15);
  margin-top: 4px;
}
.ad-reward-hint {
  font-size: 0.78rem; color: #f0c040;
  margin: 0 0 8px; line-height: 1.4;
}
.btn-watch-ad {
  width: 100%; padding: 11px 16px;
  background: linear-gradient(135deg, #2a1f00, #4a3800);
  border: 1px solid #f0c040; border-radius: 12px;
  color: #f0c040; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.4px;
}
.btn-watch-ad:hover { background: linear-gradient(135deg, #3a2a00, #5a4800); border-color: #ffd740; }
.ad-reward-done { font-size: 0.85rem; color: #00ffa3; font-weight: 700; margin: 0; }

/* Ad modal */
.ad-box {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 28px 24px; max-width: 340px;
}
.ad-video-placeholder {
  width: 100%; min-height: 160px;
  background: #050512; border: 2px solid #1e1e44;
  border-radius: 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
}
.ad-video-icon { font-size: 2.8rem; }
.ad-video-label { font-size: 0.9rem; color: #8888aa; font-weight: 700; margin: 0; }
.ad-video-sub   { font-size: 0.72rem; color: #555577; margin: 0; }
.ad-skip-countdown {
  font-size: 0.72rem; color: #f0c040;
  background: rgba(240,192,64,0.1); border-radius: 6px;
  padding: 3px 10px; margin-top: 4px;
}
.btn-ad-collect {
  width: 100%; padding: 13px 16px;
  background: linear-gradient(135deg, #003322, #00553a);
  border: 1px solid #00ffa3; border-radius: 12px;
  color: #00ffa3; font-size: 1rem; font-weight: 800;
  cursor: pointer; transition: opacity 0.15s;
  letter-spacing: 0.5px;
}
.btn-ad-collect:disabled { opacity: 0.35; cursor: default; }
.btn-ad-collect:not(:disabled):hover { opacity: 0.85; }
.ad-disclaimer { font-size: 0.65rem; color: #444466; margin: 0; text-align: center; }
