/* ===================================================
   FORMULA ARENA — Design System v2.0
   Premium Cyberpunk UI/UX Overhaul
   =================================================== */

/* ——— CSS Custom Properties ——— */
:root {
  /* Deep space palette */
  --bg-deep: #03040a;
  --bg-panel: rgba(8, 11, 22, 0.80);
  --bg-card: rgba(10, 14, 28, 0.72);
  --bg-input: rgba(4, 6, 14, 0.85);
  --bg-highlight: rgba(0, 240, 255, 0.04);

  /* Neon accent palette */
  --neon-cyan: #00f0ff;
  --neon-pink: #ff2d78;
  --neon-green: #00ff88;
  --neon-gold: #ffc140;
  --neon-purple: #9d00ff;

  /* Border strokes */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-neon: rgba(0, 240, 255, 0.18);
  --border-active: rgba(0, 240, 255, 0.55);

  /* Text */
  --text-primary: #eef2ff;
  --text-secondary: #7888a8;
  --text-dim: rgba(255, 255, 255, 0.3);

  /* Fonts */
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Transitions */
  --t-fast: 0.15s var(--ease-in-out);
  --t-mid: 0.28s var(--ease-out);
  --t-slow: 0.45s var(--ease-out);
}

/* ——— Reset ——— */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-main);
  overflow: hidden;
  height: 100%;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* ——— Animated Background ——— */
.stars-bg {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(rgba(255, 255, 255, .25) 1px, transparent 30px),
    radial-gradient(rgba(255, 255, 255, .15) 1px, transparent 20px);
  background-size: 500px 500px, 300px 300px;
  background-position: 0 0, 50px 80px;
  opacity: 0.07;
  z-index: -3;
}

.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.11;
  z-index: -2;
  animation: float-orb 22s infinite alternate ease-in-out;
}

#orb-1 {
  width: 500px;
  height: 500px;
  background: var(--neon-cyan);
  top: -12%;
  left: -12%;
}

#orb-2 {
  width: 550px;
  height: 550px;
  background: var(--neon-purple);
  bottom: -15%;
  right: -12%;
  animation-delay: -8s;
}

@keyframes float-orb {
  0% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(60px, 80px) scale(1.12);
  }

  100% {
    transform: translate(-30px, -50px) scale(0.9);
  }
}

/* Floating math symbols background */
body::before {
  content: '';
  position: fixed;
  top: -420px;
  left: -420px;
  right: 0;
  bottom: 0;
  z-index: -3;
  pointer-events: none;
  background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='420'><g font-family='Courier New,monospace' fill='%2300f0ff'><text x='28' y='60' font-size='34' fill-opacity='0.07'>∑</text><text x='300' y='90' font-size='26' fill-opacity='0.06'>π</text><text x='180' y='150' font-size='22' fill-opacity='0.07'>f(x)</text><text x='60' y='250' font-size='30' fill-opacity='0.05' fill='%239d00ff'>∫</text><text x='320' y='230' font-size='20' fill-opacity='0.06'>√x</text><text x='120' y='360' font-size='24' fill-opacity='0.06' fill='%239d00ff'>Δy</text><text x='260' y='330' font-size='18' fill-opacity='0.07'>sin(x)</text><text x='30' y='160' font-size='18' fill-opacity='0.05'>e^x</text><text x='350' y='390' font-size='28' fill-opacity='0.05'>∞</text><text x='210' y='40' font-size='16' fill-opacity='0.05' fill='%23ffc140'>θ</text><text x='330' y='150' font-size='16' fill-opacity='0.05' fill='%23ffc140'>λ</text><text x='90' y='320' font-size='15' fill-opacity='0.06'>x²</text></g><path d='M0 210 Q 52 150, 105 210 T 210 210 T 315 210 T 420 210' fill='none' stroke='%2300f0ff' stroke-opacity='0.05' stroke-width='1.5'/><path d='M0 300 C 105 230, 315 370, 420 300' fill='none' stroke='%239d00ff' stroke-opacity='0.05' stroke-width='1.5' stroke-dasharray='6 5'/></svg>");
  background-size: 420px 420px;
  animation: math-drift 140s linear infinite;
}

