/* ============================================================
   TD Duel — Liquid Glass Neo-Tech Theme
   Telegram Mini App · Main Stylesheet
   ============================================================
   Glassmorphism meets terminal aesthetics.
   All colours driven by CSS custom properties for easy theming.
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-primary:        #0a0e17;
  --bg-glass:          rgba(15, 23, 42, 0.75);
  --bg-glass-hover:    rgba(15, 23, 42, 0.90);

  /* Borders */
  --border-glass:       rgba(100, 200, 255, 0.15);
  --border-glass-active:rgba(100, 200, 255, 0.40);

  /* Text */
  --text-primary:      #e2e8f0;
  --text-secondary:    #94a3b8;
  --text-accent:       #38bdf8;
  --text-highlight:    #22d3ee;

  /* Buttons */
  --btn-primary:       linear-gradient(135deg, #0ea5e9, #6366f1);
  --btn-danger:        #ef4444;
  --btn-success:       #22c55e;

  /* Game-specific */
  --hp-bar:            #22c55e;
  --hp-bar-low:        #ef4444;
  --tower-tier1:       #38bdf8;
  --tower-tier2:       #a78bfa;
  --income-green:      #4ade80;

  /* Effects */
  --shadow-glow:       0 0 20px rgba(56, 189, 248, 0.15);

  /* Radii */
  --radius-sm:         8px;
  --radius-md:         12px;
  --radius-lg:         16px;
  --radius-xl:         20px;
  --radius-full:       9999px;

  /* Spacing */
  --space-xs:          4px;
  --space-sm:          8px;
  --space-md:          16px;
  --space-lg:          24px;
  --space-xl:          32px;

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-mid:    250ms ease;
  --transition-slow:   400ms ease;

  /* Safe-area insets (overridden by env() where needed) */
  --sat:               0px;
  --sar:               0px;
  --sab:               0px;
  --sal:               0px;
}

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

html {
  height: 100%;
  overflow: hidden;                         /* prevent scroll bounce */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-overflow-scrolling: auto;         /* avoid iOS momentum bounce */
  overscroll-behavior: none;                /* standard no-bounce */
}

body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* safe-area padding for notched iPhones */
  padding-top:    env(safe-area-inset-top,    var(--sat));
  padding-right:  env(safe-area-inset-right,  var(--sar));
  padding-bottom: env(safe-area-inset-bottom, var(--sab));
  padding-left:   env(safe-area-inset-left,   var(--sal));
}

/* Prevent iOS rubber-band scroll on children too */
#app {
  height: 100%;
  overflow: hidden;
}

/* Remove default button / link chrome */
a, button, input, textarea, select {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

button {
  cursor: pointer;
  touch-action: manipulation;              /* remove 300 ms delay */
}

/* Minimum 44 px tap targets (WCAG / Apple HIG) */
button,
[role="button"],
a,
input,
select,
textarea {
  min-height: 44px;
  min-width:  44px;
}

/* ── 2. Screen Containers ───────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-mid),
              visibility var(--transition-mid);
  z-index: 1;
}

/* ── 3. Active Screen ──────────────────────────────────────── */
.screen.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

/* ── 4. Glass Panel ─────────────────────────────────────────── */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-glow);
  transition: background var(--transition-fast),
              border-color var(--transition-fast);
}

.glass-panel:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-active);
}

/* ── 5. Glass Button ────────────────────────────────────────── */
.glass-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 44px;
  min-width:  44px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--btn-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
              var(--shadow-glow);
  transition: transform var(--transition-fast),
              box-shadow var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.glass-button:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4),
              0 0 30px rgba(56, 189, 248, 0.25);
}

