:root {
  --bg: #06111b;
  --surface: rgba(7, 19, 30, 0.86);
  --surface-2: rgba(12, 31, 43, 0.96);
  --line: rgba(148, 163, 184, 0.2);
  --text: #e5f4ef;
  --muted: #9db8ad;
  --accent: #4ade80;
  --accent-2: #22c55e;
  --gold: #f59e0b;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(34, 197, 94, 0.18), transparent 38%),
    linear-gradient(180deg, #0b2230, #06111b 60%);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
}

body {
  display: flex;
  justify-content: center;
}

.wrap {
  width: min(1024px, 100vw);
  padding: 14px;
}

.topbar,
.controls,
.panel,
.stat {
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(12, 31, 43, 0.92), rgba(8, 22, 31, 0.92));
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 62ch;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

button {
  border: 0;
  border-radius: 12px;
  color: #f8fffb;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

#restartBtn {
  padding: 10px 14px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
}

#soundBtn {
  padding: 10px 14px;
  background: linear-gradient(135deg, #15803d, #0f766e);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(8, 21, 30, 0.9), rgba(13, 29, 38, 0.94));
}

.stat span {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat strong {
  font-size: 1.02rem;
}

#game {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 22px;
  background: linear-gradient(180deg, #8cd9ff 0 28%, #4f8f43 28% 100%);
  touch-action: none;
  box-shadow: 0 24px 60px rgba(2, 8, 23, 0.36);
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9, 25, 34, 0.92), rgba(7, 19, 28, 0.92));
}

#message {
  margin: 0;
  font-weight: 600;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.panel {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 22, 31, 0.92), rgba(12, 29, 38, 0.94));
}

.panel h2 {
  font-size: 1rem;
}

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

.actions button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(14, 165, 233, 0.18));
  border: 1px solid rgba(134, 239, 172, 0.18);
}

.actions button span {
  color: #fef3c7;
  font-weight: 800;
}

@media (max-width: 720px) {
  .hud,
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
  }

  #restartBtn,
  #soundBtn {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .hud,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .wrap {
    padding: 10px;
  }
}