@keyframes math-drift {
  to {
    transform: translate(420px, 420px);
  }
}

@media (prefers-reduced-motion: reduce) {

  body::before,
  .glow-orb {
    animation: none;
  }
}

/* ——— Screen Layer Management ——— */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transform: translateY(14px);
  transition: opacity var(--t-slow), transform var(--t-slow);
}

.screen.active {
  position: relative;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ——— Glassmorphism Surface ——— */
.glassmorphism {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-neon);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  border-radius: 16px;
}

/* ——— Typography ——— */
h1,
h2,
h3 {
  font-weight: 800;
  letter-spacing: 0.4px;
}

.accent-text {
  color: var(--neon-cyan);
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.45);
}

.text-glow {
  text-shadow: 0 0 8px currentColor;
}

.warning-glow-text {
  color: var(--neon-pink);
  text-shadow: 0 0 16px rgba(255, 45, 120, 0.55);
}

/* ======================================================
   MAIN MENU SCREEN
   ====================================================== */
#menu-screen {
  max-width: 480px;
  justify-content: center;
  align-self: center;
  height: auto;
  max-height: 100%;
  padding-top: 60px;
  /* clear fixed profile card */
}

/* Profile card — fixed in viewport top-right corner */
.menu-profile-card {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 50px;
  /* pill shape */
  border: 1px solid var(--border-neon);
  background: rgba(8, 11, 22, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  z-index: 50;
  transition: all var(--t-fast);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

.menu-profile-card:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25), 0 4px 16px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.profile-avatar-mini-container {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--neon-cyan);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.profile-avatar-mini {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-info-mini {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.profile-info-mini .username-text {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-info-mini .level-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--neon-cyan);
  font-weight: 800;
}

/* Logo */
.logo-container {
  text-align: center;
  margin-bottom: 36px;
}

.game-logo {
  font-size: 2.9rem;
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
  font-family: var(--font-main);
  font-weight: 800;
}

.tagline {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-top: 6px;
  letter-spacing: 1.5px;
}

/* PRE-MATCH TACTICS card */
.profile-section {
  padding: 20px 22px;
  margin-bottom: 22px;
}

.profile-section h2 {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-family: var(--font-mono);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.input-row-flex {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
}

.flex-1 {
  flex: 1;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.input-group label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.input-group input {
  background: var(--bg-input);
  border: 1px solid var(--border-neon);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.input-group input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

/* Dropdown selects */
.item-dropdown {
  background: var(--bg-input);
  border: 1px solid var(--border-neon);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.92rem;
  outline: none;
  cursor: pointer;
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='8'><path d='M0 0 L7 8 L14 0' fill='none' stroke='%237888a8' stroke-width='2'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.item-dropdown:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.item-dropdown option {
  background: #0d1020;
  color: var(--text-primary);
}

/* Equipped cosmetics tags */
.equipped-cosmetics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.cosmetic-tag {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: rgba(0, 240, 255, 0.07);
  border: 1px solid rgba(0, 240, 255, 0.18);
  border-radius: 20px;
  padding: 3px 10px;
  color: rgba(0, 240, 255, 0.8);
}

/* ——— Buttons ——— */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 13px 20px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
  transition: all var(--t-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
}

/* Shimmer sweep on hover */
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 220%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.07), transparent);
  transform: skewX(-22deg);
  transition: 0.6s var(--ease-out);
  pointer-events: none;
}

.btn:hover::after {
  left: 100%;
}

.btn:active {
  transform: scale(0.97);
}

/* Primary (Quick Match) */
.primary-glowing {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.9), rgba(0, 150, 255, 0.85));
  color: #001020;
  font-weight: 800;
  border: none;
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.28), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.primary-glowing:hover {
  box-shadow: 0 0 34px rgba(0, 240, 255, 0.55), 0 6px 18px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.btn-subtext {
  font-size: 0.67rem;
  opacity: 0.72;
  font-weight: 400;
  margin-top: 2px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

/* Secondary */
.btn.secondary {
  border: 1px solid var(--border-neon);
}

.btn.secondary:hover {
  background: var(--bg-highlight);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.12);
}

/* Action green (LOCK FORMULA) */
.action-glowing {
  background: linear-gradient(135deg, var(--neon-green), #00aa55);
  color: #001a0a;
  font-weight: 800;
  border: none;
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.28);
  padding: 10px 16px;
  flex-shrink: 0;
  border-radius: 10px;
  font-size: 0.9rem;
}

.action-glowing:hover {
  box-shadow: 0 0 26px rgba(0, 255, 136, 0.5);
  transform: translateY(-1px);
}

/* 2-column sub-row */
.menu-sub-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.menu-sub-row.font-sm .btn {
  padding: 10px 5px !important;
  font-size: 0.78rem !important;
  border-radius: 10px !important;
}

/* Room action row */
.room-action-group {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 12px;
  margin-top: 4px;
}

.join-room-input-box {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-neon);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  transition: border-color var(--t-fast);
}

.join-room-input-box:focus-within {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.join-room-input-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  width: 100%;
  padding-left: 12px;
  outline: none;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 3px;
}

.small-btn {
  padding: 6px 14px !important;
  border-radius: 9px !important;
  font-size: 0.82rem !important;
  flex-shrink: 0;
}

/* Footer credits */
.footer-credits {
  text-align: center;
  margin-top: 20px;
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

/* ======================================================
   LOBBY SCREEN
   ====================================================== */
.lobby-container {
  max-width: 500px;
  width: 100%;
  margin: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-title {
  text-align: center;
  font-size: 1.7rem;
  letter-spacing: 1.5px;
}

.lobby-room-id {
  text-align: center;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.lobby-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-active), transparent);
  opacity: 0.6;
}

.lobby-players-list {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border-subtle);
  max-height: 240px;
  overflow-y: auto;
}

