:root {
  --bg: #f6efe3;
  --bg-accent: #fbf7ef;
  --bg-bottom: #ede2d1;
  --bg-glow-1: rgba(230, 120, 62, 0.18);
  --bg-glow-2: rgba(45, 118, 124, 0.16);
  --panel: rgba(255, 249, 241, 0.82);
  --panel-strong: rgba(255, 251, 246, 0.92);
  --text: #17202a;
  --muted: #5e6a73;
  --line: rgba(23, 32, 42, 0.11);
  --brand: #2d767c;
  --brand-dark: #1c545b;
  --accent: #e6783e;
  --accent-soft: rgba(230, 120, 62, 0.16);
  --shadow: 0 20px 56px rgba(28, 38, 44, 0.13);
  --shell: min(1360px, calc(100% - 24px));
  --header-bg: rgba(246, 239, 227, 0.82);
  --focus: rgba(45, 118, 124, 0.28);
  --pill: rgba(23, 32, 42, 0.06);
  --pill-hover: rgba(23, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: none;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-glow-1), transparent 30%),
    radial-gradient(circle at 88% 14%, var(--bg-glow-2), transparent 24%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 50%, var(--bg-bottom) 100%);
}

a {
  color: inherit;
}

button,
kbd {
  font: inherit;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55em;
  padding: 0.12em 0.38em;
  border-radius: 0.45em;
  border: 1px solid rgba(23, 32, 42, 0.14);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.site-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  backdrop-filter: blur(18px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}

.site-nav,
.wrap,
.game-footer {
  width: 100%;
}

.site-nav,
.wrap > * ,
.game-footer {
  padding-inline: max(12px, calc((100vw - var(--shell)) / 2));
}

.site-nav {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.site-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand) 0%, #53a4ad 100%);
  position: relative;
  box-shadow: 0 10px 24px rgba(45, 118, 124, 0.24);
}

.site-brand-mark::before,
.site-brand-mark::after {
  content: "";
  position: absolute;
  border-radius: 8px;
}

.site-brand-mark::before {
  inset: 8px 18px 18px 8px;
  background: rgba(255, 255, 255, 0.92);
}

.site-brand-mark::after {
  inset: 18px 8px 8px 18px;
  background: rgba(230, 120, 62, 0.95);
}

.site-brand-label,
.eyebrow,
.panel-label {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
}

.site-brand-name {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.site-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.site-links a,
.mini-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--muted);
  background: var(--pill);
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.mini-link {
  cursor: pointer;
}

.site-links a,
.mini-link,
.btn,
.pad-btn {
  touch-action: manipulation;
}

.site-links a:hover,
.mini-link:hover,
.site-links a:focus-visible,
.mini-link:focus-visible,
.btn:hover,
.btn:focus-visible,
.pad-btn:hover,
.pad-btn:focus-visible {
  background: var(--pill-hover);
  outline: none;
}

.wrap {
  width: 100%;
  flex: 1;
  padding-top: 14px;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

.hero,
.board-card,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 16px;
}

.hero-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 18px;
  align-items: stretch;
}

.hero-copy,
.hero-panel {
  background: var(--panel-strong);
  border: 1px solid rgba(23, 32, 42, 0.06);
  border-radius: 24px;
  padding: 22px;
}

.game-name {
  margin: 8px 0 0;
  font-size: clamp(2.1rem, 4vw, 4rem);
  letter-spacing: -0.04em;
}

.intro-help {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
  max-width: 60ch;
}

.intro-help-small {
  margin-top: 10px;
}

.hero-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  background: rgba(45, 118, 124, 0.1);
  color: var(--brand-dark);
}

.hero-chip-accent {
  background: rgba(230, 120, 62, 0.14);
  color: #7f3c18;
}

.hero-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-label {
  margin: 0;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hud-item {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 32, 42, 0.08);
}

