*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0a0c0f;
  --bg-soft: #0f1217;
  --panel: #14181f;
  --panel-2: #1a1f28;
  --ink: #e9eef5;
  --muted: #8e9bb0;
  --muted-2: #7f8ca2;
  --line: #27303c;
  --line-bright: #3b4759;
  --accent: #78e08a;
  --accent-2: #5fe3d3;
  --accent-ink: #09210e;
  --gold: #ffd166;
  --orange: #ff9f43;
  --danger: #ff6b6b;
  --font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;
  --radius: 3px;
  --panel-shadow: 6px 6px 0 rgba(0, 0, 0, 0.32);
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 15% -10%, rgba(120, 224, 138, 0.055), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(95, 227, 211, 0.045), transparent 55%),
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  padding: 0 16px;
}

.app {
  width: 100%;
  max-width: 1080px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  transform: rotate(-2deg);
}

.brand-mark i {
  display: block;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
}

.brand-mark i:nth-child(1) {
  background: #78e08a;
}

.brand-mark i:nth-child(2) {
  background: #5fe3d3;
}

.brand-mark i:nth-child(3) {
  background: #ffd166;
}

.brand-mark i:nth-child(4) {
  background: #ff7b72;
}

.brand-word {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
}

.brand-word span {
  color: var(--accent);
}

.brand:hover .brand-word span {
  color: var(--accent-2);
}

.hud {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  background: rgba(20, 24, 31, 0.7);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.22);
}

.hud-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 82px;
  padding: 7px 14px;
  border-right: 1px solid var(--line);
  line-height: 1.08;
}

.hud-label {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hud-value {
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.hud-sub {
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.hud-sub b {
  color: var(--muted);
  font-weight: 600;
}

.lives {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.life-heart {
  width: 14px;
  height: 14px;
  fill: var(--accent);
  filter: drop-shadow(0 0 9px rgba(120, 224, 138, 0.28));
  transition: fill 0.2s ease, filter 0.2s ease, transform 0.2s ease;
}

.life-heart.is-lost {
  fill: #2a313c;
  filter: none;
  transform: scale(0.82);
}

.lives[data-lives="2"] .life-heart:not(.is-lost) {
  fill: var(--orange);
  filter: drop-shadow(0 0 9px rgba(255, 159, 67, 0.32));
}

.lives[data-lives="1"] .life-heart:not(.is-lost) {
  fill: var(--danger);
  filter: drop-shadow(0 0 9px rgba(255, 107, 107, 0.36));
}

.hud > .icon-button {
  border-left: 1px solid var(--line);
}

.sound-button span {
  position: relative;
  display: inline-block;
  line-height: 1;
}

.sound-button.is-muted {
  color: var(--muted-2);
}

.sound-button.is-muted span::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  height: 1px;
  background: currentColor;
  transform: rotate(-45deg);
}

.icon-button {
  appearance: none;
  width: 44px;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  background: var(--panel-2);
  color: var(--ink);
}

.noscript {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--danger);
  background: rgba(255, 107, 107, 0.08);
  color: #ffb0a8;
  font-size: 12px;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  gap: 22px;
  align-items: start;
  flex: 1;
}

.side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.house-rail {
  display: none;
}

.house-mobile {
  display: block;
}

.house-rail,
.house-mobile,
.house-note {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.28);
}

.house-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 13px 30px 13px 13px;
}

.house-rail .house-body {
  padding: 14px 30px 14px 14px;
}

.house-mobile .house-body {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 12px 40px 12px 14px;
}

