body.starshards-page {
  --page-bg: #000;
  --page-bg-accent: rgba(79, 201, 255, 0.16);
  --panel: rgba(10, 15, 24, 0.86);
  --panel-strong: rgba(8, 13, 22, 0.96);
  --accent: #7df0ff;
  --accent-strong: #eafaff;
  --accent-soft: rgba(125, 240, 255, 0.18);
  --line: rgba(129, 158, 190, 0.2);
  --line-strong: rgba(129, 158, 190, 0.32);
  --ink: #ecf7ff;
  --muted: #a9c3d8;
  --shadow: 0 28px 80px rgba(2, 5, 12, 0.45);
  background: #000;
}

.starshards-page .shell {
  max-width: 1180px;
  padding-top: 1.4rem;
}

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

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

.starshards-page .hero-back-link {
  width: 2.45rem;
  min-width: 2.45rem;
  min-height: 2.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.18rem;
  border-radius: 999px;
  border: 1px solid rgba(125, 240, 255, 0.22);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 1.3rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.04);
}

.starshards-page .hero-back-link:hover,
.starshards-page .hero-back-link:focus-visible {
  border-color: rgba(125, 240, 255, 0.46);
  background: rgba(125, 240, 255, 0.1);
  color: #f6fdff;
}

.starshards-page .hero h1 {
  font-size: clamp(2.7rem, 6vw, 5rem);
  line-height: 0.92;
}

.starshards-page .hero-summary {
  max-width: 40rem;
}

.starshards-page .hero-status-card,
.starshards-page .game-surface-card,
.starshards-page .help-panel {
  border-radius: calc(var(--radius) + 0.1rem);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.starshards-page .hero-status-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 0.65rem;
  gap: 0.55rem;
}

.starshards-page .stat {
  min-height: 0;
  padding: 0.55rem 0.62rem 0.48rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 55%),
    rgba(255, 255, 255, 0.03);
}

.starshards-page .stat-label {
  font-size: 0.65rem;
  margin-bottom: 0.2rem;
}

.starshards-page .stat-value {
  font-size: 1.12rem;
  line-height: 1;
}

.starshards-page .game-layout {
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
}

.starshards-page .game-surface-card {
  max-width: 1000px;
  margin: 0 auto;
  overflow: hidden;
}

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

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

.starshards-page .state-pill.is-good {
  color: #edfffb;
  border-color: rgba(125, 240, 255, 0.38);
  background: rgba(51, 151, 173, 0.28);
}

.starshards-page .state-pill.is-warn {
  color: #fff8de;
  border-color: rgba(255, 200, 122, 0.4);
  background: rgba(130, 77, 22, 0.32);
}

.starshards-page .state-pill.is-danger {
  color: #fff1ee;
  border-color: rgba(255, 124, 124, 0.44);
  background: rgba(125, 37, 37, 0.36);
}

.starshards-frame {
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 16 / 10;
  background: #000;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 20px 60px rgba(2, 6, 12, 0.3);
}

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

.starshards-frame::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 20%),
    linear-gradient(transparent 0, transparent calc(100% - 1px), rgba(255, 255, 255, 0.03) calc(100% - 1px));
}

.starshards-frame::after {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.025) 0,
      rgba(255, 255, 255, 0.025) 2px,
      transparent 2px,
      transparent 7px
    );
  mix-blend-mode: screen;
}

#starshardsCanvas {
  width: 100%;
  aspect-ratio: 16 / 10;
  cursor: crosshair;
}

.start-overlay,
.pause-overlay,
.gameover-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 12, 0.58);
  padding: 1rem;
}

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

