/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

/* the hidden attribute always wins, even over display:flex rules */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, 'Segoe UI', Arial, sans-serif;
  background: #070b18;
  color: #e8eaf6;
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   MENU SCREEN
═══════════════════════════════════════════ */
#menu {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

#menu.exiting {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}

#menuCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Red / Blue faction light bleeds */
.faction-bleed {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  pointer-events: none;
}
.faction-bleed.left {
  left: 0;
  background: radial-gradient(ellipse at left center,
    rgba(180, 30, 30, 0.22) 0%,
    transparent 70%);
}
.faction-bleed.right {
  right: 0;
  background: radial-gradient(ellipse at right center,
    rgba(30, 80, 210, 0.22) 0%,
    transparent 70%);
}

/* Dark center vignette */
#menu-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 80% at 50% 50%,
      transparent 0%,
      rgba(4, 7, 18, 0.7) 100%),
    linear-gradient(to bottom,
      rgba(4, 7, 18, 0.55) 0%,
      transparent 20%,
      transparent 80%,
      rgba(4, 7, 18, 0.75) 100%);
  pointer-events: none;
}

/* Content layout */
#menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 52px;
  width: 100%;
  padding: 40px 20px;
}

/* ── Logo ── */
#menu-logo {
  text-align: center;
  animation: menuFadeDown 0.9s cubic-bezier(0.2, 0, 0, 1) both;
}

.logo-eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: #c8a84b;
  margin-bottom: 14px;
  opacity: 0.9;
}

.logo-title {
  margin: 0;
  font-size: clamp(4.5rem, 10vw, 8.5rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 1;
  background: linear-gradient(175deg, #ffffff 0%, #c5d4f5 45%, #7090d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 50px rgba(80, 130, 255, 0.35))
          drop-shadow(0 2px 8px rgba(0,0,0,0.8));
}

.logo-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 18px auto;
  width: 340px;
  animation: menuDividerExpand 1.1s 0.2s cubic-bezier(0.2, 0, 0, 1) both;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(200,168,75,0.6), transparent);
}

.divider-icon {
  color: #c8a84b;
  font-size: 1rem;
  opacity: 0.85;
}

.logo-tagline {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8898c0;
}

/* ── Menu steps ── */
.menu-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  animation: menuFadeUp 0.9s 0.15s cubic-bezier(0.2, 0, 0, 1) both;
}

/* ── Action buttons row ── */
#menu-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

/* ── Generic menu button ── */
.menu-btn {
  position: relative;
  overflow: hidden;
  padding: 15px 44px;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.22s ease;
}

.menu-btn.primary {
  border: 1px solid rgba(200,168,75,0.55);
  background: linear-gradient(135deg, rgba(200,168,75,0.12), rgba(200,168,75,0.04));
  color: #d4b55a;
  animation: btnPulse 3s 1.5s ease-in-out infinite;
}
.menu-btn.primary:hover {
  border-color: rgba(200,168,75,0.95);
  color: #f5d878;
  background: linear-gradient(135deg, rgba(200,168,75,0.22), rgba(200,168,75,0.08));
  box-shadow: 0 0 28px rgba(200,168,75,0.28), 0 0 60px rgba(200,168,75,0.1);
  transform: translateY(-2px);
  animation: none;
}
.menu-btn.primary:active { transform: translateY(0); }

.menu-btn.secondary {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #6878a0;
}
.menu-btn.secondary:hover {
  border-color: rgba(255,255,255,0.25);
  color: #a0b0d0;
  background: rgba(255,255,255,0.07);
  transform: translateY(-1px);
}

.menu-btn.sm { padding: 12px 28px; font-size: 0.8rem; }

.menu-btn:disabled { opacity: 0.4; cursor: not-allowed; animation: none; transform: none !important; }

.btn-shine {
  position: absolute;
  top: 0; left: -75%;
  width: 50%; height: 100%;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.18) 50%, transparent 100%);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
  pointer-events: none;
}
.menu-btn:hover .btn-shine { left: 125%; }

/* ── Join panel ── */
.join-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 36px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}

.join-label {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #4a5880;
}

.join-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

#roomCodeInput {
  padding: 12px 18px;
  width: 160px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  color: #e8eaf6;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