.glass-button:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Variants */
.glass-button--danger {
  background: var(--btn-danger);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.glass-button--danger:hover {
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.glass-button--success {
  background: var(--btn-success);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.glass-button--success:hover {
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
}

.glass-button--ghost {
  background: transparent;
  border: 1px solid var(--border-glass);
  box-shadow: none;
}

.glass-button--ghost:hover {
  background: var(--bg-glass);
  border-color: var(--border-glass-active);
}

.glass-button--lg {
  padding: 14px 32px;
  font-size: 18px;
  border-radius: var(--radius-lg);
  min-height: 52px;
}

.glass-button--sm {
  padding: 6px 14px;
  font-size: 12px;
  min-height: 36px;
}

.glass-button:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── 6. Lobby Screen ────────────────────────────────────────── */
.screen--lobby {
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

.screen--lobby .lobby-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-accent), var(--text-highlight));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.screen--lobby .lobby-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  max-width: 280px;
}

.screen--lobby .play-btn {
  /* Large hero play button */
  width: 160px;
  height: 160px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: pulse 2.5s ease-in-out infinite;
}

.screen--lobby .play-btn:active {
  animation: none;
  transform: scale(0.94);
}

/* ── 7. Queue Screen ────────────────────────────────────────── */
.screen--queue {
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

.searching-spinner {
  width: 80px;
  height: 80px;
  border: 4px solid var(--border-glass);
  border-top-color: var(--text-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.queue-status {
  font-size: 16px;
  color: var(--text-secondary);
}

.queue-timer {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-accent);
}

/* ── 8. Game Screen ─────────────────────────────────────────── */
.screen--game {
  position: relative;
  overflow: hidden;
}

.screen--game .game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── 9. HUD (Heads-Up Display) ──────────────────────────────── */
.hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, var(--sat)) + var(--space-sm));
  left: var(--space-sm);
  right: var(--space-sm);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
  z-index: 20;
}

.hud .glass-panel {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 1;
  min-width: 0;
}

/* Stat pill — compact HUD chip */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.stat-pill .stat-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stat-pill .stat-value {
  font-variant-numeric: tabular-nums;
}

.stat-pill--hp .stat-value { color: var(--hp-bar); }
.stat-pill--coins .stat-value { color: var(--income-green); }
.stat-pill--income .stat-value { color: var(--income-green); }
.stat-pill--wave .stat-value { color: var(--text-accent); }

/* ── 10. HP Bar ─────────────────────────────────────────────── */
.hp-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.hp-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--hp-bar), #4ade80);
  transition: width var(--transition-mid);
}

.hp-bar__fill--low {
  background: linear-gradient(90deg, var(--hp-bar-low), #f97316);
}

/* Larger variant for result screen */
.hp-bar--lg {
  height: 14px;
  border-radius: var(--radius-sm);
}

.hp-bar--lg .hp-bar__fill {
  border-radius: var(--radius-sm);
}

/* ── 11. Bottom Sheet ───────────────────────────────────────── */
.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-glass);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
  padding: var(--space-sm) var(--space-md) var(--space-md);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, var(--sab)));
  transform: translateY(100%);
  transition: transform var(--transition-slow);
  z-index: 30;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bottom-sheet.open {
  transform: translateY(0);
}

/* Drag handle */
.bottom-sheet__handle {
  width: 36px;
  height: 4px;
  margin: 0 auto var(--space-md);
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
}

.bottom-sheet__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

/* ── 12. Tower Card ─────────────────────────────────────────── */
.tower-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-sm);
}

.tower-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background var(--transition-fast),
              transform var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.tower-card:hover,
.tower-card:active {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-active);
  transform: scale(1.03);
}

.tower-card.selected {
  border-color: var(--text-accent);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.tower-card.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Icon placeholder */
.tower-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.tower-card__name {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
}

.tower-card__cost {
  font-size: 11px;
  color: var(--income-green);
  font-weight: 700;
}

.tower-card__stats {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.3;
}

/* Tier colour accents */
.tower-card--tier1 .tower-card__icon { border: 1px solid var(--tower-tier1); }
.tower-card--tier2 .tower-card__icon { border: 1px solid var(--tower-tier2); }

/* ── 13. Packet Card ────────────────────────────────────────── */
.packet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}

.packet-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background var(--transition-fast),
              transform var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.packet-card:hover,
.packet-card:active {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-active);
  transform: scale(1.02);
}