.lobby-players-list h3 {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.lobby-players-list ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.lobby-players-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  font-size: 0.88rem;
  border-left: 3px solid var(--neon-cyan);
  transition: background var(--t-fast);
}

.lobby-players-list li:hover {
  background: rgba(0, 240, 255, 0.04);
}

.lobby-players-list li.is-bot {
  border-left-color: var(--neon-purple);
}

.status-badge {
  font-size: 0.66rem;
  padding: 2px 7px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.status-badge.connecting {
  background: rgba(255, 193, 64, 0.12);
  color: var(--neon-gold);
  border: 1px solid rgba(255, 193, 64, 0.2);
}

.status-badge.ready {
  background: rgba(0, 255, 136, 0.1);
  color: var(--neon-green);
  border: 1px solid rgba(0, 255, 136, 0.2);
}

.lobby-countdown-box {
  text-align: center;
  padding: 8px;
}

.lobby-countdown-box p {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.82rem;
  letter-spacing: 0.5px;
}

.countdown-val {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 800;
  color: var(--neon-pink);
  text-shadow: 0 0 20px rgba(255, 45, 120, 0.45);
}

.lobby-tip {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.55;
  text-align: center;
}

.host-controls-box {
  margin: 12px 0;
  text-align: center;
}

.start-btn {
  width: 100%;
  padding: 16px !important;
  background: linear-gradient(135deg, var(--neon-green), #00994d);
  color: #001a0a;
  font-weight: 800;
  border: none;
  box-shadow: 0 0 22px rgba(0, 255, 136, 0.3);
}

.start-btn:hover {
  box-shadow: 0 0 35px rgba(0, 255, 136, 0.6);
  transform: translateY(-2px);
}

.lobby-wait-box {
  margin: 16px 0;
  text-align: center;
}

.blink-text {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--neon-gold);
  text-shadow: 0 0 10px rgba(255, 193, 64, 0.3);
  animation: blink 1.6s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

.lobby-leave-wrapper {
  width: 100%;
  margin-top: 4px;
}

.lobby-leave-btn {
  width: 100%;
  border-color: rgba(255, 45, 120, 0.3) !important;
}

.lobby-leave-btn:hover {
  background: rgba(255, 45, 120, 0.06) !important;
  border-color: var(--neon-pink) !important;
  box-shadow: 0 0 14px rgba(255, 45, 120, 0.2) !important;
  color: var(--neon-pink) !important;
}

/* ======================================================
   GAME SCREEN LAYOUT
   ====================================================== */
#game-screen.active {
  display: grid;
}

#game-screen {
  padding: 8px;
  max-width: 1300px;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: auto;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr 270px;
  grid-template-areas:
    "header aside"
    "canvas aside"
    "footer aside";
  gap: 10px;
  overflow: hidden;
}

