@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;500;700&display=swap');

/* ── Reset & body ─────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0f;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

canvas {
  display: block;
  touch-action: none;
}

/* ── HUD (scores) ─────────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 24px;
  z-index: 20;
  font-family: 'Orbitron', monospace;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#hud.visible { opacity: 1; }

.connection-status {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}
.connection-status.visible { display: inline-flex; }

.connection-status .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5a5a66;
  box-shadow: 0 0 8px rgba(90,90,102,0.5);
}
.connection-status .dot.green {
  background: #33ff99;
  box-shadow: 0 0 10px rgba(51,255,153,0.65);
}
.connection-status .dot.yellow {
  background: #ffc832;
  box-shadow: 0 0 10px rgba(255,200,50,0.65);
}
.connection-status .dot.red {
  background: #ff4444;
  box-shadow: 0 0 10px rgba(255,68,68,0.65);
}
.connection-status .dot.offline {
  background: #5a5a66;
  box-shadow: none;
}

#network-warning {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  letter-spacing: 0.5px;
  background: rgba(255,68,68,0.12);
  border: 1px solid rgba(255,68,68,0.45);
  color: #ff9f9f;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#network-warning.visible { opacity: 1; }

.score-box {
  text-align: center;
  padding: 6px 16px;
  border-radius: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.1s;
}
.score-box.flash { transform: scale(1.15); }

.score-box .label {
  font-size: 10px;
  letter-spacing: 2px;
  opacity: 0.5;
  text-transform: uppercase;
}
.score-box .value {
  font-size: 26px;
  font-weight: 900;
}

.score-box.p0 .value { color: #ff3366; }
.score-box.p1 .value { color: #33ff99; }
.score-box.p2 .value { color: #3399ff; }

.score-box.eliminated { opacity: 0.3; }
.score-box.eliminated .value { text-decoration: line-through; }

/* ── Scoreboard (goals panel) ────────────────────────────────────── */
#scoreboard {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px 16px;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 100px;
}
#scoreboard.visible { opacity: 1; }

.sb-title {
  font: bold 11px Orbitron, monospace;
  color: rgba(255,255,255,0.4);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.sb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sb-row:last-child { border-bottom: none; }

.sb-name {
  font: bold 13px Orbitron, monospace;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-row.p0 .sb-name { color: #ff3366; }
.sb-row.p1 .sb-name { color: #33ff99; }
.sb-row.p2 .sb-name { color: #3399ff; }

.sb-goals {
  font: bold 22px Orbitron, monospace;
  color: #fff;
  margin-left: 16px;
  min-width: 24px;
  text-align: right;
}

/* ── Menu overlay ─────────────────────────────────────────────────── */
#menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  pointer-events: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.menu-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: auto;
  animation: fadeIn 0.2s ease-out;
  margin: auto 0;
  padding: 20px 16px;
  max-width: 100vw;
}
.menu-screen.active { display: flex; }

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

/* ── Title screen ─────────────────────────────────────────────────── */
#screen-title .logo {
  font-family: 'Orbitron', monospace;
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #ff3366, #3399ff, #33ff99);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
#screen-title .subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 40px;
}
#screen-title .start-hint {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.version-tag {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.25);
}

#debug-bot-controls {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.debug-label {
  font-size: 10px;
  color: rgba(255,200,50,0.5);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.debug-bot-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.menu-btn-debug {
  font-size: 11px;
  padding: 5px 12px;
  background: rgba(255,200,50,0.1);
  border-color: rgba(255,200,50,0.3);
}

.debug-bot-status {
  font-size: 11px;
  color: rgba(255,200,50,0.6);
  margin-top: 6px;
  margin-top: 24px;
}

/* ── Heading style shared across screens ─────────────────────────── */
#screen-difficulty h2,
#screen-mode h2,
#screen-online h2,
#screen-online-wait h2,
#screen-settings h2 {
  font-family: 'Orbitron', monospace;
  font-size: 18px;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 28px;
}

/* ── Menu buttons ────────────────────────────────────────────────── */
.menu-btn {
  display: block;
  width: 240px;
  padding: 12px 0;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 2px solid rgba(51,153,255,0.85);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #67b8ff;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.menu-btn:active { transform: scale(0.96); }
.menu-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}
.menu-btn-secondary {
  border-color: rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.85);
}
.menu-btn-quit {
  border-color: rgba(255,68,68,0.35);
  color: rgba(255,68,68,0.6);
  margin-top: 12px;
  font-size: 12px;
}

