body.stacks-page {
  --page-bg: #0c0d0f;
  --page-bg-accent: rgba(111, 152, 255, 0.18);
  --panel: rgba(18, 20, 24, 0.82);
  --panel-strong: rgba(20, 23, 28, 0.96);
  --accent: #6f98ff;
  --accent-strong: #e0e7ff;
  --accent-soft: rgba(111, 152, 255, 0.18);
  --line: rgba(157, 167, 187, 0.18);
  --shadow: 0 22px 70px rgba(3, 4, 7, 0.42);
  --felt-board-bg: rgba(17, 52, 46, 0.98);
  background: #0c0d0f;
}

.stacks-page .shell {
  max-width: 1160px;
  padding: 1.4rem 0 0;
}

.stacks-page .hero {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.9fr);
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: center;
}

.stacks-page .eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
}

.stacks-page .hero-copy-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.9rem;
}

.stacks-page .hero-back-link {
  width: 2.4rem;
  min-width: 2.4rem;
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.18rem;
  border-radius: 999px;
  border: 1px solid rgba(157, 167, 187, 0.24);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 1.3rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stacks-page .hero-back-link:hover,
.stacks-page .hero-back-link:focus-visible {
  color: #f4f7ff;
  border-color: rgba(111, 152, 255, 0.44);
  background: rgba(111, 152, 255, 0.1);
}

.stacks-page .hero h1 {
  font-size: clamp(2.6rem, 5vw, 4.5rem);
  line-height: 0.95;
}

.stacks-page .hero-copy,
.stacks-page .hero-status-card,
.stacks-page .game-surface-card,
.stacks-page .how-to-card {
  border-radius: calc(var(--radius) + 0.1rem);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.stacks-page .hero-status-card {
  overflow: hidden;
  align-self: center;
}

.stacks-page .game-layout {
  grid-template-columns: minmax(460px, 620px);
  justify-content: center;
  gap: 0.8rem;
}

.stacks-page .game-surface-header,
.stacks-page .panel-section,
.stacks-page .canvas-shell {
  padding-left: 0.85rem;
  padding-right: 0.85rem;
}

.stacks-page .game-surface-header,
.stacks-page .panel-section {
  padding-top: 0.85rem;
}

.stacks-page .game-surface-copy,
.stacks-page .panel-copy,
.stacks-page .canvas-caption {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
}

.stacks-page .game-surface-header h2,
.stacks-page .panel-heading {
  color: var(--ink);
}

.stacks-page .state-pill {
  color: #9ae6b4;
  background: rgba(72, 187, 120, 0.16);
  border: 1px solid rgba(72, 187, 120, 0.35);
}

.stacks-board-frame {
  width: min(100%, 22.5rem, 30vh);
  margin: 0 auto;
  aspect-ratio: 10 / 20;
  background:
    radial-gradient(circle at 16% 22%, rgba(138, 255, 206, 0.16), transparent 22%),
    radial-gradient(circle at 84% 14%, rgba(91, 201, 255, 0.14), transparent 24%),
    radial-gradient(circle at 55% 78%, rgba(242, 221, 135, 0.08), transparent 28%),
    linear-gradient(138deg, rgba(25, 113, 90, 0.98), rgba(20, 89, 76, 0.98) 38%, rgba(20, 115, 79, 0.98) 70%, rgba(28, 77, 105, 0.98)),
    var(--felt-board-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 24px 70px rgba(10, 42, 33, 0.3);
}

.stacks-board-frame::before,
.stacks-board-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.stacks-board-frame::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0)),
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.18), transparent 30%);
}

.stacks-board-frame::after {
  background:
    radial-gradient(circle at 20% 88%, rgba(36, 20, 5, 0.18), transparent 18%),
    radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.05), transparent 22%);
}

#stacksCanvas {
  width: 100%;
  aspect-ratio: 10 / 20;
}

.canvas-stage {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr) 7.2rem;
  align-items: start;
  gap: 0.7rem;
}

.board-side-toolbar {
  display: flex;
  justify-content: flex-start;
  align-self: start;
}