/* Header */
.game-header {
  grid-area: header;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 18px;
  border-radius: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(10px);
}

.header-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.header-item .label {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.header-item .value {
  font-size: 1.3rem;
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--neon-cyan);
}

.timer-item .value {
  color: var(--neon-gold);
}

.warning-glow {
  animation: pulse-glow 0.9s infinite alternate;
}

@keyframes pulse-glow {
  0% {
    text-shadow: 0 0 6px rgba(255, 193, 64, 0.3);
  }

  100% {
    text-shadow: 0 0 20px rgba(255, 193, 64, 0.9);
  }
}

/* Scoreboard Panel */
.scoreboard-panel {
  grid-area: aside;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.scoreboard-panel h3 {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.scoreboard-panel ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.scoreboard-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background var(--t-fast);
}

.scoreboard-panel li:hover {
  background: rgba(255, 255, 255, 0.04);
}

.scoreboard-panel li.dead {
  opacity: 0.38;
  text-decoration: line-through;
  border-left-color: #444 !important;
}

.scoreboard-panel .player-tag {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 5px currentColor;
}

.scoreboard-panel .score {
  font-family: var(--font-mono);
  color: var(--neon-cyan);
}

.scoreboard-panel .status {
  font-size: 0.65rem;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  font-family: var(--font-mono);
}

.grid-env-vars {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  color: var(--text-secondary);
}

/* Canvas Area */
.canvas-container {
  grid-area: canvas;
  background: rgba(3, 4, 10, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.5);
}

#game-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.canvas-scale-hint {
  position: absolute;
  bottom: 7px;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.15);
}

/* Game Controls Footer */
.game-controls {
  grid-area: footer;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.formula-inputs-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.formula-box {
  flex-grow: 1;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-neon);
  border-radius: 10px;
  padding: 5px 12px;
  gap: 8px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.formula-box:focus-within {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.formula-box label {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--neon-cyan);
  font-size: 0.88rem;
  flex-shrink: 0;
}

.formula-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  min-height: 32px;
  width: 100%;
  outline: none;
  transition: color var(--t-fast);
}

/* Firing direction button */
.dir-btn {
  flex-shrink: 0;
  padding: 9px 13px;
  font-size: 1.1rem;
  color: var(--neon-gold);
  border-color: rgba(255, 193, 64, 0.3);
}

.dir-btn:hover {
  border-color: var(--neon-gold);
  box-shadow: 0 0 12px rgba(255, 193, 64, 0.3);
}

/* ——— Virtual Keypad ——— */
.keyboard-helper {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.key-btn {
  flex-grow: 1;
  background: rgba(16, 20, 38, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.12);
  border-radius: 8px;
  padding: 8px 5px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: all 0.1s var(--ease-in-out);
  display: flex;
  align-items: center;
  justify-content: center;
}

.key-btn:hover {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--neon-cyan);
  color: #fff;
  box-shadow: 0 2px 0 rgba(0, 240, 255, 0.4), 0 0 10px rgba(0, 240, 255, 0.2);
  transform: translateY(-1px);
}

.key-btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 transparent, inset 0 1px 4px rgba(0, 0, 0, 0.6);
}

.key-btn.delete-btn {
  background: rgba(255, 45, 120, 0.07);
  border-color: rgba(255, 45, 120, 0.22);
  color: var(--neon-pink);
  box-shadow: 0 2px 0 rgba(255, 45, 120, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  flex-grow: 1.5;
}

.key-btn.delete-btn:hover {
  background: rgba(255, 45, 120, 0.14);
  border-color: var(--neon-pink);
  color: #fff;
  box-shadow: 0 2px 0 var(--neon-pink), 0 0 10px rgba(255, 45, 120, 0.25);
  transform: translateY(-1px);
}

.key-btn.delete-btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 transparent;
}

