:root {
  --bg: #0f172a;
  --card: #111827;
  --card-2: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --line: rgba(255,255,255,.12);
  --accent: #38bdf8;
  --danger: #fb7185;
  --shadow: 0 18px 60px rgba(0,0,0,.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(56,189,248,.18), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(167,139,250,.14), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--accent);
  color: #082f49;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

button.secondary,
button.ghost {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.app {
  width: min(100%, 860px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: -.04em;
}

h2 {
  font-size: 16px;
}

.subtitle {
  color: var(--muted);
  margin-top: 2px;
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: auto 260px;
  gap: 16px;
  align-items: start;
}

.game-card,
.panel {
  background: rgba(17,24,39,.82);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.game-card {
  padding: 14px;
}

#game {
  display: block;
  width: min(74vw, 360px);
  height: calc(min(74vw, 360px) * 2);
  max-height: calc(100svh - 220px);
  aspect-ratio: 1 / 2;
  background: #020617;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.panel {
  padding: 16px;
  display: grid;
  gap: 16px;
}

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

.stats div {
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stats strong {
  font-size: 24px;
}

.next {
  display: grid;
  gap: 10px;
}

#next {
  width: 120px;
  height: 120px;
  background: #020617;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.buttons {
  display: grid;
  gap: 10px;
}

details {
  color: var(--muted);
  font-size: 14px;
}

summary {
  color: var(--text);
  cursor: pointer;
  margin-bottom: 8px;
}

ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.mobile-controls {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  align-items: stretch;
}

.mobile-controls button {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.mobile-controls .control-main {
  min-height: 58px;
  padding: 10px 8px;
  font-size: 28px;
  border-radius: 18px;
}

.mobile-controls .control-left {
  grid-column: 1;
}

.mobile-controls .control-rotate {
  grid-column: 2;
}

.mobile-controls .control-right {
  grid-column: 3;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2,6,23,.62);
  backdrop-filter: blur(8px);
}

.overlay.hidden {
  pointer-events: none;
}

.modal {
  width: min(100%, 360px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  text-align: center;
}

@media (max-width: 760px) {
  body {
    align-items: start;
    padding-top: calc(env(safe-area-inset-top) + 8px);
  }

  .topbar {
    margin-bottom: 10px;
  }

  h1 {
    font-size: 34px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .game-card {
    padding: 8px;
  }

  .panel {
    grid-template-columns: 1fr;
  }

  .mobile-controls {
    display: grid;
  }

  #game {
    width: 100%;
    max-height: calc(100svh - 165px);
    height: auto;
  }
}


.audio-status {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
