﻿:root {
  --bg: #0d0d18;
  --panel: rgba(0, 0, 0, 0.35);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.72);
  --danger: rgba(255, 90, 90, 0.7);
  --max-content: 1080px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", sans-serif;
  touch-action: none;
  user-select: none;
}

body.stats-body {
  overflow: auto;
  touch-action: pan-y;
  user-select: auto;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.center-wrap {
  width: 100%;
  max-width: var(--max-content);
  min-height: 100%;
  margin: 0 auto;
}

#menu {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 0%, #2a0a20 0%, #0d0d18 72%);
}

.title-wrap {
  margin-bottom: 20px;
  text-align: center;
}

.title-wrap h1 {
  font-family: "Russo One", sans-serif;
  font-size: clamp(32px, 8vw, 56px);
  line-height: 1.1;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #fff 26%, #ffb3d1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  margin-top: 10px;
  font-size: clamp(14px, 2.8vw, 18px);
  color: rgba(255, 255, 255, 0.58);
}

.menu-actions {
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 560px;
}

.menu-link {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: #fff;
  text-align: center;
  text-decoration: none;
  padding: 10px 14px;
  font-weight: 800;
}

.mode-cards {
  display: grid;
  width: 100%;
  max-width: 920px;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.mode-card {
  border: none;
  border-radius: 20px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 16px 18px;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.mode-card:active {
  transform: scale(0.98);
}

.mode-emoji {
  font-size: 46px;
  line-height: 1;
}

.mode-title {
  font-family: "Russo One", sans-serif;
  font-size: clamp(18px, 3vw, 24px);
}

.mode-sub {
  margin-top: 4px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.35;
}

.mode-arrow {
  margin-left: auto;
  opacity: 0.7;
  font-size: 20px;
}

#game-screen {
  display: none;
  height: 100%;
  flex-direction: column;
}

#hud {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 10px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Russo One", sans-serif;
  font-size: clamp(15px, 2.4vw, 22px);
}

.hud-stat.right {
  justify-content: flex-end;
}

.hud-wave {
  text-align: center;
  font-family: "Russo One", sans-serif;
  font-size: clamp(13px, 2vw, 18px);
  color: rgba(255, 255, 255, 0.82);
}

#canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 240px;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#wave-ann {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Russo One", sans-serif;
  font-size: clamp(28px, 6vw, 52px);
  text-shadow: 0 0 20px rgba(255, 219, 107, 0.92);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 3;
  text-align: center;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.45);
  font-size: clamp(11px, 1.7vw, 14px);
  text-align: center;
  pointer-events: none;
  z-index: 3;
  white-space: nowrap;
}

#overlay {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 6;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
}

#overlay.show {
  display: flex;
}

.overlay-card {
  width: min(440px, 100%);
  border-radius: 16px;
  background: rgba(10, 10, 22, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 20px;
  text-align: center;
}

.overlay-card h2 {
  font-family: "Russo One", sans-serif;
  font-size: clamp(24px, 4vw, 38px);
}

.overlay-sub {
  margin-top: 10px;
  color: var(--text-muted);
  line-height: 1.35;
}

#overlay-score {
  margin-top: 14px;
  font-family: "Russo One", sans-serif;
  color: #ffd55b;
  font-size: clamp(28px, 6vw, 46px);
}

.score-form {
  margin-top: 14px;
  display: none;
  gap: 8px;
  align-items: stretch;
}

.score-form.show {
  display: grid;
  grid-template-columns: 1fr auto;
}

.score-input {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.overlay-status {
  min-height: 20px;
  margin-top: 8px;
  color: #ffd55b;
  font-size: 13px;
}

.ov-actions {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.ov-btn {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #3a73ff, #5ca9ff);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  font-family: "Russo One", sans-serif;
}

.ov-btn.ghost {
  background: rgba(255, 255, 255, 0.12);
  font-family: "Nunito", sans-serif;
}

.stats-page {
  min-height: 100vh;
  overflow: auto;
  background: radial-gradient(ellipse at 50% 0%, #102647 0%, #0d0d18 72%);
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.stats-wrap {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.stats-header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.stats-header h1 {
  font-family: "Russo One", sans-serif;
  font-size: clamp(24px, 5vw, 44px);
}

.top-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-filter,
.stats-btn {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 8px 12px;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
}

.panel {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  padding: 12px;
}

.panel h2 {
  margin-bottom: 10px;
  font-family: "Russo One", sans-serif;
  font-size: 22px;
}

.score-list {
  display: grid;
  gap: 6px;
}

.score-item {
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.score-rank {
  color: #ffd55b;
  font-family: "Russo One", sans-serif;
}

.score-meta {
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  #hint {
    white-space: normal;
    width: calc(100% - 24px);
  }
}

@media (max-width: 640px) {
  .menu-actions {
    flex-direction: column;
  }

  #hud {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 4px;
    padding-bottom: 8px;
  }

  .hud-stat,
  .hud-stat.right {
    justify-content: center;
  }

  .score-form.show {
    grid-template-columns: 1fr;
  }
}