/* Header exit button */
.header-exit-btn {
  background: rgba(255, 45, 120, 0.07) !important;
  border: 1px solid rgba(255, 45, 120, 0.25) !important;
  color: var(--neon-pink) !important;
  font-family: var(--font-mono) !important;
  font-size: 0.72rem !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  cursor: pointer;
  transition: all var(--t-fast);
  text-shadow: none !important;
}

.header-exit-btn:hover {
  background: var(--neon-pink) !important;
  color: #fff !important;
  box-shadow: 0 0 12px rgba(255, 45, 120, 0.4) !important;
}

/* ======================================================
   MODAL OVERLAYS
   ====================================================== */
.modal-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(2, 3, 8, 0.78);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, backdrop-filter 0.35s ease;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 20px;
  background: rgba(8, 11, 24, 0.96);
  border: 1px solid rgba(0, 240, 255, 0.22);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  transform: scale(0.92) translateY(10px);
  transition: transform 0.35s var(--spring);
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.2) transparent;
}

.modal-card::-webkit-scrollbar {
  width: 4px;
}

.modal-card::-webkit-scrollbar-track {
  background: transparent;
}

.modal-card::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.2);
  border-radius: 2px;
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(8, 11, 24, 0.95);
  backdrop-filter: blur(8px);
  z-index: 1;
}

.modal-header h2 {
  font-size: 1.15rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.close-modal {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 1.4rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: all var(--t-fast);
}

.close-modal:hover {
  color: var(--neon-pink);
  border-color: rgba(255, 45, 120, 0.3);
  background: rgba(255, 45, 120, 0.08);
}

.modal-content {
  padding: 22px;
  overflow-y: auto;
}

/* ======================================================
   SHOP & COSMETICS
   ====================================================== */
.shop-content {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.shop-pack {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--t-fast);
}

.shop-pack:hover {
  border-color: rgba(255, 193, 64, 0.2);
}

.shop-pack h3 {
  font-size: 1rem;
  color: var(--neon-gold);
  text-shadow: 0 0 8px rgba(255, 193, 64, 0.2);
}

.shop-pack p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.cosmetics-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.cosmetic-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 9px 4px;
  text-align: center;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all var(--t-fast);
}

.cosmetic-item:hover {
  background: var(--bg-highlight);
  border-color: var(--border-neon);
}

.cosmetic-item.owned {
  border-color: var(--border-active);
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.04);
}

.cosmetic-item.equipped {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--neon-cyan);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}

.buy-pack-btn {
  margin-top: 4px;
  padding: 10px;
  font-size: 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 193, 64, 0.28);
  background: rgba(255, 193, 64, 0.05);
  color: var(--neon-gold);
  cursor: pointer;
  transition: all var(--t-fast);
  font-weight: 700;
  font-family: var(--font-main);
}

.buy-pack-btn:hover {
  background: rgba(255, 193, 64, 0.14);
  box-shadow: 0 0 14px rgba(255, 193, 64, 0.2);
  border-color: var(--neon-gold);
}

/* ======================================================
   GUIDE / TEXT CONTENT
   ====================================================== */
.text-guide {
  display: flex;
  flex-direction: column;
  gap: 14px;
  line-height: 1.65;
}

.text-guide h3 {
  font-size: 0.95rem;
  color: var(--neon-cyan);
  margin-top: 8px;
}

.text-guide p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.text-guide code {
  font-family: var(--font-mono);
  background: var(--bg-input);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--neon-pink);
  font-size: 0.82rem;
}

.formula-example {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.formula-example strong {
  font-size: 0.82rem;
  color: var(--neon-gold);
  display: block;
}

.formula-example code {
  color: var(--text-primary);
  background: transparent;
  padding: 0;
  display: block;
  font-size: 0.88rem;
}

/* ======================================================
   COOLDOWN / ELIMINATED STATE
   ====================================================== */
.text-center {
  text-align: center;
}

.danger-text {
  color: var(--neon-pink);
  font-size: 1.8rem;
  margin-bottom: 10px;
  text-shadow: 0 0 16px rgba(255, 45, 120, 0.4);
}

.eliminated-stats {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 18px;
}

.stats-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
  padding: 15px;
  border: 1px solid var(--border-subtle);
  margin-bottom: 22px;
  gap: 12px;
}