#roomCodeInput:focus { border-color: rgba(200,168,75,0.5); }
#roomCodeInput::placeholder { color: #2a3050; letter-spacing: 0.1em; }

.join-error {
  font-size: 0.78rem;
  color: #d64545;
  min-height: 1em;
}

.back-link {
  background: none;
  border: none;
  color: #3a4460;
  font-size: 0.78rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: color 0.15s;
}
.back-link:hover { color: #6878a0; }

/* ── Created panel ── */
.created-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 48px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(200,168,75,0.18);
  border-radius: 10px;
}

.created-label {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #c8a84b;
  opacity: 0.7;
}

.created-code {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #c8a84b;
  filter: drop-shadow(0 0 20px rgba(200,168,75,0.4));
}

.created-hint {
  font-size: 0.75rem;
  color: #3a4460;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.created-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

/* ── Rules ── */
#menu-rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  max-width: 400px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 0.8rem;
  color: #6878a0;
  line-height: 1.5;
}

.rule-num {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #c8a84b;
  opacity: 0.7;
  margin-top: 2px;
}

/* ── Footer ── */
#menu-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #3a4460;
  text-align: center;
  animation: menuFadeUp 1s 0.3s ease both;
}
#menu-footer strong { color: #c8a84b; font-weight: 700; }

/* ── Ad slot ── */
.ad-slot {
  width: min(728px, 92vw);
  margin: 4px auto 0;
  text-align: center;
  animation: menuFadeUp 1s 0.4s ease both;
}
.ad-label {
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #2a3450;
  margin-bottom: 4px;
}
.ad-slot ins { min-height: 90px; }

/* ═══════════════════════════════════════════
   MENU ANIMATIONS
═══════════════════════════════════════════ */
@keyframes menuFadeDown {
  from { opacity: 0; transform: translateY(-24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes menuFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes menuDividerExpand {
  from { opacity: 0; width: 0; }
  to   { opacity: 1; width: 340px; }
}
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(200,168,75,0); }
  50%       { box-shadow: 0 0 20px rgba(200,168,75,0.2), 0 0 50px rgba(200,168,75,0.06); }
}

/* ═══════════════════════════════════════════
   GAME UI — hidden until battle starts
═══════════════════════════════════════════ */
.game-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease 0.1s;
}
.game-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Top Bar ── */
#topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: linear-gradient(to bottom, rgba(12, 16, 34, 0.97), rgba(8, 11, 26, 0.92));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(200, 168, 75, 0.16);
  position: relative;
  z-index: 10;
}

/* faction accents on topbar edges */
#topbar::before, #topbar::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 3px;
}
#topbar::before { left: 0;  background: linear-gradient(to bottom, #d64545, transparent); }
#topbar::after  { right: 0; background: linear-gradient(to bottom, #3b6bd6, transparent); }

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-icon {
  color: #c8a84b;
  font-size: 1rem;
  filter: drop-shadow(0 0 8px rgba(200,168,75,0.45));
}

.brand-name {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  background: linear-gradient(175deg, #ffffff 0%, #c5d4f5 55%, #8aa5dd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #c8a84b;
  opacity: 0.75;
}

.hud {
  display: flex;
  gap: 12px;
}

.hud-chip {
  padding: 7px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #a8b8d8;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 5px;
  text-transform: uppercase;
}

#status {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f5c842;
  opacity: 0;
  transition: opacity 0.15s;
  min-width: 200px;
  text-align: center;
  text-shadow: 0 0 12px rgba(245,200,66,0.4);
}
#status.active { opacity: 1; }

/* ── Layout ── */
#main {
  display: flex;
  height: calc(100vh - 64px);
}

/* ── Sidebar ── */
#sidebar {
  width: 248px;
  background: linear-gradient(to right, rgba(7, 10, 24, 0.96), rgba(10, 14, 30, 0.92));
  border-right: 1px solid rgba(200, 168, 75, 0.1);
  padding: 16px 14px;
  overflow-y: auto;
}

.panel {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  position: relative;
}

/* thin gold top accent, echoing the menu's divider language */
.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(200,168,75,0.35), transparent);
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: #c8a84b;
  opacity: 0.75;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: #8494b4;
  margin-bottom: 7px;
}

.stat-row > span:last-child {
  font-weight: 700;
  color: #c5d4f5;
}