/* ── Keyboard menu focus ────────────────────────────────────────── */
:where(#menu-overlay button, #menu-overlay input, .pest-gallery-overlay button):focus-visible,
:where(#menu-overlay button, #menu-overlay input, .pest-gallery-overlay button).menu-nav-focused {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.16),
    0 0 0 4px rgba(103,184,255,0.2),
    0 0 24px rgba(103,184,255,0.34);
}

:where(#menu-overlay button, .pest-gallery-overlay button):focus-visible,
:where(#menu-overlay button, .pest-gallery-overlay button).menu-nav-focused {
  transform: translateY(-1px);
}

:where(#menu-overlay input):focus-visible,
:where(#menu-overlay input).menu-nav-focused {
  border-color: rgba(103,184,255,0.78);
  background: rgba(0,0,0,0.62);
}

.pest-mascot.menu-nav-focused .pest-mascot-img,
.pest-mascot:focus-visible .pest-mascot-img {
  border-color: rgba(103,184,255,0.72);
  box-shadow: 0 0 18px rgba(103,184,255,0.24);
}

/* ── Difficulty buttons ──────────────────────────────────────────── */
/* ── Game setup columns ──────────────────────────────────────────── */
.setup-columns {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  margin: 8px auto 16px;
  max-width: 900px;
  padding: 0 12px;
}

.setup-col {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.setup-col-label {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 10px;
  text-align: center;
}

.setup-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.setup-actions-top {
  display: none;
  margin-top: 0;
  margin-bottom: 4px;
}

.menu-btn-start {
  font-size: 14px;
  padding: 10px 36px;
  letter-spacing: 2px;
  border-color: #33ff99;
  color: #33ff99;
  background: rgba(51,255,153,0.08);
  width: auto;
}

.menu-btn-start:hover {
  background: rgba(51,255,153,0.15);
}

.diff-btn {
  display: block;
  width: 100%;
  padding: 10px 0;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 2px solid;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.diff-btn:active { transform: scale(0.96); }

.diff-btn.easy   { border-color: rgba(51,255,153,0.4); color: #33ff99; }
.diff-btn.medium { border-color: rgba(255,200,50,0.4); color: #ffc832; }
.diff-btn.hard   { border-color: rgba(255,51,102,0.4); color: #ff3366; }

.diff-btn.active.easy   { border-color: #33ff99; background: rgba(51,255,153,0.12); }
.diff-btn.active.medium { border-color: #ffc832; background: rgba(255,200,50,0.12); }
.diff-btn.active.hard   { border-color: #ff3366; background: rgba(255,51,102,0.12); }

.diff-btn .desc {
  display: block;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.5;
  letter-spacing: 0;
  margin-top: 2px;
}

/* ── Gameplay panel (right column) ─────────────────────────────── */
.gameplay-panel {
  border: 1px solid rgba(100,200,255,0.2);
  border-radius: 8px;
  background: rgba(100,200,255,0.04);
  padding: 10px 12px;
  width: 100%;
}

/* ── Online form ─────────────────────────────────────────────────── */
.online-form {
  width: min(88vw, 260px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.online-form label {
  margin: 4px 0 6px;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.5);
  text-align: left;
}

.online-form input {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  text-transform: uppercase;
}

.online-form input::placeholder {
  color: rgba(255,255,255,0.35);
  text-transform: none;
}

.status-text {
  min-height: 18px;
  margin-top: 8px;
  color: rgba(255,255,255,0.65);
  font-size: 14px;
}

/* ── Waiting room ────────────────────────────────────────────────── */
.room-code {
  font-family: 'Orbitron', monospace;
  font-size: 18px;
  letter-spacing: 3px;
  margin-bottom: 2px;
  color: #67b8ff;
  cursor: pointer;
  transition: color 0.15s;
}
.room-code:hover { color: #99d1ff; }

.room-code-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-bottom: 8px;
}

.menu-btn-invite {
  font-size: 12px;
  padding: 6px 16px;
  margin-bottom: 10px;
  background: rgba(103,184,255,0.15);
  border-color: rgba(103,184,255,0.4);
}

.wait-player-list {
  margin: 0 0 10px;
  padding: 10px 14px;
  width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(0,0,0,0.35);
  font-size: 14px;
  line-height: 1.8;
  text-align: left;
}

.wait-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ai-pick-label {
  font-size: 0.75rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.ai-pick-btns {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.btn-ai-diff {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
  padding: 6px 12px;
  min-width: 0;
  width: auto;
}
.btn-ai-diff.active {
  border-color: #33ff99;
  color: #33ff99;
  background: rgba(51,255,153,0.1);
}

/* ── Pest panel (grouped border) ───────────────────────────────── */
.pest-panel {
  border: 1px solid rgba(68,255,136,0.25);
  border-radius: 8px;
  padding: 10px 12px 8px;
  margin: 0;
  background: rgba(68,255,136,0.03);
  width: 100%;
}

/* ── Pest presets ──────────────────────────────────────────────── */
.pest-presets {
  margin: 0 0 10px;
  text-align: center;
}

.preset-btn {
  padding: 6px 8px;
  border: none;
  background: rgba(0,0,0,0.45);
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  border-right: 1px solid rgba(68,255,136,0.15);
}
.preset-btn:last-child { border-right: none; }

.preset-btn:hover {
  background: rgba(68,255,136,0.08);
  color: rgba(255,255,255,0.7);
}

.preset-btn.active {
  background: rgba(68,255,136,0.18);
  color: #44ff88;
  text-shadow: 0 0 8px rgba(68,255,136,0.4);
}

#wait-pest-presets .preset-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Pest level picker ──────────────────────────────────────────── */
.pest-level-picker {
  margin: 0 0 8px;
  text-align: center;
}

.pest-label {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 8px;
}

.pest-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(68,255,136,0.25);
}

.pest-btn {
  padding: 6px 10px;
  border: none;
  background: rgba(0,0,0,0.45);
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  border-right: 1px solid rgba(68,255,136,0.15);
}
.pest-btn:last-child { border-right: none; }

.pest-btn:hover {
  background: rgba(68,255,136,0.08);
  color: rgba(255,255,255,0.7);
}

#wait-pest-picker .pest-btn:disabled,
#wait-pest-toggles .toggle-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pest-btn.active {
  background: rgba(68,255,136,0.18);
  color: #44ff88;
  text-shadow: 0 0 8px rgba(68,255,136,0.4);
}

.pest-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  margin-top: 5px;
}

.pest-toggles {
  margin: 4px 0 0;
}

.pest-toggle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0;
}

.pest-toggle-name {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.5);
  width: 80px;
  text-align: right;
}

.pest-toggles .toggle-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 0;
  background: rgba(0,0,0,0.45);
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.pest-toggles .toggle-btn:first-child { border-radius: 6px 0 0 6px; }
.pest-toggles .toggle-btn:last-child { border-radius: 0 6px 6px 0; }

.pest-toggles .toggle-btn:hover {
  background: rgba(68,255,136,0.08);
  color: rgba(255,255,255,0.7);
}

.pest-toggles .toggle-btn.active {
  background: rgba(68,255,136,0.18);
  color: #44ff88;
  text-shadow: 0 0 8px rgba(68,255,136,0.4);
}

/* ── Pest customize button ─────────────────────────────────────── */
.pest-customize-btn {
  display: block;
  width: 100%;
  padding: 8px 0;
  margin: 6px 0 8px;
  border: 1px dashed rgba(68,255,136,0.3);
  border-radius: 8px;
  background: rgba(0,0,0,0.3);
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.pest-customize-btn:hover {
  background: rgba(68,255,136,0.06);
  color: rgba(255,255,255,0.6);
  border-color: rgba(68,255,136,0.45);
}
.pest-customize-btn.active {
  background: rgba(68,255,136,0.14);
  color: #44ff88;
  border-color: rgba(68,255,136,0.5);
  border-style: solid;
  text-shadow: 0 0 8px rgba(68,255,136,0.4);
}
.pest-customize-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Pest gallery modal ────────────────────────────────────────── */
.pest-gallery-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 70;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  animation: fadeIn 0.2s ease-out;
  overflow-y: auto;
}
.pest-gallery-overlay.active {
  display: flex;
}

.pest-gallery {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 28px 20px;
  border: 1px solid rgba(68,255,136,0.3);
  border-radius: 14px;
  background: rgba(10,10,15,0.95);
  max-width: 340px;
  width: 90vw;
}

.pest-gallery-title {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 20px;
}

.pest-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
  width: 100%;
}

.pest-mascot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.pest-mascot:active { transform: scale(0.95); }
.pest-mascot:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
}

.pest-mascot-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.pest-mascot-img img,
.pest-mascot-img svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) brightness(0.5);
  transition: filter 0.3s;
}
.pest-mascot-img svg {
  padding: 4px;
  object-fit: contain;
}

.pest-mascot-name {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  transition: color 0.2s, text-shadow 0.2s;
  text-align: center;
}

/* Enabled pest mascot state */
.pest-mascot.enabled {
  border-color: rgba(68,255,136,0.45);
  background: rgba(68,255,136,0.08);
}
.pest-mascot.enabled .pest-mascot-img {
  border-color: rgba(68,255,136,0.4);
  box-shadow: 0 0 16px rgba(68,255,136,0.15);
}
.pest-mascot.enabled .pest-mascot-img img,
.pest-mascot.enabled .pest-mascot-img svg {
  filter: none;
}
.pest-mascot.enabled .pest-mascot-name {
  color: #44ff88;
  text-shadow: 0 0 8px rgba(68,255,136,0.3);
}

.pest-mascot:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.pest-gallery-done {
  padding: 10px 40px;
  border: 1px solid rgba(68,255,136,0.4);
  border-radius: 8px;
  background: rgba(68,255,136,0.1);
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #44ff88;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.pest-gallery-done:hover {
  background: rgba(68,255,136,0.18);
}
.pest-gallery-done:active { transform: scale(0.95); }

/* ── Settings screen ─────────────────────────────────────────────── */
.settings-form {
  width: min(88vw, 260px);
  margin-bottom: 20px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.setting-row label {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.5);
}

.setting-row input {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  width: 120px;
  text-align: right;
  text-transform: uppercase;
}

.toggle-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.45);
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.toggle-btn.on {
  color: #33ff99;
  border-color: rgba(51,255,153,0.5);
  background: rgba(51,255,153,0.1);
}
.toggle-btn.off {
  color: #ff4444;
  border-color: rgba(255,68,68,0.4);
  background: rgba(255,68,68,0.08);
}


.exp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.exp-row:has(.exp-corner-btns) {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.exp-row:has(.exp-corner-btns) .exp-name {
  text-align: center;
}

.exp-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
}

.exp-row .toggle-btn {
  min-width: 52px;
  padding: 4px 10px;
  font-size: 11px;
}

.exp-corner-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 100%;
}

.corner-btn {
  padding: 5px 4px;
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.corner-btn.active {
  color: #66ccff;
  border-color: rgba(100,200,255,0.5);
  background: rgba(100,200,255,0.15);
}

/* ── Update button ──────────────────────────────────────────────── */
.menu-btn-update {
  border-color: rgba(255,200,50,0.5);
  color: #ffc832;
  font-size: 12px;
  margin-top: 12px;
}

/* ── Rematch status ──────────────────────────────────────────────── */
.rematch-status {
  font-size: 14px;
  color: rgba(255,255,255,0.55);
  min-height: 20px;
  margin-bottom: 16px;
}

/* ── Countdown ────────────────────────────────────────────────────── */
#countdown-display {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#countdown-display.active { display: flex; }

#countdown-display .num {
  font-family: 'Orbitron', monospace;
  font-size: clamp(60px, 15vw, 120px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(255,255,255,0.3);
  animation: countPop 0.6s ease-out forwards;
}

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

/* ── Abandon countdown (AI-only phantom game) ────────────────────── */
#abandon-countdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 55;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  font-family: 'Orbitron', monospace;
}
#abandon-countdown.visible { opacity: 1; }

.abandon-label {
  font-size: clamp(14px, 3vw, 22px);
  font-weight: 700;
  color: rgba(255, 80, 80, 0.6);
  letter-spacing: 0.3em;
  margin-bottom: 4px;
}

.abandon-timer {
  font-size: clamp(80px, 20vw, 160px);
  font-weight: 900;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 0 40px rgba(255, 60, 60, 0.25);
  line-height: 1;
}

.abandon-sub {
  font-size: clamp(12px, 2.5vw, 18px);
  font-weight: 300;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
}

/* ── Pause screen ────────────────────────────────────────────────── */
#screen-pause {
  background: rgba(0,0,0,0.75);
  position: fixed;
  inset: 0;
  z-index: 55;
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

#screen-pause h2 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 28px;
  color: rgba(255,255,255,0.8);
}

/* ── Set over (between sets) ──────────────────────────────────────── */
#screen-setover {
  background: rgba(0,0,0,0.88);
  position: fixed;
  inset: 0;
  z-index: 55;
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

#screen-setover h1 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 8px;
}
#screen-setover .winner-text {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ── Set scoreboard (tennis-style) ───────────────────────────────── */
.set-scoreboard {
  min-width: 200px;
  margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(0,0,0,0.5);
  overflow: hidden;
}

.set-sb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.35);
}