.stat-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--neon-cyan);
}

.cooldown-box {
  padding: 10px;
  margin-bottom: 24px;
}

.cooldown-box p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.ad-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ======================================================
   LEADERBOARD / GAME OVER
   ====================================================== */
.victory-declaration {
  font-size: 1.1rem;
  margin-bottom: 18px;
  line-height: 1.5;
}

.victory-declaration strong {
  color: var(--neon-green);
  text-shadow: 0 0 12px rgba(0, 255, 136, 0.3);
}

.leaderboard-box {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  padding: 14px;
  margin-bottom: 22px;
}

.leaderboard-box h3 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

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

.leaderboard-table th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 7px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table td {
  padding: 9px 7px;
  font-size: 0.82rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.leaderboard-table tr:first-child td {
  color: var(--neon-gold);
  font-weight: 700;
}

.game-over-actions {
  display: flex;
  justify-content: center;
}

/* ======================================================
   AD / IAP SCREENS
   ====================================================== */
.ad-modal {
  background: rgba(4, 5, 12, 0.98);
  padding: 0;
}

.ad-player-box {
  width: 100vw;
  height: 100vh;
  max-width: 540px;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: none;
  background: transparent;
}

.ad-header {
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ad-tag {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.ad-timer {
  background: var(--neon-pink);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 12px rgba(255, 45, 120, 0.4);
}

.ad-body {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.video-placeholder {
  width: 100%;
  height: 290px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.01);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 28px;
}

.video-placeholder h3 {
  font-size: 1.1rem;
  color: var(--neon-cyan);
}

.video-placeholder p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-width: 300px;
}

.ad-skin-preview {
  position: relative;
  width: 80%;
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 14px;
}

.trail-line-glow {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--neon-cyan), transparent);
  box-shadow: 0 0 8px var(--neon-cyan);
  animation: move-trail 1.8s infinite linear;
}

@keyframes move-trail {
  0% {
    left: -10%;
  }

  100% {
    left: 110%;
  }
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.ad-footer {
  padding: 14px 20px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
}

/* Checkout / IAP */
.checkout-box {
  max-width: 400px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.iap-pack-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--neon-cyan);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.iap-pack-price {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--neon-gold);
}

.iap-payment-info {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
}

.payment-method {
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: 600;
}

.iap-notice {
  font-size: 0.68rem;
  color: var(--neon-pink);
  margin-top: 8px;
}

.iap-actions {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

/* ======================================================
   MATCHMAKING SCREEN
   ====================================================== */
.matchmaking-container {
  max-width: 460px;
  width: 100%;
  margin: auto;
  padding: 40px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.radar-container {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px solid rgba(0, 240, 255, 0.15);
  background: radial-gradient(circle, rgba(0, 240, 255, 0.03) 0%, rgba(0, 0, 0, 0.85) 100%);
  box-shadow: inset 0 0 24px rgba(0, 240, 255, 0.12), 0 0 30px rgba(0, 240, 255, 0.06);
  overflow: hidden;
  margin: 14px 0;
}

.radar-sweep {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: conic-gradient(from 0deg at 0 0, rgba(0, 240, 255, 0.3) 0deg, rgba(0, 240, 255, 0) 90deg);
  transform-origin: top left;
  animation: radar-sweep-rotate 3s infinite linear;
}

@keyframes radar-sweep-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.radar-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.2);
  animation: radar-pulse-expand 2s infinite ease-out;
  opacity: 0;
}

@keyframes radar-pulse-expand {
  0% {
    transform: scale(0.1);
    opacity: 0;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.radar-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: var(--neon-cyan);
  border-radius: 50%;
  filter: blur(26px);
  opacity: 0.18;
}

.radar-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 10px var(--neon-green);
  animation: radar-dot-fade 1.5s infinite alternate;
}