.stat-row .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
  vertical-align: middle;
}
.dot.red     { background: #d64545; box-shadow: 0 0 5px #d64545; }
.dot.blue    { background: #3b6bd6; box-shadow: 0 0 5px #3b6bd6; }
.dot.neutral { background: #6a7090; }

#selectedInfo {
  font-size: 0.82rem;
  line-height: 1.7;
  color: #8494b4;
}

#selectedInfo strong {
  color: #c5d4f5;
  letter-spacing: 0.08em;
}

/* ── Gold slider ── */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, rgba(200,168,75,0.45), rgba(200,168,75,0.12));
  outline: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #c8a84b;
  border: 2px solid #0a0e1e;
  box-shadow: 0 0 8px rgba(200,168,75,0.5);
  transition: transform 0.12s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

input[type=range]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #c8a84b;
  border: 2px solid #0a0e1e;
  box-shadow: 0 0 8px rgba(200,168,75,0.5);
}

#powerDisplay { color: #c8a84b; }

.panel label { color: #8494b4; }

/* ═══════════════════════════════════════════
   WAITING FOR OPPONENT OVERLAY
═══════════════════════════════════════════ */
#waiting-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 248px; /* clear of the sidebar */
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 18, 0.78);
  backdrop-filter: blur(5px);
  z-index: 50;
  animation: menuFadeDown 0.4s ease both;
}

.waiting-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 44px 64px;
  background: rgba(8, 12, 28, 0.92);
  border: 1px solid rgba(200, 168, 75, 0.18);
  border-radius: 14px;
}

.waiting-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(200, 168, 75, 0.15);
  border-top-color: #c8a84b;
  animation: spin 1s linear infinite;
  margin-bottom: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.waiting-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #c5d4f5;
}

.waiting-sub {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: #4a5880;
}

.waiting-code {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #c8a84b;
  filter: drop-shadow(0 0 18px rgba(200,168,75,0.4));
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   PROFILE CARD
═══════════════════════════════════════════ */
#profile-card {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
  width: 264px;
  background: rgba(8, 12, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  overflow: hidden;
  animation: menuFadeDown 0.8s 0.3s ease both;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#profile-card.open {
  border-color: rgba(200, 168, 75, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

#profileToggle {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 12px 14px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
#profileToggle:hover { background: rgba(255,255,255,0.04); }

#pt-avatar {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px rgba(200,168,75,0.35));
}

.pt-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#pt-title {
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #c5d4f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#pt-sub {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: #c8a84b;
  opacity: 0.8;
  text-transform: uppercase;
}

#pt-chevron {
  color: #4a5880;
  font-size: 0.8rem;
  transition: transform 0.25s ease, color 0.15s;
}
#profile-card.open #pt-chevron { transform: rotate(180deg); color: #c8a84b; }

#profile-body {
  padding: 4px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  animation: bodySlide 0.22s ease both;
}

@keyframes bodySlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

#profile-view {
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* sign-in nudge */
#profile-card.shake { animation: cardShake 0.4s ease; }

@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-7px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(3px); }
}

