:root {
  --ink: #242538;
  --muted: #62677a;
  --paper: rgba(255, 255, 255, 0.93);
  --line: rgba(36, 37, 56, 0.14);
  --rose: #ff7aa8;
  --aqua: #39c3ce;
  --gold: #f3c65d;
  --violet: #6c61b8;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.78)),
    url("../../res/images/backgrounds/Soda.png") center / cover fixed;
  touch-action: manipulation;
}

button,
a {
  font: inherit;
}

.game-shell {
  width: min(900px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 26px;
}

.topbar a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #267b83;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 4rem;
  line-height: 1;
}

.hero p:last-child {
  max-width: 680px;
  margin: 14px 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(36, 37, 56, 0.13);
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.hud strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
}

.next-wrap {
  display: grid;
  grid-template-columns: auto 66px;
  align-items: center;
  gap: 10px;
}

.next-wrap span {
  font-weight: 800;
}

#next-ball {
  width: 66px;
  height: 66px;
}

.ball-book {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
}

.ball-book-title {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 900;
}

.level-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 10px;
  min-width: 0;
  padding: 2px 2px 6px;
}

.level-card {
  display: grid;
  place-items: center;
  min-height: 104px;
  padding: 8px 6px;
  border: 1px solid rgba(36, 37, 56, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.level-card canvas {
  width: 58px;
  height: 58px;
}

.level-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #1f2032;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  font-weight: 900;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.stage-wrap {
  width: min(100%, 520px);
  margin: 16px auto 0;
}

#game {
  display: block;
  width: 100%;
  aspect-ratio: 420 / 600;
  border: 1px solid rgba(36, 37, 56, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(217, 246, 248, 0.86)),
    radial-gradient(circle at 50% 16%, rgba(255, 122, 168, 0.24), transparent 24%);
  box-shadow: 0 22px 48px rgba(36, 37, 56, 0.2);
  touch-action: none;
}

.controls {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 12px;
}

.controls p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 620px) {
  .game-shell {
    width: min(100% - 20px, 520px);
    padding-top: 16px;
  }

  h1 {
    font-size: 2.45rem;
  }

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

  .next-wrap,
  .ball-book,
  .hud button,
  .controls button,
  .controls p {
    grid-column: 1 / -1;
  }

  .next-wrap {
    grid-template-columns: auto 66px;
    justify-content: start;
  }

  .ball-book {
    grid-template-columns: 1fr;
  }

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