.packet-card.selected {
  border-color: var(--btn-danger);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.packet-card__name {
  font-size: 13px;
  font-weight: 600;
}

.packet-card__damage {
  font-size: 11px;
  color: var(--btn-danger);
}

.packet-card__speed {
  font-size: 11px;
  color: var(--text-secondary);
}

.packet-card__cost {
  font-size: 12px;
  font-weight: 700;
  color: var(--income-green);
}

/* ── 14. Upgrade Path ───────────────────────────────────────── */
.upgrade-path {
  display: flex;
  gap: var(--space-sm);
}

.upgrade-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background var(--transition-fast),
              transform var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.upgrade-option:hover,
.upgrade-option:active {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-active);
  transform: scale(1.02);
}

.upgrade-option.selected {
  border-color: var(--text-accent);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.upgrade-option__direction {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 700;
}

.upgrade-option__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.upgrade-option__effect {
  font-size: 11px;
  color: var(--text-highlight);
}

.upgrade-option__cost {
  font-size: 12px;
  font-weight: 700;
  color: var(--income-green);
}

/* ── 15. Pad Highlight ──────────────────────────────────────── */
/* Applied via JS when a build pad on the canvas is selected.
   The glow is rendered on an overlay div positioned over the pad. */
.pad-highlight {
  position: absolute;
  border: 2px solid var(--text-accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4),
              inset 0 0 8px rgba(56, 189, 248, 0.15);
  pointer-events: none;
  animation: padGlow 1.5s ease-in-out infinite;
  z-index: 15;
}

@keyframes padGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(56, 189, 248, 0.4),
                         inset 0 0 8px rgba(56, 189, 248, 0.15); }
  50%       { box-shadow: 0 0 24px rgba(56, 189, 248, 0.6),
                         inset 0 0 12px rgba(56, 189, 248, 0.25); }
}

/* ── 16. Result Screen ──────────────────────────────────────── */
.screen--result {
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  text-align: center;
}

.result-title {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: -1px;
  animation: fadeIn 0.6s ease-out both;
}

.result-title--victory {
  background: linear-gradient(135deg, var(--btn-success), var(--income-green));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-title--defeat {
  background: linear-gradient(135deg, var(--btn-danger), #f97316);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-stats {
  width: 100%;
  max-width: 320px;
  animation: slideUp 0.6s ease-out 0.2s both;
}

.result-stats table {
  width: 100%;
  border-collapse: collapse;
}

.result-stats th,
.result-stats td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-size: 13px;
}

.result-stats th {
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-glass);
}

.result-stats td {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* ── 17. Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4),
                         var(--shadow-glow); }
  50%       { box-shadow: 0 0 0 12px rgba(56, 189, 248, 0),
                         0 0 40px rgba(56, 189, 248, 0.25); }
}

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

/* Utility animation classes */
.anim-fade-in   { animation: fadeIn   var(--transition-mid) ease-out both; }
.anim-slide-up  { animation: slideUp  var(--transition-mid) ease-out both; }
.anim-pulse     { animation: pulse    2.5s ease-in-out infinite; }
.anim-spin      { animation: spin     1s linear infinite; }

/* ── 18. Safe-Area Handling ─────────────────────────────────── */
/* Extra helpers for notched iPhones — use these on fixed/sticky
   elements that hug the edges. */
.safe-top    { padding-top:    calc(var(--space-sm) + env(safe-area-inset-top,    var(--sat))); }
.safe-bottom { padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, var(--sab))); }
.safe-left   { padding-left:   calc(var(--space-sm) + env(safe-area-inset-left,   var(--sal))); }
.safe-right  { padding-right:  calc(var(--space-sm) + env(safe-area-inset-right,  var(--sar))); }

.safe-x { padding-left:  calc(var(--space-sm) + env(safe-area-inset-left,  var(--sal)));
          padding-right: calc(var(--space-sm) + env(safe-area-inset-right, var(--sar))); }

.safe-y { padding-top:    calc(var(--space-sm) + env(safe-area-inset-top,    var(--sat)));
          padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, var(--sab))); }