@keyframes radar-dot-fade {
  0% {
    opacity: 0.2;
    transform: scale(0.8);
  }

  100% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.matchmaking-status {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.matchmaking-timer,
.matchmaking-count {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.matchmaking-timer span,
.matchmaking-count span {
  color: var(--neon-gold);
  font-weight: 700;
}

.cancel-matchmaking-btn {
  width: 100%;
  max-width: 240px;
  border-color: rgba(255, 45, 120, 0.3) !important;
}

.cancel-matchmaking-btn:hover {
  background: rgba(255, 45, 120, 0.06) !important;
  border-color: var(--neon-pink) !important;
  box-shadow: 0 0 14px rgba(255, 45, 120, 0.2) !important;
  color: var(--neon-pink) !important;
}

/* ======================================================
   PROFILE MODAL
   ====================================================== */
.profile-modal-content {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.profile-header-edit {
  display: flex;
  gap: 22px;
  align-items: flex-start;
}

.avatar-select-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.profile-avatar-large {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2.5px solid var(--neon-cyan);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.3);
  background: rgba(0, 0, 0, 0.5);
  object-fit: cover;
  cursor: pointer;
  transition: all var(--t-fast);
}

.profile-avatar-large:hover {
  transform: scale(1.06);
  border-color: #fff;
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.5);
}

.sub-label {
  font-size: 0.62rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.avatar-grid {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border-neon);
}

.avatar-grid.active {
  display: grid;
}

.avatar-item {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  overflow: hidden;
  transition: all var(--t-fast);
}

.avatar-item:hover,
.avatar-item.selected {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
  transform: scale(1.12);
}

.avatar-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-edit-fields {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.username-save-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: stretch;
}

.username-save-row input {
  flex-grow: 1;
}

.username-save-row .btn {
  flex-shrink: 0;
  margin: 0;
  padding: 0 16px !important;
  font-size: 0.85rem;
}


.level-exp-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
}

.level-display-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lvl-label {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.lvl-value {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.exp-bar-wrapper {
  height: 7px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.exp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple));
  border-radius: 4px;
  transition: width 0.6s var(--ease-out);
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}

.exp-text {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-secondary);
  text-align: right;
}

.profile-stats-card {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 15px;
}

.profile-stats-card h3 {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color var(--t-fast);
}

.stat-item:hover {
  border-color: var(--border-neon);
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.stat-item:nth-child(2) .stat-num {
  color: var(--neon-gold);
}

.stat-item:nth-child(3) .stat-num {
  color: var(--neon-pink);
}

.stat-name {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.5px;
}

/* ======================================================
   INVENTORY MODAL
   ====================================================== */
.inventory-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.inventory-section h3 {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

/* ======================================================
   UTILITY CLASSES
   ====================================================== */
.force-modal {
  z-index: 110;
}

/* ======================================================
   RESPONSIVE — TABLET / MOBILE
   ====================================================== */
@media (max-width: 900px) {
  #game-screen {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "canvas"
      "footer";
    padding: 6px;
    gap: 7px;
    overflow-y: auto;
  }

  .canvas-container {
    min-height: 200px;
  }

  .scoreboard-panel {
    display: none;
  }
}

@media (max-width: 600px) {
  body {
    align-items: stretch;
  }

  .screen {
    padding: 12px;
  }

  #menu-screen {
    max-width: 100%;
    align-self: stretch;
    height: 100%;
    justify-content: flex-start;
    padding-bottom: 24px;
  }

  .logo-container {
    margin-bottom: 20px;
    padding-top: 18px;
  }

  .game-logo {
    font-size: 2rem;
  }

  .formula-inputs-row {
    gap: 5px;
  }

  .formula-box {
    padding: 4px 10px;
  }

  .action-glowing {
    padding: 8px 11px;
    font-size: 0.82rem;
  }

  .keyboard-helper {
    justify-content: space-between;
  }

  .key-btn {
    padding: 6px 3px;
    font-size: 0.72rem;
  }

  .input-row-flex {
    flex-direction: column;
    gap: 11px;
  }

  .room-action-group {
    grid-template-columns: 1fr;
  }

  .modal-card {
    max-height: 92vh;
  }

  .profile-header-edit {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .menu-sub-row.font-sm {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

/* ======================================================
   OUT GAME CONFIRMATION MODAL
   ====================================================== */
.out-game-confirm-card {
  max-width: 400px;
  padding: 0;
  overflow: hidden;
  border-color: rgba(255, 45, 120, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 45, 120, 0.15),
    0 24px 60px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Animated top danger stripe */
.out-game-confirm-card::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg,
      transparent 0%,
      var(--neon-pink) 30%,
      rgba(255, 45, 120, 0.6) 70%,
      transparent 100%);
  animation: danger-stripe 2s infinite linear;
  background-size: 200% 100%;
}

@keyframes danger-stripe {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

/* Icon + title header */
.out-game-icon-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 26px 0;
}

.out-game-icon-ring {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 45, 120, 0.06);
  border: 1.5px solid rgba(255, 45, 120, 0.25);
  box-shadow: 0 0 20px rgba(255, 45, 120, 0.15), inset 0 0 12px rgba(255, 45, 120, 0.08);
  animation: ring-pulse 2.5s infinite ease-in-out;
}

@keyframes ring-pulse {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(255, 45, 120, 0.15), inset 0 0 12px rgba(255, 45, 120, 0.08);
  }

  50% {
    box-shadow: 0 0 30px rgba(255, 45, 120, 0.3), inset 0 0 18px rgba(255, 45, 120, 0.12);
  }
}

