:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #a9bbca;
  --panel: rgba(16, 25, 35, 0.9);
  --panel-strong: rgba(8, 14, 23, 0.96);
  --line: rgba(255, 255, 255, 0.16);
  --blue: #4fc3ff;
  --green: #57e39b;
  --yellow: #ffd764;
  --red: #ff6b5d;
  --pink: #ff7ed4;
  --charcoal: #101923;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 15% 20%, rgba(79, 195, 255, 0.28), transparent 26rem),
    radial-gradient(circle at 80% 10%, rgba(255, 215, 100, 0.2), transparent 22rem),
    linear-gradient(145deg, #101923 0%, #182938 48%, #0f141d 100%);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 10px;
}

.game-card {
  width: min(1180px, 100%);
  height: min(100dvh - 20px, 900px);
  min-height: 620px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(7, 13, 20, 0.92) 0%, rgba(7, 13, 20, 0.58) 45%, rgba(7, 13, 20, 0.2) 100%),
    url("assets/spark-on-hero.webp") center / cover no-repeat,
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 38%),
    var(--panel);
  box-shadow: 0 22px 70px var(--shadow);
  overflow: hidden;
}

.topbar,
.hero-row,
.landing-stage,
.hud,
.control-row,
.buzz-footer {
  position: relative;
  z-index: 1;
}

.topbar,
.hero-row,
.hud,
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  min-width: 0;
  min-height: 38px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 50%;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3));
}

.shell-links,
.mode-tabs,
.gadget-tray,
.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-button,
.mode-button,
.gadget-button,
.icon-action,
.primary-button,
.close-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 12px;
}

.mini-button:hover,
.mode-button:hover,
.gadget-button:hover,
.icon-action:hover,
.close-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.mini-button.accent,
.primary-button {
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #07131a;
  border-color: transparent;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.provenance-badge {
  width: fit-content;
  border: 1px solid rgba(255, 207, 56, 0.32);
  border-radius: 999px;
  padding: 0.24rem 0.55rem;
  background: rgba(255, 255, 255, 0.1);
}

.game-titlemark {
  display: block;
  width: min(100%, 620px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.3));
}

body.is-playing .game-titlemark {
  width: clamp(174px, 26vw, 340px);
}

h1 {
  margin: 0;
  max-width: 650px;
  font-size: clamp(3rem, 8vw, 7rem);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.tagline {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--ink);
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 750;
}

.landing-stage {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.landing-copy {
  align-self: center;
  max-width: 420px;
}

.landing-kicker {
  margin: 0 0 16px;
  color: var(--yellow);
  font-size: clamp(1.1rem, 2.2vw, 1.7rem);
  font-weight: 900;
}

.landing-start {
  min-width: 190px;
  min-height: 54px;
  font-size: 1.12rem;
}

.mode-cards {
  width: min(460px, 48%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.mode-card {
  min-width: 0;
  min-height: 88px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 12px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 13, 20, 0.72);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
}

.mode-card:hover {
  border-color: rgba(87, 227, 155, 0.75);
  background: rgba(10, 21, 29, 0.86);
}

.mode-card strong {
  font-size: 0.9rem;
}

.mode-card span:last-child {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

body.is-playing .landing-stage,
body.is-landing .hud,
body.is-landing .play-wrap,
body.is-landing .control-row {
  display: none;
}

body.is-playing .game-card {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 38%),
    var(--panel);
}

body.is-playing h1 {
  font-size: clamp(1.4rem, 3vw, 2.8rem);
}

body.is-playing .tagline {
  display: none;
}

.mode-button.is-active,
.gadget-button.is-selected {
  border-color: rgba(87, 227, 155, 0.9);
  background: rgba(87, 227, 155, 0.18);
  box-shadow: inset 0 0 0 1px rgba(87, 227, 155, 0.2);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.hud-pill {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 11, 18, 0.58);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.hud-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-pill strong {
  font-size: 1.15rem;
  line-height: 1;
}

.status-pill {
  color: var(--yellow);
  font-weight: 800;
}

.play-wrap {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)),
    #172536;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 260px;
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 15, 23, 0.42);
}

.play-overlay.is-hidden {
  pointer-events: none;
  opacity: 0;
}

.start-panel {
  max-width: 360px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(11, 18, 28, 0.86);
  padding: 16px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

.start-panel p {
  margin: 0 0 14px;
  color: var(--muted);
}

.control-row {
  align-items: stretch;
}

.gadget-tray {
  flex: 1;
  min-width: 0;
}

.gadget-button {
  flex: 1;
  display: grid;
  grid-template-columns: 28px minmax(0, auto);
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  font-weight: 800;
}

.gadget-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: block;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.24), 0 0 18px rgba(255, 255, 255, 0.1);
}

