/* ============================================================
   MOORSCHWEIN AI — Operation Chicken-GPT
   Retro-Futuristic AI Farm Arcade Styling
   ============================================================ */

:root {
  --bg-deep: #070d1c;
  --panel-bg: rgba(11, 20, 40, 0.84);
  --panel-inner: rgba(17, 30, 58, 0.72);
  --border-glow: rgba(0, 242, 255, 0.32);
  --cyan: #00f2ff;
  --amber: #facc15;
  --pink: #ff2e93;
  --danger: #ff4769;
  --success: #22c55e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #162447 0%, #070d1c 75%);
  color: var(--text-main);
  font-family: var(--font-ui);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

/* Responsive 16:9 Game Stage */
.stage-wrapper {
  position: relative;
  width: min(100%, calc((100vh - 24px) * 16 / 9), 1280px);
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  overflow: hidden;
  background: #0f172a;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.7),
    0 0 0 2px rgba(0, 242, 255, 0.25),
    0 0 40px rgba(0, 242, 255, 0.12);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-wrapper.playing #gameCanvas {
  cursor: none;
}

.hidden {
  display: none !important;
}

/* ================= IN-GAME HUD ================= */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-top-left,
.hud-top-right {
  position: absolute;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-top-left {
  left: 16px;
}

.hud-top-right {
  right: 16px;
}

.hud-pill {
  background: rgba(11, 20, 40, 0.8);
  border: 1.5px solid rgba(0, 242, 255, 0.4);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.hud-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--cyan);
  text-transform: uppercase;
  line-height: 1;
}

.hud-value {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: #ffffff;
}

.hud-timer.urgent {
  border-color: var(--danger);
  background: rgba(127, 29, 29, 0.88);
  animation: pulseUrgent 0.6s infinite alternate;
}

.hud-timer.urgent .hud-label,
.hud-timer.urgent .hud-value {
  color: #ffe4e6;
}

@keyframes pulseUrgent {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}

.hud-combo {
  border-color: var(--amber);
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.88), rgba(219, 39, 119, 0.88));
  flex-direction: row;
  padding: 8px 12px;
}

.hud-combo .hud-value {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.hud-secrets {
  flex-direction: row;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
  padding: 8px 12px;
  min-width: auto;
}

.hud-icon-btn {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(11, 20, 40, 0.82);
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.hud-icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--cyan);
  background: rgba(15, 35, 70, 0.95);
}

.hud-bottom-right {
  position: absolute;
  right: 16px;
  bottom: 14px;
}

.ammo-panel {
  background: rgba(11, 20, 40, 0.82);
  border: 1.5px solid rgba(250, 204, 21, 0.45);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.ammo-panel.empty {
  border-color: var(--danger);
  animation: pulseUrgent 0.45s infinite alternate;
}

.ammo-panel.turbo {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.45);
}

.ammo-icons {
  display: flex;
  gap: 4px;
  font-size: 20px;
  line-height: 1;
}

.ammo-chicken {
  transition: transform 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
}

.ammo-chicken.spent {
  opacity: 0.2;
  filter: grayscale(1);
  transform: scale(0.8);
}

.ammo-chicken.turbo-glow {
  filter: drop-shadow(0 0 6px var(--cyan));
}

