:root {
  --bg: #0f1116;
  --bg-deep: #0b0d12;
  --panel: #151a22;
  --panel-2: #111620;
  --text: #eef2f7;
  --text-muted: #9aa4b2;
  --accent: #2ec4b6;
  --accent-2: #ffb703;
  --accent-3: #ff6b6b;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(46, 196, 182, 0.12), transparent 45%),
    radial-gradient(circle at 90% 20%, rgba(255, 183, 3, 0.12), transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(255, 107, 107, 0.08), transparent 45%),
    linear-gradient(135deg, var(--bg-deep), var(--bg));
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px 48px;
}

.screen {
  display: none;
  width: 100%;
  animation: fade-up 0.4s ease-out both;
}

.screen.active {
  display: flex;
  justify-content: center;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel {
  width: min(960px, 94vw);
  background: linear-gradient(160deg, rgba(21, 26, 34, 0.96), rgba(17, 22, 32, 0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 40px);
  box-shadow: var(--shadow);
}

.menu-panel {
  text-align: center;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 12px;
}

h1, h2 {
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  margin: 0 0 12px;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
}

h2 {
  font-size: 1.5rem;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
}

.best-scores {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.best-scores span {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.best-scores strong {
  color: var(--accent-2);
  font-size: 1.2rem;
  margin-left: 6px;
}

.mode-select {
  display: inline-flex;
  gap: 12px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.mode-select button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.mode-select button.is-active {
  background: rgba(46, 196, 182, 0.18);
  color: var(--text);
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #041b19;
  box-shadow: 0 12px 30px rgba(46, 196, 182, 0.35);
}

.btn-secondary {
  background: rgba(255, 183, 3, 0.15);
  color: var(--text);
  border: 1px solid rgba(255, 183, 3, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn:hover {
  transform: translateY(-1px);
}

.game-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 18px 22px;
  background: rgba(21, 26, 34, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.title-block .subtext {
  color: var(--text-muted);
  margin: 6px 0 0;
}

.stats {
  display: flex;
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat span {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat strong {
  font-size: 1.6rem;
  color: var(--text);
}

#timer {
  color: var(--accent-2);
}

#score {
  color: var(--accent);
}

.board-wrap {
  position: relative;
  margin: 0 auto;
  width: min(560px, 92vw);
  box-sizing: border-box;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(15, 18, 26, 0.8);
  border: 1px solid var(--border);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.35);
}

.board-canvas {
  display: block;
  border-radius: 12px;
  touch-action: none;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-8px);
}

.gameover-panel {
  text-align: center;
}

.score-line {
  font-size: 2.6rem;
  color: var(--accent-2);
  margin: 24px 0 10px;
}

.best-score-line {
  color: var(--text-muted);
}

.new-best {
  margin-left: 8px;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #041b19;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  .stats {
    width: 100%;
    justify-content: space-between;
  }

  .stat {
    align-items: flex-start;
  }

  .board-wrap {
    padding: 10px;
  }
}