.start-panel,
.pause-panel,
.gameover-panel {
  width: min(32rem, 100%);
  padding: 1.2rem 1.2rem 1.1rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(125, 240, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 28%),
    rgba(7, 13, 20, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.start-panel h2 {
  margin: 0.2rem 0 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  letter-spacing: -0.03em;
}

.start-panel-copy,
.pause-copy {
  margin: 0.8rem auto 0;
  max-width: 28rem;
  color: var(--muted);
  line-height: 1.55;
}

.start-btn,
.pause-btn {
  margin-top: 1rem;
  min-width: 9.5rem;
  min-height: 3rem;
  border-radius: 999px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.start-btn {
  border-color: rgba(125, 240, 255, 0.46);
  background: rgba(125, 240, 255, 0.16);
  color: var(--ink);
}

.start-btn:hover:not(:disabled),
.start-btn:focus-visible {
  border-color: rgba(125, 240, 255, 0.6);
  background: rgba(125, 240, 255, 0.26);
  color: #f8fdff;
}

.pause-btn {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(10, 15, 21, 0.88);
  color: var(--ink);
}

/* Game-over overlay */
.gameover-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
}

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

.gameover-stat-grid {
  margin: 0.9rem auto 0;
  max-width: 22rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.gameover-stat {
  padding: 0.5rem 0.55rem 0.42rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.gameover-stat .stat-label {
  font-size: 0.62rem;
  margin-bottom: 0.15rem;
}

.gameover-stat .stat-value {
  font-size: 1.05rem;
  line-height: 1;
}

.gameover-stat .stat-label.is-highlight {
  color: #7df0ff;
}

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

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

.starshards-page button:hover:not(:disabled) {
  border-color: rgba(125, 240, 255, 0.44);
  background: rgba(125, 240, 255, 0.1);
  color: #f5fcff;
}

.starshards-page #newGameBtn {
  background: rgba(125, 240, 255, 0.16);
  border-color: rgba(125, 240, 255, 0.34);
}

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

.starshards-page .panel-copy {
  font-size: 0.92rem;
}

/* SVG icon buttons */
.icon-action {
  padding: 0;
}

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

.pause-glyph {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

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

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

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

.game-action-icon,
.restart-icon {
  width: 1.45rem;
  height: 1.45rem;
}

/* Music toggle */
.music-toggle {
  padding: 0;
  color: var(--muted);
  transition: border-color 120ms ease, box-shadow 120ms ease, color 120ms ease;
}

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

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

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

.music-toggle.is-on {
  color: var(--ink);
  border-color: rgba(255, 241, 166, 0.95);
  box-shadow:
    0 0 0 1px rgba(255, 241, 166, 0.32),
    0 0 14px rgba(255, 241, 166, 0.12);
}

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

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

/* Music player bar */
.music-player {
  border-top: 1px solid var(--line);
  padding-bottom: 0.7rem;
}

.music-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.music-player-info {
  min-width: 0;
  flex: 1;
}

.music-title {
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.music-player-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.music-ctrl {
  width: 2.2rem;
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.7rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.music-ctrl:hover:not(:disabled) {
  color: var(--ink);
}

.music-ctrl-main {
  width: 2.6rem;
  min-width: 2.6rem;
  min-height: 2.6rem;
  border-color: rgba(125, 240, 255, 0.3);
  color: var(--ink);
}

.music-pause-icon {
  display: none;
}

.music-ctrl-main.is-playing .music-play-icon {
  display: none;
}

.music-ctrl-main.is-playing .music-pause-icon {
  display: block;
}

.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.4rem;
  display: grid;
  gap: 0.45rem;
}

.floating-action {
  width: 4.4rem;
  min-width: 4.4rem;
  min-height: 4rem;
  padding: 0.72rem 0.86rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

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

.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 {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.help-toggle {
  color: var(--ink);
}

@media (max-width: 980px) {
  .starshards-page .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .starshards-page .shell {
    padding-top: 1rem;
  }

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

  .touch-controls {
    display: grid;
  }

  .floating-controls {
    position: static;
    margin: 0.9rem auto 0;
    width: min(100%, 30rem);
    align-items: stretch;
  }

  .floating-game-actions {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .floating-action,
  .help-panel {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .starshards-page .hero-copy-wrap {
    grid-template-columns: 1fr;
  }

  .starshards-page .hero-back-link {
    margin-top: 0;
  }

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