.out-game-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--neon-pink);
  letter-spacing: 1.5px;
  text-shadow: 0 0 16px rgba(255, 45, 120, 0.4);
  line-height: 1.2;
}

.out-game-subtitle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 1px;
}

/* Body section */
.out-game-body {
  padding: 20px 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Warning list */
.out-game-warning-box {
  background: rgba(255, 45, 120, 0.04);
  border: 1px solid rgba(255, 45, 120, 0.14);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.out-game-warning-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.out-game-warn-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.out-game-warning-row strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Action buttons */
.out-game-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Forfeit (danger) button */
.out-game-confirm-btn {
  background: linear-gradient(135deg, #ff2d78, #cc1155);
  color: #fff;
  border: none;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 0 20px rgba(255, 45, 120, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.15s var(--ease-in-out);
}

.out-game-confirm-btn:hover {
  background: linear-gradient(135deg, #ff4090, #dd2266);
  box-shadow: 0 0 30px rgba(255, 45, 120, 0.55), 0 6px 18px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.out-game-confirm-btn:active {
  transform: scale(0.97);
}

/* Stay (safe) button */
.out-game-cancel-btn {
  border-color: rgba(0, 240, 255, 0.25) !important;
  color: var(--neon-cyan) !important;
}

.out-game-cancel-btn:hover {
  background: rgba(0, 240, 255, 0.06) !important;
  border-color: var(--neon-cyan) !important;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.15) !important;
}

/* ——— AdSense Sidebar Banners ——— */
.menu-ad-sidebar {
  position: fixed;
  top: 52%;
  transform: translateY(-50%);
  width: 180px;
  height: 640px;
  background: rgba(4, 6, 14, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px dashed var(--border-neon);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.04);
  z-index: 10;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast);
}

.menu-ad-sidebar.visible {
  opacity: 1;
  pointer-events: auto;
}

.left-ad {
  left: calc(50% - 240px - 210px);
}

.right-ad {
  right: calc(50% - 240px - 210px);
}

.ad-container-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  gap: 8px;
}

.ad-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  opacity: 0.7;
  text-transform: uppercase;
}

.ad-placeholder-bg {
  position: absolute;
  top: 30px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.05);
  border-radius: 8px;
  z-index: -1;
  color: var(--neon-cyan);
  opacity: 0.35;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-align: center;
  gap: 12px;
  padding: 20px;
}

.ad-placeholder-bg svg {
  animation: ad-scan 3s ease-in-out infinite;
}

@keyframes ad-scan {
  0% { transform: scale(0.95); opacity: 0.3; }
  50% { transform: scale(1.05); opacity: 0.7; filter: drop-shadow(0 0 8px var(--neon-cyan)); }
  100% { transform: scale(0.95); opacity: 0.3; }
}

/* Hide sidebars on screens that are too narrow */
@media (max-width: 960px) {
  .menu-ad-sidebar {
    display: none !important;
  }
}