.board-main {
  display: grid;
  width: fit-content;
  max-width: 100%;
  justify-self: center;
  justify-items: center;
  gap: 0.7rem;
}

.board-control-shell {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 3rem;
  align-items: center;
  gap: 0.7rem;
  width: fit-content;
  max-width: 100%;
  margin: 0;
}

.board-drop-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

.board-drop-btn {
  min-width: min(12rem, 100%);
  padding-inline: 1.4rem;
}

.board-arrow {
  min-height: 7.5rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 24, 34, 0.88);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 18px 40px rgba(3, 6, 10, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
}

.board-arrow:hover:not(:disabled),
.board-arrow:focus-visible {
  border-color: rgba(111, 152, 255, 0.44);
  background: rgba(20, 31, 44, 0.92);
  color: #f4f7ff;
}

.start-overlay,
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 13, 0.52);
}

.start-overlay.is-visible,
.pause-overlay.is-visible {
  display: flex;
}

.start-btn {
  min-width: 8.5rem;
  min-height: 3rem;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(111, 152, 255, 0.4);
  background: rgba(111, 152, 255, 0.18);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 40px rgba(3, 6, 10, 0.22);
  letter-spacing: 0.14em;
}

.start-btn:hover:not(:disabled),
.start-btn:focus-visible {
  border-color: rgba(111, 152, 255, 0.56);
  background: rgba(111, 152, 255, 0.26);
  color: #f4f7ff;
}

.pause-btn {
  min-width: 9rem;
  min-height: 3rem;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 15, 21, 0.88);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 40px rgba(3, 6, 10, 0.22);
  letter-spacing: 0.16em;
}

.pause-btn:hover:not(:disabled),
.pause-btn:focus-visible {
  border-color: rgba(111, 152, 255, 0.42);
  background: rgba(16, 24, 34, 0.92);
  color: #f4f7ff;
}

.touch-controls {
  display: none;
  padding: 0 0.85rem 0.85rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.stacks-page .status-grid {
  gap: 0.45rem;
}

.stacks-page .hero-status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0.56rem 0.62rem;
  gap: 0.56rem;
  align-items: start;
}

.stacks-page .stat {
  min-height: 0;
  padding: 0.48rem 0.58rem 0.42rem;
}

.stacks-page .stat-label {
  font-size: 0.66rem;
  margin-bottom: 0.22rem;
}

.stacks-page .stat-value {
  font-size: 1.16rem;
  line-height: 1;
}

.stacks-page .board-status-panel {
  padding-top: 0;
}

.stacks-page .stat-meta {
  margin-top: 0.18rem;
  font-size: 0.76rem;
  line-height: 1.35;
}

.stacks-page button {
  min-height: 2.45rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 0.95rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
}

.stacks-page button:hover:not(:disabled) {
  border-color: rgba(111, 152, 255, 0.5);
  background: rgba(111, 152, 255, 0.1);
  color: #eef2f8;
}

.stacks-page button.ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.stacks-page #newGameBtn {
  background: rgba(111, 152, 255, 0.16);
  border-color: rgba(111, 152, 255, 0.36);
}

.music-now-playing,
.floating-action {
  padding: 0.72rem 0.86rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.music-now-playing {
  max-width: min(17rem, calc(100vw - 2rem));
  display: grid;
  gap: 0.22rem;
  text-align: right;
}

.music-now-footer {
  max-width: min(28rem, calc(100vw - 2rem));
  margin: 1rem auto 0;
  text-align: center;
}

.music-now-label,
.music-track-credit {
  font-size: 0.67rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.music-track-title {
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--ink);
}

.music-track-credit {
  text-decoration: none;
}

.music-track-credit:hover {
  color: var(--ink);
}

.floating-controls {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.7rem;
}

.floating-game-actions {
  width: 4.2rem;
  display: grid;
  gap: 0.45rem;
}

.floating-action {
  width: 4.2rem;
  min-width: 4.2rem;
  min-height: 4.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.stacks-page .floating-action.game-action {
  width: 100%;
}

.icon-action {
  padding: 0;
}

#newGameBtn {
  padding: 0;
}

.game-action-icon,
.pause-icon {
  width: 1.45rem;
  height: 1.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.game-action-icon svg,
.pause-glyph {
  width: 100%;
  height: 100%;
}

.pause-glyph-play {
  display: none;
}

#pauseBtn.is-resume .pause-glyph-pause {
  display: none;
}

#pauseBtn.is-resume .pause-glyph-play {
  display: block;
}