/* auth forms */
.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.auth-tab {
  flex: 1;
  padding: 8px 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  color: #4a5880;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-tab:hover  { color: #7888a8; }
.auth-tab.active {
  border-color: rgba(200,168,75,0.5);
  background: rgba(200,168,75,0.07);
  color: #c8a84b;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-form input {
  padding: 9px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: #e8eaf6;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
.auth-form input:focus { border-color: rgba(200,168,75,0.5); }
.auth-form input::placeholder { color: #3a4460; }

.auth-error {
  font-size: 0.74rem;
  color: #d66060;
  min-height: 1em;
  line-height: 1.4;
}

.guest-hint {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: #4a5880;
  text-align: center;
  margin-top: -22px; /* tucks neatly under the action buttons (flex gap is 32px) */
}

/* ═══════════════════════════════════════════
   AUTH ENTRY BUTTONS (top right, signed out)
═══════════════════════════════════════════ */
#auth-buttons {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 5;
  display: flex;
  gap: 10px;
  animation: menuFadeDown 0.8s 0.3s ease both;
}

.auth-cta {
  padding: 9px 22px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.18s;
}

.auth-cta.ghost {
  background: none;
  border: 1px solid rgba(255,255,255,0.14);
  color: #8898b8;
}
.auth-cta.ghost:hover {
  border-color: rgba(255,255,255,0.3);
  color: #c5d4f5;
  background: rgba(255,255,255,0.04);
}

.auth-cta.solid {
  border: 1px solid rgba(200,168,75,0.55);
  background: linear-gradient(135deg, rgba(200,168,75,0.16), rgba(200,168,75,0.06));
  color: #d4b55a;
}
.auth-cta.solid:hover {
  border-color: rgba(200,168,75,0.95);
  color: #f5d878;
  box-shadow: 0 0 18px rgba(200,168,75,0.25);
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════
   AUTH MODAL
═══════════════════════════════════════════ */
#auth-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 14, 0.78);
  backdrop-filter: blur(6px);
  animation: modalFade 0.25s ease both;
}

.modal-box {
  position: relative;
  width: 360px;
  padding: 36px 38px 30px;
  background: rgba(10, 14, 30, 0.97);
  border: 1px solid rgba(200, 168, 75, 0.22);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: modalPop 0.3s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes modalFade {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: #4a5880;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: #c5d4f5; }

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-eyebrow {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #c8a84b;
  opacity: 0.75;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #e8eaf6;
}

.modal-form input {
  padding: 12px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #e8eaf6;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.modal-form input:focus {
  border-color: rgba(200,168,75,0.55);
  background: rgba(255,255,255,0.07);
}
.modal-form input::placeholder { color: #3a4460; }

.modal-alt {
  margin-top: 8px;
  font-size: 0.76rem;
  color: #4a5880;
  text-align: center;
}
.modal-alt a {
  color: #c8a84b;
  cursor: pointer;
  font-weight: 600;
}
.modal-alt a:hover { text-decoration: underline; }

#profile-summary {
  display: flex;
  align-items: center;
  gap: 10px;
}

#profile-avatar {
  font-size: 1.7rem;
  filter: drop-shadow(0 0 8px rgba(200,168,75,0.35));
}

.profile-meta { flex: 1; min-width: 0; }

#profile-name {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #c5d4f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#profile-record {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #c8a84b;
  opacity: 0.8;
}

#profileEditBtn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #6878a0;
  font-size: 0.85rem;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s;
}
#profileEditBtn:hover { color: #c8a84b; border-color: rgba(200,168,75,0.4); }

#profile-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pe-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #c8a84b;
  opacity: 0.7;
}

#profileNameInput {
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: #e8eaf6;
  font-size: 0.88rem;
  outline: none;
}
#profileNameInput:focus { border-color: rgba(200,168,75,0.5); }

#avatarChoices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.avatar-choice {
  font-size: 1.2rem;
  padding: 7px 0;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.avatar-choice:hover  { border-color: rgba(255,255,255,0.25); }
.avatar-choice.active { border-color: rgba(200,168,75,0.7); background: rgba(200,168,75,0.1); }

.pe-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}

.pe-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #6878a0;
}
.pe-stat-row span:last-child { color: #c5d4f5; font-weight: 600; }

/* ═══════════════════════════════════════════
   OPTION ROWS (size / duration)
═══════════════════════════════════════════ */
#option-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.opt-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #4a5880;
  text-transform: uppercase;
  min-width: 100px;
  text-align: right;
}

.opt-btns { display: flex; gap: 8px; }

.opt-btn {
  padding: 7px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: #4a5880;
  cursor: pointer;
  transition: all 0.15s;
}
.opt-btn:hover  { border-color: rgba(255,255,255,0.2); color: #7888a8; }
.opt-btn.active { border-color: rgba(200,168,75,0.5); background: rgba(200,168,75,0.07); color: #c8a84b; }

/* ═══════════════════════════════════════════
   LOBBY OVERLAY
═══════════════════════════════════════════ */
#lobby-overlay {
  position: absolute;
  top: 0; bottom: 0;
  left: 248px;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 18, 0.82);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.lobby-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 48px;
  background: rgba(8, 12, 28, 0.94);
  border: 1px solid rgba(200, 168, 75, 0.18);
  border-radius: 16px;
  min-width: 540px;
}

.lobby-eyebrow {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #c8a84b;
  opacity: 0.7;
}