.set-sb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background 0.2s;
}
.set-sb-row:last-child { border-bottom: none; }
.set-sb-row.set-winner {
  background: rgba(255,255,255,0.06);
}

.set-sb-name {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-sb-wins {
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  min-width: 30px;
  text-align: center;
}

/* ── Game over ────────────────────────────────────────────────────── */
#screen-gameover {
  background: rgba(0,0,0,0.88);
  position: fixed;
  inset: 0;
  z-index: 55;
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

#screen-gameover h1 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 8px;
}
#screen-gameover .winner-text {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
#screen-gameover .scorer-table {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}
#screen-setover .actions,
#screen-gameover .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 100%;
  padding: 0 8px;
  box-sizing: border-box;
}
#screen-setover .actions button,
#screen-gameover .actions button {
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#screen-setover .actions button:active,
#screen-gameover .actions button:active { transform: scale(0.95); }
#screen-setover .actions button:hover,
#screen-gameover .actions button:hover  { background: rgba(255,255,255,0.15); }
#screen-setover .actions button:disabled,
#screen-gameover .actions button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* ── Toast notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 8px 18px;
  border-radius: 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-info {
  background: rgba(51,153,255,0.18);
  border: 1px solid rgba(51,153,255,0.4);
  color: #99ccff;
}
.toast-error {
  background: rgba(255,68,68,0.18);
  border: 1px solid rgba(255,68,68,0.4);
  color: #ff9f9f;
}
.toast-success {
  background: rgba(51,255,153,0.18);
  border: 1px solid rgba(51,255,153,0.4);
  color: #99ffcc;
}