.softener-icon {
  background: linear-gradient(135deg, #bff2ff, #57e39b);
}

.booster-icon {
  background: linear-gradient(135deg, #ffd764, #ff6b5d);
}

.bucket-icon {
  background: linear-gradient(135deg, #4fc3ff, #ff7ed4);
}

.action-buttons {
  flex: 0 0 auto;
}

.icon-action {
  min-width: 68px;
  font-weight: 850;
}

.buzz-footer {
  color: var(--muted);
  display: grid;
  grid-template-columns: minmax(190px, 0.75fr) minmax(0, 1.5fr);
  gap: 10px 14px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 11, 18, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.footer-brand {
  min-width: 0;
}

.footer-brand a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 950;
}

.footer-mark {
  width: 30px;
  height: 30px;
}

.footer-subline,
.footer-promise {
  color: var(--muted);
}

.footer-subline {
  display: block;
  margin-top: 3px;
  font-size: 0.76rem;
}

.footer-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.footer-nav a,
.footer-nav button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  min-height: 34px;
  padding: 7px 10px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 850;
}

.footer-nav a:hover,
.footer-nav button:hover {
  border-color: rgba(255, 215, 100, 0.55);
  color: var(--yellow);
}

.footer-promise {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

body.is-playing .buzz-footer {
  grid-template-columns: auto minmax(0, 1fr);
  padding: 7px;
}

body.is-playing .footer-subline,
body.is-playing .footer-promise {
  display: none;
}

body.is-playing .footer-nav a,
body.is-playing .footer-nav button {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 0.76rem;
}

body.is-playing .footer-optional {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(720px, calc(100dvh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal h2,
.modal h3,
.modal p {
  margin-top: 0;
}

.modal p,
.modal li {
  color: var(--muted);
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.record-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.record-cell span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.record-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 1.4rem;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
    place-items: stretch;
  }

  .game-card {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 8px;
    gap: 7px;
  }

  .topbar {
    gap: 6px;
  }

  .shell-links {
    gap: 5px;
  }

  .mini-button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.78rem;
  }

  .brand-link span:last-child {
    display: none;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .hero-row {
    align-items: flex-start;
  }

  h1 {
    font-size: clamp(3.05rem, 14vw, 4rem);
    max-width: none;
  }

  .tagline {
    max-width: 82vw;
    font-size: 0.95rem;
  }

  .mode-tabs {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 42vw;
    gap: 5px;
  }

  .mode-button {
    min-height: 30px;
    padding: 5px 7px;
    font-size: 0.76rem;
  }

  .hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .hud-pill {
    min-height: 40px;
    padding: 6px;
  }

  .hud-label {
    font-size: 0.61rem;
  }

  .hud-pill strong,
  .status-pill {
    font-size: 0.86rem;
  }

  .landing-copy {
    max-width: none;
  }

  .landing-stage {
    align-items: flex-end;
    gap: 10px;
  }

  .mode-cards {
    width: min(190px, 46vw);
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .mode-card {
    min-height: 44px;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    align-items: center;
    gap: 0 7px;
    padding: 6px;
    text-align: left;
  }

  .mode-card strong {
    font-size: 0.72rem;
  }

  .mode-card span:last-child {
    font-size: 0.61rem;
  }

  .landing-kicker {
    margin-bottom: 10px;
    font-size: 1.08rem;
  }

  .landing-start {
    width: min(230px, 100%);
    min-height: 50px;
  }

  body.is-playing h1 {
    font-size: clamp(1.15rem, 6vw, 1.8rem);
    max-width: 56vw;
    white-space: normal;
  }

  .control-row {
    flex-direction: column;
    gap: 6px;
  }

  .gadget-tray,
  .action-buttons {
    width: 100%;
    gap: 5px;
  }

  .gadget-button,
  .icon-action {
    min-height: 40px;
    padding: 5px;
    font-size: 0.76rem;
  }

  .gadget-button {
    grid-template-columns: 22px minmax(0, auto);
    gap: 5px;
  }

  .gadget-icon {
    width: 22px;
    height: 22px;
  }

  .action-buttons .icon-action {
    flex: 1;
  }

  .buzz-footer {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 8px;
    line-height: 1.2;
  }

  .footer-nav {
    justify-content: flex-start;
    gap: 5px;
  }

  .footer-nav a,
  .footer-nav button {
    min-height: 30px;
    padding: 5px 7px;
    font-size: 0.68rem;
  }

  .footer-subline,
  .footer-promise {
    font-size: 0.66rem;
  }

  body.is-playing .buzz-footer {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 5px;
  }

  body.is-playing .footer-brand a span:last-child {
    display: none;
  }

  body.is-playing .footer-nav {
    justify-content: flex-end;
  }

  body.is-playing .footer-nav a,
  body.is-playing .footer-nav button {
    min-height: 34px;
    padding: 5px 7px;
    font-size: 0.66rem;
  }
}

@media (max-height: 640px) {
  .eyebrow,
  .buzz-footer span {
    display: none;
  }

  .game-card {
    gap: 5px;
  }

  h1 {
    font-size: 1.15rem;
  }

  body.is-landing h1 {
    font-size: 2.4rem;
  }

  .hud-pill {
    min-height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