.lobby-code {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #c8a84b;
  filter: drop-shadow(0 0 18px rgba(200,168,75,0.4));
  line-height: 1;
}

.lobby-teams {
  display: flex;
  gap: 14px;
  width: 100%;
}

.lobby-team {
  flex: 1;
  border-radius: 10px;
  padding: 12px;
  min-height: 120px;
}
.lobby-team.red  { background: rgba(214,69,69,0.06);  border: 1px solid rgba(214,69,69,0.25); }
.lobby-team.blue { background: rgba(59,107,214,0.06); border: 1px solid rgba(59,107,214,0.25); }

.lt-header {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  margin-bottom: 10px;
}
.lobby-team.red  .lt-header { color: #e07070; }
.lobby-team.blue .lt-header { color: #7095e0; }

.lobby-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: #c5d4f5;
}
.lobby-player.me { background: rgba(255,255,255,0.06); }

.lp-avatar { font-size: 1rem; }
.lp-name   { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lp-ready {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #3a4460;
}
.lp-ready.yes { color: #6fd66f; }

.lobby-empty {
  font-size: 0.78rem;
  color: #3a4460;
  font-style: italic;
  padding: 6px 8px;
}

.lobby-actions { display: flex; gap: 12px; }

.menu-btn.is-ready {
  border-color: rgba(111, 214, 111, 0.6);
  color: #6fd66f;
  background: rgba(111, 214, 111, 0.08);
}

.lobby-hint {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #4a5880;
}

/* ═══════════════════════════════════════════
   COUNTDOWN OVERLAY
═══════════════════════════════════════════ */
#countdown-overlay {
  position: absolute;
  top: 0; bottom: 0;
  left: 248px;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(4, 7, 18, 0.6);
  backdrop-filter: blur(3px);
  z-index: 50;
  pointer-events: none;
}

.countdown-num {
  font-size: 8rem;
  font-weight: 900;
  color: #c8a84b;
  filter: drop-shadow(0 0 40px rgba(200,168,75,0.5));
  animation: countPop 1s ease both;
  line-height: 1;
}

.countdown-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: #8898b8;
}

@keyframes countPop {
  0%   { transform: scale(1.6); opacity: 0; }
  20%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.85; }
}

/* ═══════════════════════════════════════════
   DAMAGE FLOATS / ATTACKABLE
═══════════════════════════════════════════ */
.dmg-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
  font-weight: 900;
  pointer-events: none;
  z-index: 6;
  animation: dmgFloat 0.9s ease-out forwards;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.dmg-float.red  { color: #ff9090; }
.dmg-float.blue { color: #90b8ff; }

@keyframes dmgFloat {
  0%   { opacity: 0;   margin-top: 0; }
  15%  { opacity: 1; }
  100% { opacity: 0;   margin-top: -38px; }
}

.tile.attackable {
  box-shadow: 0 0 0 2px rgba(245, 200, 66, 0.55), 0 0 16px rgba(245, 200, 66, 0.25);
  animation: attackablePulse 1s ease-in-out infinite;
}

@keyframes attackablePulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(245,200,66,0.55), 0 0 16px rgba(245,200,66,0.2); }
  50%       { box-shadow: 0 0 0 2px rgba(245,200,66,0.85), 0 0 22px rgba(245,200,66,0.4); }
}