/* ── Smash button (mobile) ────────────────────────────────────────── */
#smash-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,200,50,0.4);
  background: rgba(255,200,50,0.12);
  color: #ffc832;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  z-index: 30;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, box-shadow 0.2s;
}
#smash-btn:active { transform: scale(0.9); }
#smash-btn.available {
  border-color: #ffc832;
  background: rgba(255,200,50,0.25);
  box-shadow: 0 0 20px rgba(255,200,50,0.3);
  animation: smashPulse 0.8s ease-in-out infinite;
}

@keyframes smashPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255,200,50,0.2); }
  50%      { box-shadow: 0 0 28px rgba(255,200,50,0.5); }
}

/* ── Controls hint (desktop) ──────────────────────────────────────── */
#controls-hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: rgba(255,255,255,0.35);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  text-align: center;
}
#controls-hint.visible { opacity: 1; }

.hint-mouse {
  color: rgba(255,51,102,0.55);
  font-style: italic;
}

kbd {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
}

/* ── Mobile action buttons (music, restart) ──────────────────────── */
#mobile-actions {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 30;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.mobile-action-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-action-btn:active { transform: scale(0.88); }

.mobile-action-btn.music-off,
.mobile-action-btn.sfx-off {
  color: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.1);
}

.mobile-audio-row {
  display: flex;
  flex-direction: row;
  gap: 12px;
}