.hud-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.hud-value {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn,
.pad-btn {
  border: 0;
  border-radius: 18px;
  padding: 12px 16px;
  background: rgba(23, 32, 42, 0.08);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.btn:active,
.pad-btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-strong {
  background: linear-gradient(135deg, var(--brand) 0%, #409ca2 100%);
  color: white;
  box-shadow: 0 12px 28px rgba(45, 118, 124, 0.22);
}

.btn[data-active="true"] {
  background: rgba(230, 120, 62, 0.16);
  color: #7f3c18;
  box-shadow: 0 10px 24px rgba(230, 120, 62, 0.14);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.78fr);
  gap: 22px;
  align-items: start;
  margin-top: 22px;
}

.board-card,
.panel {
  padding: 16px;
}

.canvas-shell {
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 16%, rgba(95, 192, 206, 0.24), transparent 34%),
    radial-gradient(circle at 82% 12%, rgba(255, 171, 121, 0.22), transparent 22%),
    linear-gradient(180deg, #fef7ee 0%, #f5ead9 100%);
  padding: 14px;
  border: 1px solid rgba(23, 32, 42, 0.08);
}

#game {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  touch-action: none;
  user-select: none;
}

.stage-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stage-hud {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stage-hud-item {
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 32, 42, 0.08);
}

.stage-hud-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.stage-hud-value {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.stage-btn {
  min-height: 52px;
}

.status {
  margin-top: 14px;
  min-height: 1.5em;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
}

.side-stack {
  display: grid;
  gap: 18px;
}

.side-title {
  margin: 10px 0 0;
  font-size: 1.75rem;
  letter-spacing: -0.04em;
}

.mutator-copy,
.controls-text {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}

.meta-item {
  margin: 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 32, 42, 0.08);
}

.meta-item dt {
  font-size: 12px;
  color: var(--muted);
}

.meta-item dd {
  margin: 8px 0 0;
  font-size: 1rem;
  font-weight: 800;
}

.dpad {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.dpad-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.pad-btn-up {
  justify-self: center;
  width: min(180px, 100%);
}

.pad-btn {
  min-height: 56px;
  background: linear-gradient(180deg, rgba(23, 32, 42, 0.08), rgba(23, 32, 42, 0.12));
}

.notes-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.game-footer {
  margin-top: 22px;
  padding-top: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid rgba(23, 32, 42, 0.08);
  color: var(--muted);
}

.game-footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

body[data-display-mode="standalone"] .game-footer {
  display: none;
}

body[data-display-mode="standalone"] [data-install-button] {
  display: none;
}

body[data-display-mode="standalone"] .site-nav {
  padding-top: calc(8px + env(safe-area-inset-top));
}

body[data-display-mode="standalone"] .wrap {
  padding-top: 10px;
}

body[data-display-mode="standalone"] .stage-grid {
  margin-top: 12px;
}

body[data-display-mode="standalone"] .hero-copy,
body[data-display-mode="standalone"] .side-stack {
  display: none;
}

@media (max-width: 1080px) {
  .hero-shell,
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .board-card {
    order: -1;
  }
}

@media (max-width: 820px) {
  .wrap {
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  .stage-grid {
    order: 1;
    margin-top: 0;
  }

  .hero {
    order: 2;
  }

  .game-footer {
    order: 3;
  }

  .hero-copy,
  .side-stack {
    display: none;
  }

  .stage-hud {
    display: grid;
  }
}

@media (max-width: 720px) {
  .site-nav {
    min-height: auto;
    align-items: center;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 10px;
  }

  .site-brand {
    gap: 10px;
    min-width: 0;
  }

  .site-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .site-brand-label {
    display: none;
  }

  .site-brand-name {
    font-size: 16px;
    white-space: nowrap;
  }

  .site-links {
    min-width: 0;
    flex: 1;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .site-links::-webkit-scrollbar {
    display: none;
  }

  .site-links a,
  .mini-link {
    width: auto;
    flex: 0 0 auto;
    padding: 9px 12px;
    font-size: 13px;
  }

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

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

  .stage-btn {
    min-height: 48px;
    padding: 10px 12px;
  }

  .game-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