.reload-hint-btn {
  pointer-events: auto;
  background: rgba(250, 204, 21, 0.16);
  color: var(--amber);
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.reload-hint-btn:hover {
  background: rgba(250, 204, 21, 0.3);
}

/* ================= OVERLAYS ================= */
.overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, rgba(10, 22, 48, 0.52), rgba(5, 10, 24, 0.82));
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.menu-card,
.gameover-card,
.help-card {
  width: min(96%, 980px);
  max-height: 94%;
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1.5px solid var(--border-glow);
  border-radius: 22px;
  padding: 20px 24px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.compact-card {
  width: min(92%, 420px);
  background: var(--panel-bg);
  border: 1.5px solid var(--border-glow);
  border-radius: 22px;
  padding: 26px 28px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.compact-card h2 {
  font-size: 28px;
  letter-spacing: 0.04em;
  color: var(--cyan);
}

.compact-sub {
  margin: 6px 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.compact-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Brand Header */
.brand-header {
  text-align: center;
  margin-bottom: 16px;
}

.brand-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  background: rgba(0, 242, 255, 0.12);
  border: 1px solid rgba(0, 242, 255, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 6px;
}

.brand-title {
  font-size: clamp(26px, 3.6vw, 42px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.08;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

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

.brand-subtitle {
  margin-top: 6px;
  font-size: 13.5px;
  color: #cbd5e1;
}

/* Menu Two-Column Grid */
.menu-grid,
.gameover-grid,
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 16px;
  align-items: stretch;
}

.menu-panel {
  background: var(--panel-inner);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  color: var(--cyan);
}

.name-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(0, 242, 255, 0.38);
  background: rgba(7, 13, 28, 0.85);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.name-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.22);
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-btn {
  padding: 9px 10px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
}

.mode-btn strong {
  font-size: 13.5px;
}

.mode-btn small {
  font-size: 11px;
  opacity: 0.75;
}

.mode-btn.active {
  border-color: var(--cyan);
  background: rgba(0, 242, 255, 0.16);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(0, 242, 255, 0.22);
}

/* Buttons */
.primary-cta {
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #facc15 0%, #f97316 55%, #ff2e93 100%);
  color: #0f172a;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.4);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.primary-cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.primary-cta:active {
  transform: translateY(0);
}

.secondary-btn {
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(0, 242, 255, 0.45);
  background: rgba(0, 242, 255, 0.12);
  color: #e0f2fe;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.secondary-btn:hover {
  background: rgba(0, 242, 255, 0.22);
  transform: translateY(-1px);
}

.ghost-btn {
  padding: 10px 14px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.audio-controls-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.chip-toggle {
  padding: 7px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.chip-toggle.active {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.16);
  color: #dcfce7;
}

.voice-test-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 6px;
}

.mini-btn {
  padding: 7px 6px;
  border-radius: 10px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.1);
  color: #fef08a;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.12s ease;
}

.mini-btn:hover {
  background: rgba(250, 204, 21, 0.22);
  transform: translateY(-1px);
}

.mini-btn.info-btn {
  border-color: rgba(0, 242, 255, 0.4);
  background: rgba(0, 242, 255, 0.12);
  color: #bae6fd;
}

/* Highscore Table */
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-row h2,
.panel-title-row h3 {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--amber);
}

.mode-pill-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(0, 242, 255, 0.12);
  border: 1px solid rgba(0, 242, 255, 0.3);
  border-radius: 999px;
  padding: 3px 9px;
}

.highscore-table-wrap {
  flex: 1;
  max-height: 235px;
  overflow-y: auto;
  border-radius: 10px;
  background: rgba(7, 13, 28, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.highscore-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.highscore-table th {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 7px 8px;
}

.highscore-table td {
  padding: 6px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.highscore-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.highscore-table tr.top-1 td {
  color: #fde047;
  font-weight: 800;
}

.highscore-table tr.is-current-run {
  background: rgba(0, 242, 255, 0.22);
  box-shadow: inset 3px 0 0 var(--cyan);
  font-weight: 800;
}

.controls-mini-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: #cbd5e1;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ================= GAME OVER SCREEN ================= */
.gameover-header {
  text-align: center;
  margin-bottom: 14px;
}

.record-banner {
  display: inline-block;
  background: linear-gradient(90deg, #facc15, #ff2e93);
  color: #0f172a;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.gameover-header h2 {
  font-size: 28px;
  font-weight: 900;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(0, 242, 255, 0.14);
  border: 1.5px solid rgba(0, 242, 255, 0.45);
  font-size: 14px;
  font-weight: 800;
  color: #e0f2fe;
}

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

.stat-box {
  background: rgba(7, 13, 28, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-box.highlight {
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.1);
}

.stat-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.stat-val {
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.stat-box.highlight .stat-val {
  color: var(--amber);
}

.secrets-recap {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.secrets-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  max-height: 138px;
  overflow-y: auto;
}

.secrets-list li {
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.secrets-list li.found {
  background: rgba(0, 242, 255, 0.14);
  border-color: rgba(0, 242, 255, 0.35);
  color: #f0f9ff;
  font-weight: 700;
}

.gameover-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

/* ================= HELP MODAL ================= */
.help-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-section {
  background: var(--panel-inner);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 16px;
}

.help-section h3 {
  font-size: 14px;
  color: var(--cyan);
  margin-bottom: 8px;
  margin-top: 6px;
}

.help-section h3:first-child {
  margin-top: 0;
}

.help-intro {
  font-size: 12.5px;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.help-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: #e2e8f0;
  line-height: 1.35;
}

.help-section li.warn-item {
  color: #fda4af;
}

.help-footer {
  max-width: 340px;
  width: 100%;
  margin: 0 auto;
}

/* Subtle sleek scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(7, 13, 28, 0.4);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 242, 255, 0.35);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 242, 255, 0.6);
}

@media (max-width: 820px) {
  .menu-grid,
  .gameover-grid,
  .help-grid {
    grid-template-columns: 1fr;
  }
}