/* ── 19. Touch-Friendly Helpers ─────────────────────────────── */
/* Ensure interactive elements meet the 44×44 minimum tap area */
.tap-target {
  min-height: 44px;
  min-width:  44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── 20. Utility Classes ────────────────────────────────────── */
.text-accent     { color: var(--text-accent); }
.text-highlight  { color: var(--text-highlight); }
.text-secondary  { color: var(--text-secondary); }
.text-success    { color: var(--btn-success); }
.text-danger     { color: var(--btn-danger); }

.font-mono       { font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono',
                            'Cascadia Code', monospace; }
.font-tabular    { font-variant-numeric: tabular-nums; }

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-xs   { gap: var(--space-xs); }
.gap-sm   { gap: var(--space-sm); }
.gap-md   { gap: var(--space-md); }
.gap-lg   { gap: var(--space-lg); }

.w-full   { width: 100%; }
.h-full   { height: 100%; }

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; overscroll-behavior: contain; }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

/* ── 21. Small-Phone Media Query ────────────────────────────── */
@media (max-width: 380px) {
  :root {
    --space-md: 12px;
    --space-lg: 18px;
    --space-xl: 24px;
  }

  body {
    font-size: 13px;
  }

  .glass-panel {
    padding: var(--space-sm);
    border-radius: var(--radius-md);
  }

  .glass-button {
    padding: 8px 16px;
    font-size: 13px;
  }

  .glass-button--lg {
    padding: 12px 24px;
    font-size: 16px;
  }

  .screen--lobby .lobby-title {
    font-size: 26px;
  }

  .screen--lobby .play-btn {
    width: 130px;
    height: 130px;
    font-size: 18px;
  }

  .tower-grid {
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  }

  .packet-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .hud .glass-panel {
    padding: var(--space-xs) var(--space-sm);
  }

  .stat-pill {
    font-size: 12px;
  }

  .result-title {
    font-size: 32px;
  }

  .bottom-sheet {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-xs) var(--space-sm) var(--space-sm);
  }
}


/* Current HTML Compatibility Layer */
.screen--active,
.screen.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

#screen-lobby,
#screen-queue,
#screen-result {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 24px;
  gap: 14px;
}

#screen-lobby {
  max-width: 560px;
  margin: 0 auto;
}

.lobby-header,
.queue-content,
.result-content,
.spinner-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.lobby-title {
  font-size: clamp(30px, 7vw, 48px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 900;
  background: linear-gradient(135deg, var(--text-accent), var(--text-highlight));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lobby-subtitle,
.queue-title,
.result-subtitle,
.hint-text {
  color: var(--text-secondary);
}

.lobby-subtitle,
.result-subtitle {
  font-size: 14px;
  line-height: 1.35;
  max-width: 36ch;
}

.lobby-info {
  width: min(100%, 420px);
  padding: 16px 18px;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.btn--primary {
  color: #fff;
  background: var(--btn-primary);
}

.btn--ghost {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
}

#screen-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.spinner-logo {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text-highlight);
}

.spinner-ring,
.queue-spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--text-accent);
  animation: spin 0.9s linear infinite;
}

#screen-game,
.screen--game {
  position: relative;
  overflow: hidden;
}

.battlefield-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
}

.hud,
#hud-resources,
.action-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  z-index: 20;
}

.hud {
  top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  min-width: 0;
}

.hud-group--left,
.hud-group--right { flex: 1 1 0; }
.hud-group--center { flex: 0 0 auto; gap: 8px; }

.hud-hp,
.hud-stat,
.hud-resource {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-label,
.hud-stat__label,
.hud-resource__label {
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.hud-stat,
.hud-resource {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(10, 14, 23, 0.54);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.hud-stat__value,
.hud-resource__value,
.hp-text {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
}

#hud-resources {
  top: 76px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.action-bar {
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.action-btn {
  pointer-events: auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 96px;
  min-height: 54px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: #fff;
}

.action-btn__label {
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateY(105%);
  z-index: 30;
  max-height: 72vh;
  overflow: auto;
}

.bottom-sheet.open { transform: translateY(0); }

.bottom-sheet__content {
  display: grid;
  gap: 10px;
}

.stats-list {
  display: grid;
  gap: 10px;
}

.stats-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-item dt { color: var(--text-secondary); font-size: 12px; }
.stats-item dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .hud { left: 8px; right: 8px; gap: 8px; }
  .action-bar { left: 8px; right: 8px; gap: 8px; }
  .action-btn { width: 84px; min-height: 52px; padding: 8px; }
}