/* ═══════════════════════════════════════════
   FORCES / BATTLE LOG
═══════════════════════════════════════════ */
.force-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: #8494b4;
  margin-bottom: 5px;
}
.force-avatar { font-size: 0.9rem; }
.force-name   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.force-empty  { font-size: 0.78rem; color: #3a4460; font-style: italic; }

#battle-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.log-entry {
  font-size: 0.72rem;
  line-height: 1.4;
  color: #5868a0;
  animation: logIn 0.25s ease both;
}
.log-entry.red    { color: #c07070; }
.log-entry.blue   { color: #7090d0; }
.log-entry.system { color: #c8a84b; opacity: 0.8; }

@keyframes logIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.kbd-hint {
  font-size: 0.66rem;
  color: #3a4460;
  margin-top: 7px;
  letter-spacing: 0.05em;
}

.win-record {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: #c8a84b;
  margin: -24px 0 28px;
  min-height: 1em;
}

/* ── Grid ── */
#game {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 92px);
  gap: 10px;
  padding: 24px;
  justify-content: center;
  align-content: center;
  background:
    radial-gradient(ellipse 50% 65% at 50% 50%, rgba(24, 34, 70, 0.55) 0%, transparent 100%),
    radial-gradient(ellipse at left center,  rgba(180, 30, 30, 0.1) 0%, transparent 55%),
    radial-gradient(ellipse at right center, rgba(30, 80, 210, 0.1) 0%, transparent 55%);
  position: relative;
}

/* dark vignette framing the battlefield, echoing the menu */
#game::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom,
      rgba(4, 7, 18, 0.4) 0%,
      transparent 18%,
      transparent 82%,
      rgba(4, 7, 18, 0.5) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ── Tile ── */
.tile {
  position: relative;
  overflow: hidden;
  width: 92px;
  height: 92px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s, opacity 0.12s, box-shadow 0.12s;
  user-select: none;
  border: 1px solid rgba(255,255,255,0.07);
}

/* Ownership */
.tile.red {
  background: linear-gradient(145deg, #c43c3c, #8a2020);
  box-shadow: 0 4px 16px rgba(180,40,40,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}
.tile.blue {
  background: linear-gradient(145deg, #3060c8, #1e3d88);
  box-shadow: 0 4px 16px rgba(40,80,200,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}
.tile.neutral {
  background: linear-gradient(145deg, #525870, #363a50);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Broken — defense gone, not yet contested */
.tile.broken {
  filter: saturate(0.2) brightness(0.55);
}
.tile.broken::before {
  content: "✕";
  position: absolute;
  font-size: 2rem;
  opacity: 0.35;
  pointer-events: none;
}

/* Under attack — pending in queue */
.tile.under-attack {
  box-shadow: 0 0 0 2px rgba(245, 200, 66, 0.85) inset,
              0 0 20px rgba(245, 200, 66, 0.2);
}

/* Contested — tug of war */
.tile.contested { animation: pulse 0.75s ease-in-out infinite; }

/* Progress bar (no text) */
.tile.contested::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0;
  height: 5px;
  width: calc(var(--cap, 0) * 1%);
  background: rgba(255,255,255,0.85);
  border-radius: 0 3px 0 10px;
  transition: width 0.2s ease;
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

/* Selected */
.tile.selected {
  outline: 2px solid rgba(255,255,255,0.8);
  outline-offset: 2px;
  box-shadow: 0 0 20px rgba(255,255,255,0.15);
}

/* Out of range */
.tile.out-of-range {
  opacity: 0.22;
  pointer-events: none;
}

/* Flash capture burst */
.tile.flash { animation: flash 0.5s ease forwards; }

/* Hover */
.tile:hover:not(.out-of-range) { transform: scale(1.07); }

/* ═══════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════ */
@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes flash {
  0%   { transform: scale(1.3);  filter: brightness(2.5); }
  60%  { transform: scale(1.05); filter: brightness(1.3); }
  100% { transform: scale(1);    filter: brightness(1); }
}

/* ═══════════════════════════════════════════
   WIN OVERLAY
═══════════════════════════════════════════ */
#win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(6px);
  animation: menuFadeDown 0.5s ease both;
}

.win-box {
  text-align: center;
  padding: 56px 80px;
  background: rgba(8,12,28,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  box-shadow: 0 0 80px rgba(0,0,0,0.6);
}

.win-title {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 30px currentColor);
}
.win-title.win  { color: #f5c842; }
.win-title.lose { color: #5060a0; }
.win-title.draw { color: #8898b8; }

.win-sub {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: #4a5880;
  margin-bottom: 40px;
  text-transform: uppercase;
}

.win-box button {
  padding: 14px 44px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: 3px;
  border: 1px solid rgba(200,168,75,0.5);
  background: rgba(200,168,75,0.1);
  color: #c8a84b;
  cursor: pointer;
  transition: all 0.2s;
}
.win-box button:hover {
  background: rgba(200,168,75,0.2);
  border-color: rgba(200,168,75,0.9);
  color: #f5d878;
  box-shadow: 0 0 24px rgba(200,168,75,0.25);
}

/* ═══════════════════════════════════════════
   ROOM SIDEBAR
═══════════════════════════════════════════ */
.room-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.room-code-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #c8a84b;
}
.copy-btn {
  padding: 3px 10px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-radius: 3px;
  border: 1px solid rgba(200,168,75,0.3);
  background: rgba(200,168,75,0.06);
  color: #c8a84b;
  cursor: pointer;
  transition: all 0.15s;
}
.copy-btn:hover { background: rgba(200,168,75,0.15); border-color: rgba(200,168,75,0.6); }
.room-status-text {
  font-size: 0.75rem;
  color: #3a4870;
  margin-top: 6px;
}

/* ═══════════════════════════════════════════
   PROJECTILE CANVAS
═══════════════════════════════════════════ */
#projectile-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* ═══════════════════════════════════════════
   MODE SELECTOR
═══════════════════════════════════════════ */
#mode-selector {
  display: flex;
  gap: 10px;
}

.mode-opt {
  flex: 1;
  padding: 12px 20px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: #4a5880;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mode-opt:hover { border-color: rgba(255,255,255,0.16); color: #7888a8; }
.mode-opt.active {
  border-color: rgba(200,168,75,0.5);
  background: rgba(200,168,75,0.07);
  color: #c8a84b;
}
.mode-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.15em; }
.mode-desc  { font-size: 0.7rem; opacity: 0.7; }

#duration-row {
  display: flex;
  align-items: center;
  gap: 14px;
  animation: menuFadeUp 0.3s ease both;
}
.dur-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #4a5880;
  text-transform: uppercase;
}
#duration-btns { display: flex; gap: 8px; }
.dur-btn {
  padding: 7px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: #4a5880;
  cursor: pointer;
  transition: all 0.15s;
}
.dur-btn:hover  { border-color: rgba(255,255,255,0.2); color: #7888a8; }
.dur-btn.active { border-color: rgba(200,168,75,0.5); background: rgba(200,168,75,0.07); color: #c8a84b; }

/* ═══════════════════════════════════════════
   SCORE / TIMER HUD
═══════════════════════════════════════════ */
#score-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.88rem;
}

.score-block {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #8898b8;
}
.score-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.score-dot.red  { background: #d64545; box-shadow: 0 0 5px #d64545; }
.score-dot.blue { background: #3b6bd6; box-shadow: 0 0 5px #3b6bd6; }

.timer-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #8898b8;
  min-width: 54px;
  text-align: center;
  transition: color 0.3s;
}
.timer-text.urgent { color: #e05050; animation: timerPulse 1s ease-in-out infinite; }

@keyframes timerPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ── Mute button ── */
.topbar-icon-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.topbar-icon-btn:hover { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); }

/* ═══════════════════════════════════════════
   SURRENDER
═══════════════════════════════════════════ */
.surrender-btn {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  border-radius: 6px;
  border: 1px solid rgba(214, 69, 69, 0.25);
  background: rgba(214, 69, 69, 0.05);
  color: #7a4a55;
  cursor: pointer;
  transition: all 0.18s;
}
.surrender-btn:hover {
  border-color: rgba(214, 69, 69, 0.5);
  background: rgba(214, 69, 69, 0.12);
  color: #d67070;
}
.surrender-btn.armed {
  border-color: rgba(214, 69, 69, 0.85);
  background: rgba(214, 69, 69, 0.2);
  color: #ff8080;
  animation: surrenderPulse 0.6s ease-in-out infinite;
}
.surrender-btn:disabled { opacity: 0.5; cursor: default; animation: none; }

@keyframes surrenderPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(214,69,69,0); }
  50%       { box-shadow: 0 0 14px rgba(214,69,69,0.4); }
}

/* white flag rain on surrender endings */
.flag-rain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.flag {
  position: absolute;
  top: -8%;
  animation-name: flagFall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.3));
}

@keyframes flagFall {
  0%   { transform: translateY(0) rotate(-12deg); }
  25%  { transform: translateY(28vh) rotate(10deg); }
  50%  { transform: translateY(56vh) rotate(-10deg); }
  75%  { transform: translateY(84vh) rotate(12deg); }
  100% { transform: translateY(115vh) rotate(-8deg); }
}

/* ═══════════════════════════════════════════
   SIDEBAR DRAWER (mobile toggle)
═══════════════════════════════════════════ */
#sidebarToggle { display: none; font-size: 1.15rem; }

#sidebar-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 12, 0.55);
  z-index: 18;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 900px)
═══════════════════════════════════════════ */
@media (max-width: 900px) {
  #menu-content { gap: 30px; padding: 30px 16px; }
  .logo-title { font-size: clamp(3.2rem, 13vw, 5.5rem); }
  .logo-divider { width: min(300px, 80vw); }

  #mode-selector { flex-wrap: wrap; justify-content: center; }
  .mode-opt { flex: 1 1 140px; }

  .opt-row { flex-direction: column; gap: 8px; align-items: center; }
  .opt-label { text-align: center; min-width: 0; }

  .lobby-box { min-width: 0; width: min(540px, 92vw); padding: 28px 22px; }
  .lobby-teams { flex-direction: column; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — PHONE (≤ 640px)
═══════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Menu can scroll vertically on short screens */
  #menu { align-items: flex-start; overflow-y: auto; }
  #menu-content { min-height: 100%; justify-content: center; }

  /* Menu */
  #auth-buttons { top: 14px; right: 14px; gap: 7px; }
  .auth-cta { padding: 8px 15px; font-size: 0.66rem; letter-spacing: 0.12em; }
  #profile-card { top: 12px; right: 12px; left: 12px; width: auto; }

  #menu-content { gap: 22px; padding: 74px 14px 30px; }
  .logo-eyebrow { font-size: 0.62rem; letter-spacing: 0.28em; }
  .logo-title { font-size: clamp(2.8rem, 16vw, 4rem); letter-spacing: 0.08em; }
  .logo-tagline { font-size: 0.72rem; }
  #menu-rules { display: none; }            /* keep the phone menu compact */
  .mode-opt { flex: 1 1 100%; }
  #menu-actions { flex-direction: column; width: min(320px, 86vw); }
  #menu-actions .menu-btn { width: 100%; }
  .guest-hint { margin-top: 4px; }
  #menu-footer { gap: 16px; font-size: 0.62rem; }

  .modal-box { width: calc(100vw - 28px); padding: 30px 24px 26px; }

  /* Top bar */
  #topbar { height: 56px; padding: 0 10px; gap: 8px; }
  #sidebarToggle { display: inline-block; }
  .brand-tag { display: none; }
  .brand-name { font-size: 0.85rem; letter-spacing: 0.14em; }
  .hud { gap: 6px; }
  .hud-chip { padding: 6px 9px; font-size: 0.66rem; letter-spacing: 0.02em; }
  #player-chip { display: none; }   /* name is shown in the sidebar roster */
  /* status overlays the bar instead of taking layout width */
  #status {
    position: absolute;
    top: 56px; left: 0; right: 0;
    min-width: 0;
    padding: 6px 12px;
    background: rgba(8, 11, 26, 0.95);
    z-index: 9;
  }
  #score-hud { gap: 9px; font-size: 0.78rem; }
  .timer-text { font-size: 0.92rem; min-width: 44px; }

  #main { height: calc(100vh - 56px); height: calc(100dvh - 56px); }

  /* Sidebar becomes a slide-in drawer */
  #sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: min(280px, 84vw);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 6px 0 26px rgba(0,0,0,0.5);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-backdrop.show { display: block; }

  /* Game fills the screen; grid is centered and scroll-safe */
  #game {
    padding: 14px;
    width: 100%;
    overflow: auto;
  }

  /* Phase overlays span full width (no sidebar offset) */
  #waiting-overlay, #lobby-overlay, #countdown-overlay { left: 0; }
  .countdown-num { font-size: 5.5rem; }

  /* Win overlay fits phone */
  .win-box { padding: 40px 30px; width: calc(100vw - 32px); }
  .win-title { font-size: 2.4rem; }

  /* Larger touch targets, no sticky hover-zoom on touch */
  .tile:hover:not(.out-of-range) { transform: none; }
  .tile.attackable { animation: none; }     /* steadier on small screens */
}

/* Devices that can't truly hover (most phones/tablets): kill hover FX */
@media (hover: none) {
  .tile:hover:not(.out-of-range) { transform: none; }
  .menu-btn:hover, .opt-btn:hover, .mode-opt:hover { transform: none; }
}