.music-toggle {
  padding: 0;
  justify-content: center;
  border-radius: 1.25rem;
  color: var(--ink);
}

.music-toggle.is-on {
  border-color: rgba(255, 241, 166, 0.95);
  box-shadow:
    0 0 0 1px rgba(255, 241, 166, 0.32),
    0 10px 18px rgba(18, 24, 20, 0.24),
    0 0 24px rgba(255, 222, 120, 0.3);
}

.music-toggle-icon {
  width: 2rem;
  height: 2rem;
}

.music-toggle-wave,
.music-toggle-wave-outer {
  opacity: 0.22;
  transition: opacity 120ms ease;
}

.music-toggle-slash {
  transition: opacity 120ms ease;
}

.music-toggle.is-on .music-toggle-wave,
.music-toggle.is-on .music-toggle-wave-outer {
  opacity: 1;
}

.music-toggle.is-on .music-toggle-slash {
  opacity: 0;
}

.floating-action:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.88);
  outline-offset: 2px;
}

.help-panel {
  width: min(28rem, calc(100vw - 2rem));
  overflow: hidden;
}

.how-to-body {
  padding: 0.9rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.how-to-body .instruction-list {
  margin-top: 0.6rem;
  color: var(--muted);
}

.preview-stat,
.board-preview-card {
  display: grid;
  gap: 0.5rem;
}

.board-preview-card {
  align-self: start;
  justify-items: stretch;
}

.preview-frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(20, 33, 47, 0.96);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
}

.board-preview-frame {
  width: 100%;
}

#nextCanvas {
  width: min(100%, 5.75rem);
  aspect-ratio: 1 / 1;
}

kbd {
  font-family: var(--mono);
}

@media (max-height: 920px) and (min-width: 981px) {
  .stacks-page .hero h1 {
    font-size: clamp(2.3rem, 4vw, 3.8rem);
  }
}

@media (max-width: 980px) {
  .stacks-page .shell {
    max-width: 1160px;
  }

  .stacks-page .hero {
    grid-template-columns: 1fr;
  }

  .stacks-page .hero-copy-wrap {
    gap: 0.7rem;
  }

  .stacks-page .hero-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stacks-page .game-layout {
    grid-template-columns: minmax(380px, 580px);
  }

  .touch-controls {
    display: grid;
  }
}

@media (max-width: 720px) {
  .stacks-page .hero h1 {
    font-size: clamp(2rem, 9vw, 2.8rem);
  }

  .stacks-page .hero-copy-wrap {
    align-items: center;
  }

  .stacks-page .hero-back-link {
    width: 2.15rem;
    min-width: 2.15rem;
    min-height: 2.15rem;
    margin-top: 0;
    font-size: 1.15rem;
  }

  .stacks-page .game-layout {
    grid-template-columns: 1fr;
  }

  .stacks-page .shell {
    padding: 0.85rem;
  }

  .canvas-stage {
    grid-template-columns: 4.2rem minmax(0, 1fr);
    gap: 0.55rem;
  }

  .board-side-toolbar {
    grid-column: 1;
    grid-row: 1;
  }

  .board-main {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
  }

  .board-preview-card {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 7rem;
    justify-self: end;
  }

  .board-control-shell {
    grid-template-columns: 2.6rem minmax(0, 1fr) 2.6rem;
    gap: 0.45rem;
  }

  .board-drop-row {
    margin-top: 0.55rem;
  }

  .board-arrow {
    min-height: 5.75rem;
    font-size: 1.2rem;
  }

  .stacks-board-frame {
    width: min(100%, 22rem);
  }

  .how-to-body {
    grid-template-columns: 1fr;
  }

  .touch-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .floating-controls {
    right: 0.75rem;
    bottom: 0.75rem;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .music-now-playing {
    max-width: min(14rem, calc(100vw - 1.5rem));
  }
}