.house-label {
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.house-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.house-rail .house-copy {
  font-size: 11px;
}

.house-mobile .house-copy {
  flex: 1 1 220px;
}

.house-link {
  color: var(--accent-2);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.house-link:hover {
  color: var(--accent);
}

.house-dismiss {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.house-dismiss:hover,
.house-dismiss:focus-visible {
  color: var(--ink);
  border-color: var(--line-bright);
}

.house-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 34px 14px 14px;
}

.house-note-lead {
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.house-note-line {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.house-note--rail {
  display: none;
}

.house-note--mobile {
  display: flex;
}

@media (min-width: 1720px) {
  .page-shell.has-house-rails {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1440px) minmax(0, 1fr);
    align-items: start;
  }

  .page-shell.has-house-rails .app {
    grid-column: 2;
  }

  .page-shell.has-house-rails .house-rail {
    display: block;
    position: fixed;
    top: 50%;
    width: calc((100vw - 1440px) / 2 - 20px);
    min-width: 0;
    transform: translateY(-50%);
  }

  .page-shell.has-house-rails .house-rail--left {
    left: 10px;
  }

  .page-shell.has-house-rails .house-rail--right {
    right: 10px;
  }

  .page-shell.has-house-rails .house-rail .house-body {
    padding-right: 24px;
  }

  .page-shell.has-house-rails .house-rail .house-copy,
  .page-shell.has-house-rails .house-note--rail .house-note-line {
    overflow-wrap: anywhere;
  }

  .page-shell.has-house-rails .house-note--rail {
    display: flex;
    position: fixed;
    top: 50%;
    width: calc((100vw - 1440px) / 2 - 20px);
    min-width: 0;
    transform: translateY(-50%);
  }

  .page-shell.has-house-rails .house-note--rail[data-side="left"] {
    left: 10px;
  }

  .page-shell.has-house-rails .house-note--rail[data-side="right"] {
    right: 10px;
  }

  .house-mobile {
    display: none !important;
  }

  .house-note--mobile {
    display: none !important;
  }
}

@media (min-width: 1720px) and (max-width: 1799px) {
  .page-shell.has-house-rails .house-rail .house-body,
  .page-shell.has-house-rails .house-note--rail {
    padding-left: 10px;
    padding-right: 12px;
  }

  .page-shell.has-house-rails .house-rail .house-copy,
  .page-shell.has-house-rails .house-note--rail .house-note-line {
    font-size: 10px;
  }
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--panel-shadow);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
  pointer-events: none;
}

.stage {
  min-width: 0;
  padding: 22px;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.stage-meta {
  margin: 0;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.item-name {
  margin: 10px 0 16px;
  color: var(--ink);
  font-size: clamp(24px, 3.4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.05;
  text-wrap: balance;
}

.item-frame {
  position: relative;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 2px solid var(--line-bright);
  background-color: #0c1015;
  background-image:
    linear-gradient(45deg, #111720 25%, transparent 25%),
    linear-gradient(-45deg, #111720 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #111720 75%),
    linear-gradient(-45deg, transparent 75%, #111720 75%);
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  background-size: 28px 28px;
  box-shadow:
    inset 0 0 0 6px rgba(0, 0, 0, 0.18),
    0 18px 40px rgba(0, 0, 0, 0.28);
}

.item-glow {
  position: absolute;
  inset: 14%;
  z-index: 0;
  background: radial-gradient(circle, rgba(120, 224, 138, 0.09), transparent 66%);
  filter: blur(10px);
  pointer-events: none;
}

.item-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: 8%;
  object-fit: contain;
  pointer-events: none;
  transition: opacity 0.42s ease, filter 0.42s ease;
}

.item-image--color {
  z-index: 1;
  opacity: 0;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.35));
}

.item-frame.is-revealed .item-image--color {
  opacity: 1;
}

.item-image--gray {
  z-index: 2;
  opacity: 1;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.32));
}

.item-frame.is-revealed .item-image--gray {
  opacity: 0;
}

.item-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  color: #2c3542;
  font-size: 64px;
  font-weight: 800;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  pointer-events: none;
}

.item-grid {
  position: absolute;
  inset: 10px;
  z-index: 4;
  border: 1px solid rgba(255, 255, 255, 0.045);
  pointer-events: none;
}

.item-frame[data-state="loading"] .item-image,
.item-frame[data-state="error"] .item-image {
  opacity: 0;
}

.item-frame[data-state="loading"] .item-fallback,
.item-frame[data-state="error"] .item-fallback {
  opacity: 1;
}

.item-frame[data-state="error"] .item-fallback {
  color: #6f3b3b;
}

.item-frame[data-state="loading"]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  background: linear-gradient(
    110deg,
    transparent 20%,
    rgba(255, 255, 255, 0.055) 45%,
    transparent 70%
  );
  animation: shimmer 1.4s linear infinite;
  pointer-events: none;
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

.stage-hint {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-align: center;
}

.controls {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-title {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.panel-note {
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.color-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.color-field {
  min-width: 0;
}

.color-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.color-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.weight-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--accent-2);
  font-size: 9px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

.color-value {
  color: var(--muted-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.swatch {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--line-bright);
  background: #080a0e;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.28);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.swatch:hover,
.swatch:focus-within {
  border-color: var(--accent-2);
}

.swatch:focus-within {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.swatch:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.28);
}

.swatch input[type="color"] {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch-fill {
  position: absolute;
  inset: 7px;
  display: block;
  background: #808080;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.swatch-caption {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.55);
  font-size: 8px;
  letter-spacing: 0.16em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  text-transform: uppercase;
  pointer-events: none;
}

.hex-input {
  width: 100%;
  margin-top: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: #0b0e13;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: border-color 0.15s ease;
}

.hex-input:focus {
  border-color: var(--accent-2);
}

.hex-input.is-invalid {
  border-color: var(--danger);
}

.form-error {
  min-height: 18px;
  margin: 12px 0 8px;
  color: var(--danger);
  font-size: 11px;
}

.primary-button {
  appearance: none;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid #9af0a7;
  border-radius: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.primary-button:hover {
  background: #8ef09e;
}

.primary-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-button--ghost {
  margin-top: 8px;
  border-color: var(--line-bright);
  background: transparent;
  color: var(--accent);
  box-shadow: none;
}

.primary-button--ghost:hover {
  background: var(--panel-2);
}

#controls:focus {
  outline: none;
}

.reveal {
  padding: 20px;
  overflow: hidden;
}

.reveal::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.reveal.is-hit::after {
  background: linear-gradient(90deg, var(--danger), var(--gold));
}

.reveal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.points {
  padding: 4px 8px;
  border: 1px solid rgba(255, 209, 102, 0.3);
  background: rgba(255, 209, 102, 0.08);
  color: var(--gold);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.reveal-colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.reveal-label {
  margin: 0 0 8px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mini-swatches {
  display: flex;
  gap: 6px;
}

.mini-swatch {
  display: block;
  width: 38px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line-bright);
  background: #080a0e;
}

.mini-swatch span {
  display: block;
  width: 100%;
  height: 100%;
  background: #808080;
}

.reveal-hex {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 16px 0;
}

.meter-row {
  display: grid;
  grid-template-columns: 64px 1fr 38px;
  align-items: center;
  gap: 8px;
}

.meter-label {
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.meter {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0a0d12;
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.meter-row--total .meter {
  height: 10px;
}

.meter-row--total .meter i {
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.meter-value {
  color: var(--ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.reveal-note {
  min-height: 18px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.reveal.is-hit .reveal-note {
  color: #ffb0a8;
}

.dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-bright);
  border-radius: 0;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--ink);
  box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.35);
}

.dialog::backdrop {
  background: rgba(4, 6, 9, 0.72);
  backdrop-filter: blur(5px);
}

.help-dialog {
  padding: 22px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-title {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

.rules li::marker {
  color: var(--accent-2);
  font-weight: 700;
}

.rules strong {
  color: var(--ink);
}

.dialog-foot {
  margin: 0 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
  color: var(--muted-2);
  font-size: 11px;
}

.help-dialog .primary-button {
  margin-top: 4px;
}

.game-over-dialog {
  width: min(440px, calc(100% - 32px));
  border-top: 3px solid var(--accent);
}

.overlay-card {
  padding: 26px;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 22px 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.final-stats > div {
  padding: 12px 10px;
  background: var(--panel);
  text-align: center;
}

.final-stats span {
  display: block;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.final-stats strong {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.final-message {
  min-height: 20px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.overlay-actions .primary-button {
  flex: 1 1 150px;
}

.overlay-actions .primary-button--ghost {
  margin-top: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border: 1px solid var(--line-bright);
  background: #1b222c;
  color: var(--ink);
  font-size: 11px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 10px;
}

.footer p {
  margin: 0;
}

.footer-contact {
  white-space: nowrap;
}

.footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer a:hover {
  color: var(--accent-2);
}

@media (min-width: 1200px) {
  body {
    font-size: 16px;
  }

  .page-shell {
    padding: 0 24px;
  }

  .app {
    max-width: 1440px;
    padding: 30px 0 26px;
    gap: 26px;
  }

  .topbar {
    gap: 24px;
    padding-bottom: 20px;
  }

  .brand {
    gap: 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    gap: 4px;
  }

  .brand-word {
    font-size: 30px;
  }

  .hud-stat {
    min-width: 104px;
    padding: 10px 18px;
  }

  .hud-label,
  .hud-sub {
    font-size: 10px;
  }

  .hud-value {
    font-size: 24px;
  }

  .lives {
    gap: 5px;
    margin-top: 8px;
  }

  .life-heart {
    width: 15px;
    height: 15px;
  }

  .icon-button {
    width: 50px;
    min-height: 50px;
    font-size: 20px;
  }

  .board {
    grid-template-columns: minmax(0, 1.1fr) minmax(430px, 0.9fr);
    gap: 26px;
  }

  .side {
    gap: 20px;
  }

  .stage {
    padding: 28px;
  }

  .stage-head {
    gap: 16px;
  }

  .eyebrow,
  .stage-meta {
    font-size: 11px;
  }

  .item-name {
    margin: 12px 0 20px;
    font-size: clamp(34px, 3.2vw, 46px);
  }

  .item-frame {
    max-width: clamp(430px, calc(100vh - 380px), 560px);
  }

  .stage-hint {
    margin-top: 16px;
    font-size: 14px;
  }

  .controls,
  .reveal {
    padding: 26px;
  }

  .panel-head {
    margin-bottom: 18px;
  }

  .panel-title {
    font-size: 22px;
  }

  .panel-note {
    font-size: 10px;
  }

  .color-fields {
    gap: 16px;
  }

  .color-field-head {
    margin-bottom: 10px;
  }

  .color-label {
    font-size: 12px;
  }

  .weight-badge {
    padding: 2px 5px;
    font-size: 10px;
  }

  .color-value {
    font-size: 11px;
  }

  .swatch-fill {
    inset: 9px;
  }

  .swatch-caption {
    right: 12px;
    bottom: 10px;
    font-size: 9px;
  }

  .hex-input {
    margin-top: 10px;
    padding: 10px 11px;
    font-size: 14px;
  }

  .form-error {
    margin: 14px 0 10px;
    font-size: 13px;
  }

  .primary-button {
    padding: 15px 18px;
    font-size: 14px;
  }

  .reveal-head {
    margin-bottom: 18px;
  }

  .points {
    padding: 5px 10px;
    font-size: 24px;
  }

  .reveal-colors {
    gap: 16px;
    padding: 16px 0 18px;
  }

  .reveal-label {
    margin-bottom: 10px;
    font-size: 10px;
  }

  .mini-swatch {
    width: 46px;
    height: 46px;
  }

  .reveal-hex {
    margin-top: 10px;
    font-size: 11px;
  }

  .meters {
    gap: 11px;
    margin: 18px 0;
  }

  .meter-row {
    grid-template-columns: 78px 1fr 44px;
    gap: 10px;
  }

  .meter-label {
    font-size: 10px;
  }

  .meter {
    height: 10px;
  }

  .meter-row--total .meter {
    height: 12px;
  }

  .meter-value {
    font-size: 12px;
  }

  .reveal-note {
    margin-bottom: 16px;
    font-size: 14px;
  }

  .dialog {
    width: min(600px, calc(100% - 48px));
  }

  .help-dialog {
    padding: 26px;
  }

  .dialog-title {
    font-size: 30px;
  }

  .rules {
    gap: 14px;
    margin: 24px 0;
    font-size: 15px;
  }

  .dialog-foot {
    padding: 14px;
    font-size: 12px;
  }

  .game-over-dialog {
    width: min(500px, calc(100% - 48px));
  }

  .overlay-card {
    padding: 30px;
  }

  .final-stats {
    margin: 26px 0;
  }

  .final-stats > div {
    padding: 14px 12px;
  }

  .final-stats span {
    font-size: 10px;
  }

  .final-stats strong {
    font-size: 26px;
  }

  .final-message {
    font-size: 15px;
  }

  .footer {
    gap: 14px;
    padding-top: 20px;
    font-size: 11px;
  }

  .toast {
    bottom: 30px;
    padding: 12px 16px;
    font-size: 13px;
  }
}

@media (max-width: 860px) {
  .page-shell {
    padding: 0 12px;
  }

  .app {
    max-width: 720px;
    padding-top: 16px;
  }

  .board {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .stage {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
  }

  .side {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
  }

  .item-frame {
    max-width: 420px;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .hud {
    width: 100%;
    justify-content: flex-end;
  }

  .hud-stat:first-child {
    margin-right: auto;
  }
}

@media (max-width: 560px) {
  .page-shell {
    padding: 0 10px;
  }

  .app {
    max-width: none;
    gap: 16px;
  }

  .topbar {
    gap: 12px;
  }

  .brand-word {
    font-size: 21px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
  }

  .hud {
    flex-wrap: wrap;
  }

  .hud-stat {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
  }

  .hud-stat .hud-sub {
    display: none;
  }

  .hud > .icon-button {
    width: 40px;
    min-height: 40px;
  }

  .stage,
  .controls,
  .reveal {
    padding: 16px;
  }

  .item-name {
    font-size: 26px;
  }

  .color-fields {
    gap: 10px;
  }

  .color-field-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .meter-row {
    grid-template-columns: 56px 1fr 36px;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