.mobile-quit-btn {
  border-color: rgba(255,68,68,0.35);
  color: rgba(255,68,68,0.6);
  font-size: 16px;
  font-weight: 700;
}
.mobile-quit-btn:active {
  background: rgba(255,68,68,0.15);
}

/* ── Mobile adjustments ───────────────────────────────────────────── */
/* JS adds .mobile-show class; display without relying on media query
   since some high-DPI phones (e.g. Samsung Galaxy S26) may report
   hover:hover and bypass (hover:none) checks. */
#smash-btn.mobile-show { display: flex; align-items: center; justify-content: center; }
#mobile-actions.mobile-show { display: flex; }

/* Also hide controls-hint on narrow touch screens as a CSS fallback */
@media (hover: none) and (pointer: coarse) {
  #controls-hint { display: none; }
}

/* ── Narrow phone HUD adjustments ───────────────────────────────── */
@media (max-width: 480px) {
  #hud {
    gap: 6px;
    top: 6px;
    left: 4px;
    right: 4px;
    transform: none;
    width: auto;
    justify-content: center;
  }
  .score-box {
    padding: 4px 8px;
    min-width: 0;
    flex: 0 1 auto;
    max-width: 30vw;
  }
  .score-box .label {
    font-size: 8px;
    letter-spacing: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .score-box .value {
    font-size: 20px;
  }

  /* ── Compact menu screens for narrow phones ────────────────────── */
  #screen-difficulty h2,
  #screen-mode h2,
  #screen-online h2,
  #screen-online-wait h2,
  #screen-settings h2 {
    margin-bottom: 14px;
    font-size: 14px;
    letter-spacing: 2px;
  }

  .menu-btn {
    width: 220px;
    padding: 10px 0;
    margin-bottom: 8px;
    font-size: 12px;
  }

  .setup-columns {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .setup-col {
    max-width: 260px;
    width: 100%;
  }

  .setup-col-label {
    font-size: 10px;
    margin-bottom: 6px;
  }

  #screen-difficulty {
    margin-top: 8px;
    padding-top: 10px;
  }

  .diff-btn {
    width: 100%;
    padding: 8px 0;
    margin-bottom: 6px;
    font-size: 13px;
  }

  .corner-btn {
    padding: 6px 6px;
    font-size: 10px;
    min-height: 32px;
  }

  .menu-btn-start {
    font-size: 14px;
    padding: 10px 36px;
  }

  .setup-actions-top {
    display: flex;
  }

  .room-code {
    font-size: 15px;
    margin-bottom: 1px;
  }

  .room-code-hint {
    font-size: 10px;
    margin-bottom: 4px;
  }

  .menu-btn-invite {
    font-size: 11px;
    padding: 5px 14px;
    margin-bottom: 6px;
  }

  .status-text {
    font-size: 12px;
    margin-top: 4px;
    min-height: 14px;
  }

  .wait-player-list {
    margin: 6px 0 10px;
    padding: 6px 12px;
    min-width: 200px;
    font-size: 13px;
    line-height: 1.6;
  }

  /* Compact pest panel */
  .pest-panel {
    padding: 6px 8px 4px;
    margin: 6px 0 8px;
  }

  .pest-label {
    font-size: 9px;
    margin-bottom: 4px;
    letter-spacing: 1.5px;
  }

  .preset-btn {
    padding: 5px 8px;
    font-size: 9px;
  }

  .pest-customize-btn {
    padding: 5px 0;
    margin: 3px 0 5px;
    font-size: 9px;
  }

  .pest-btn {
    padding: 5px 10px;
    font-size: 10px;
  }

  .pest-desc {
    font-size: 10px;
    margin-top: 2px;
  }

  /* AI difficulty buttons — match pest panel width */
  #ai-difficulty-picker {
    width: 100%;
  }
  .ai-pick-btns {
    gap: 4px;
    width: 100%;
  }
  .ai-pick-btns .menu-btn {
    width: auto;
    flex: 1;
    padding: 8px 4px;
    font-size: 11px;
    min-width: 0;
  }

  .ai-pick-label {
    font-size: 0.65rem;
    margin-bottom: 2px;
  }

  .wait-actions {
    gap: 2px;
  }

  /* Compact debug controls */
  .debug-bot-btns .menu-btn {
    width: auto;
    font-size: 10px;
    padding: 4px 8px;
  }

  #debug-bot-controls {
    margin-top: 10px;
    padding-top: 8px;
  }

  .version-tag {
    margin-top: 4px;
  }

  /* Compact pest gallery modal */
  .pest-gallery {
    padding: 16px 18px 14px;
  }

  .pest-gallery-title {
    font-size: 12px;
    margin-bottom: 14px;
  }

  .pest-gallery-grid {
    gap: 10px;
    margin-bottom: 14px;
  }

  .pest-mascot {
    padding: 8px 6px;
    gap: 6px;
  }

  .pest-mascot-img {
    width: 56px;
    height: 56px;
  }

  .pest-mascot-name {
    font-size: 8px;
  }

  .pest-gallery-done {
    padding: 8px 32px;
    font-size: 11px;
  }
}
