:root {
  --bg: #141414;
  --rail: #101010;
  --panel: #1C1C1C;
  --elevated: #262626;
  --yellow: #F5C518;
  --amber: #FF9F1C;
  --amber-pressed: #C46A00;
  --cyan: #3DE0FF;
  --white: #FFFFFF;
  --wrong: #FF4D2E;
  --dim: #B7B7B7;
  --black: #000000;
  --scrim: rgba(16, 16, 16, 0.82);
  --black-face: "Arial Black", "Segoe UI", Impact, sans-serif;
  --cond: "Arial Narrow", "Segoe UI", sans-serif;
  --ui: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #000;
  color: var(--white);
  font-family: var(--ui);
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.stage {
  width: min(440px, 100%);
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.screen {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.home {
  flex-direction: row;
  padding: 0;
}
.sub { padding-left: 12px; padding-right: 12px; }
.scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 16px;
}

.label {
  margin: 0;
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.label.brand { color: var(--yellow); margin-top: 4px; }
.label.amber, .amber { color: var(--amber); }
.label.gap { margin-top: 12px; }
.gold { color: var(--yellow); }

.cut {
  --stroke: var(--yellow);
  --fill: var(--panel);
  background: var(--stroke);
  color: inherit;
  border: 0;
  padding: 2px;
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
}
.cut > .fill {
  background: var(--fill);
  clip-path: inherit;
  min-height: 44px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stroke-yellow { --stroke: var(--yellow); }
.stroke-amber { --stroke: var(--amber); }
.stroke-white { --stroke: var(--white); }
.stroke-cyan { --stroke: var(--cyan); }
.stroke-dim { --stroke: var(--elevated); }
.stroke-red { --stroke: var(--wrong); }
.slant {
  clip-path: polygon(14px 0, calc(100% - 14px) 8px, 100% 20px, 100% calc(100% - 12px), calc(100% - 14px) 100%, 14px calc(100% - 8px), 0 calc(100% - 20px), 0 12px);
}
.slant-lg {
  clip-path: polygon(16px 0, calc(100% - 16px) 10px, 100% 26px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px calc(100% - 10px), 0 calc(100% - 26px), 0 16px);
}

.solid {
  border: 0;
  background: var(--yellow);
  color: var(--black);
  min-height: 52px;
  padding: 0 16px;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
}
.solid:active { background: var(--amber-pressed); }
.solid.alert { background: var(--wrong); color: var(--white); }
.solid.slim { min-height: 44px; height: 44px; width: auto; font-size: 12px; flex: none; }
.solid.dock { width: calc(100% - 0px); margin: 0 0 16px; flex: none; }

.rail {
  width: 56px;
  flex: none;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  overflow-y: auto;
}
.rail-btn {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--white);
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
}
.rail-btn svg { width: 24px; height: 24px; display: block; }
.rail-btn svg path { fill: currentColor; }
.rail-btn svg path.line { fill: none; stroke: currentColor; stroke-width: 2; }
.rail-btn.on { color: var(--yellow); }
.rail-mark {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--yellow);
}

.dash {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 10px calc(8px + env(safe-area-inset-bottom));
  padding-top: calc(4px + env(safe-area-inset-top));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.octs {
  display: flex;
  gap: 6px;
  height: 78px;
  margin-top: 6px;
  flex: none;
}
.oct { flex: 1; min-width: 0; }
.oct .fill { flex-direction: column; gap: 0; padding: 4px; }
.oct b {
  font-family: var(--black-face);
  font-size: clamp(22px, 7vw, 34px);
  line-height: 1;
  font-weight: 900;
  max-width: 100%;
  overflow: hidden;
}

.energy {
  position: relative;
  flex: 1 1 150px;
  min-height: 150px;
  margin: 8px 0;
  display: grid;
  place-items: center;
}
.energy svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hero-play {
  position: relative;
  z-index: 1;
  width: 200px;
  height: 64px;
  min-height: 64px;
  font-size: 18px;
}
.hero-play.pulse { animation: tap 160ms ease; }
@keyframes tap {
  50% { transform: scale(1.06); }
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  flex: none;
}
.mode-chip { min-height: 58px; width: 100%; }
.mode-chip .fill { min-height: 54px; flex-direction: column; gap: 0; }
.mode-chip b {
  font-family: var(--black-face);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 900;
}
.pulse-chip b { font-size: 13px; }
.banner { width: 100%; margin-top: 8px; flex: none; text-align: left; }
.banner .fill { min-height: 48px; justify-content: space-between; padding: 0 14px; }
.banner b {
  font-family: var(--black-face);
  color: var(--amber);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 14px;
}
.mini-stats, .empty-bar { margin-top: 8px; margin-bottom: 8px; flex: none; height: 64px; }
.mini-stats .fill { display: grid; grid-template-columns: repeat(4, 1fr); }
.mini-stats .fill > div { text-align: center; }
.mini-stats b { display: block; font-family: var(--black-face); font-size: 18px; }
.empty-bar .fill { justify-content: space-between; padding: 0 8px 0 12px; gap: 8px; }
.empty-bar .fill > span {
  font-family: var(--black-face);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
}

.topbar {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar h1 {
  margin: 0;
  flex: 1;
  font-family: var(--black-face);
  font-size: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 900;
}
.back {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: 0;
  background: transparent;
  padding: 12px;
  display: grid;
  place-items: center;
}
.back svg { width: 24px; height: 24px; }
.back path { fill: none; stroke: var(--yellow); stroke-width: 2.4; stroke-linecap: square; }
.count {
  color: var(--yellow);
  font-family: var(--black-face);
  font-size: 16px;
  margin-right: 4px;
}

.mode-card { width: 100%; margin-top: 8px; text-align: left; }
.mode-card .fill {
  min-height: 74px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 14px;
  gap: 4px;
}
.mode-card b {
  font-family: var(--black-face);
  font-size: 22px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mode-card .fill > span {
  font-family: var(--cond);
  color: var(--dim);
  font-size: 14px;
  line-height: 1.3;
}
.tone-yellow { color: var(--yellow); }
.tone-white { color: var(--white); }
.tone-cyan { color: var(--cyan); }
.tone-amber { color: var(--amber); }

.daily-body { flex: 1; min-height: 0; }
.target {
  margin: 0;
  font-family: var(--black-face);
  font-size: 56px;
  line-height: 0.95;
  font-weight: 900;
}
.status {
  margin: 4px 0 0;
  font-family: var(--black-face);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 16px;
  color: var(--yellow);
}
.mission-copy {
  margin: 16px 0 0;
  font-family: var(--cond);
  color: var(--dim);
  font-size: 16px;
  line-height: 1.35;
}
.amber-rule { display: block; width: 48px; height: 3px; margin-top: 18px; background: var(--amber); }

.play { position: relative; }
.play-col {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 10px 8px;
}
.mission { margin-top: 4px; }
.hud { height: 72px; flex: none; margin-top: 4px; }
.hud .fill { display: grid; grid-template-columns: repeat(4, 1fr); }
.hud .fill > div, .result-row > div { text-align: center; min-width: 0; }
.hud b, .result-row b {
  display: block;
  font-family: var(--black-face);
  font-size: 22px;
  line-height: 1.05;
  font-weight: 900;
}
.hud.hot { animation: warn 300ms steps(2, end) infinite; }
@keyframes warn {
  50% { --stroke: var(--amber-pressed); }
}
.board-slot {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  margin: 8px 0;
}
.board {
  --cols: 4;
  --rows: 4;
  display: grid;
  gap: 8px;
  width: min(100cqw, calc(100cqh * var(--cols) / var(--rows)));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: var(--cols) / var(--rows);
}
.tile {
  --edge: var(--yellow);
  --ink: var(--yellow);
  --face: #121212;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: var(--edge);
  color: var(--ink);
  clip-path: polygon(12% 0, 88% 0, 100% 12%, 100% 88%, 88% 100%, 12% 100%, 0 88%, 0 12%);
}
.tile .face {
  position: absolute;
  inset: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 18%), var(--face);
  clip-path: polygon(12% 0, 88% 0, 100% 12%, 100% 88%, 88% 100%, 12% 100%, 0 88%, 0 12%);
}
.tile .mark { position: relative; z-index: 1; width: 54%; height: 54%; pointer-events: none; }
.tile .mark path, .tile .mark circle { fill: currentColor; }
.tile .mark [fill="none"] { fill: none; }
.tile.matched { opacity: 0.5; }
.game-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.grow { flex: 1; min-width: 0; min-height: 52px; }
.grow .fill {
  min-height: 48px;
  color: var(--yellow);
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 14px;
}
.pips {
  width: 76px;
  height: 52px;
  min-height: 52px;
  min-width: 76px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
}
.pips i {
  width: 12px;
  height: 16px;
  background: var(--yellow);
  clip-path: polygon(28% 0, 100% 0, 72% 100%, 0 100%);
}
.pips i.off { background: var(--elevated); }
.pips:disabled { opacity: 0.4; }

.result {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 4;
}
.result-card { width: min(100%, 400px); }
.result-in {
  flex-direction: column;
  align-items: stretch;
  padding: 18px;
  gap: 0;
  height: auto;
}
.result-in h2 {
  margin: 0;
  color: var(--yellow);
  font-family: var(--black-face);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 22px;
}
.result-in > p {
  margin: 4px 0 0;
  font-family: var(--cond);
  color: var(--dim);
  font-size: 14px;
}
.result-in .label { margin-top: 10px; }
.big {
  font-family: var(--black-face);
  font-size: 52px;
  line-height: 0.95;
  font-weight: 900;
}
.result-row { display: grid; grid-template-columns: repeat(3, 1fr); text-align: left; }
.result-row > div { text-align: left; }
.result-row b { font-size: 20px; }
.stars { display: flex; gap: 6px; width: 120px; height: 28px; margin-top: 8px; }
.stars svg { width: 28px; height: 28px; fill: var(--elevated); }
.stars svg.lit { fill: var(--yellow); }
.result-in .solid, .result-in .cut { width: 100%; margin-top: 8px; }
.result-in .cut .fill {
  color: var(--yellow);
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sum-row, .mode-best {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.mode-best { grid-template-columns: repeat(5, 1fr); margin-top: 4px; }
.sum-row b, .mode-best b {
  display: block;
  font-family: var(--black-face);
  font-weight: 900;
}
.sum-row b { font-size: 28px; line-height: 1.05; }
.mode-best { text-align: center; }
.mode-best b { font-size: 12px; }
.chart {
  height: 150px;
  margin-top: 8px;
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar {
  width: 100%;
  background: rgba(245, 197, 24, 0.7);
  clip-path: polygon(16% 0, 100% 0, 84% 100%, 0 100%);
  min-height: 4px;
}
.bar.last { background: var(--yellow); }
.bar-col span {
  height: 18px;
  font-family: var(--cond);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--dim);
}
.recent { width: 100%; margin-bottom: 6px; text-align: left; }
.recent .fill { justify-content: space-between; padding: 8px 12px; min-height: 52px; }
.recent b {
  display: block;
  font-family: var(--black-face);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 14px;
}
.recent small { color: var(--dim); font-family: var(--cond); font-size: 12px; }
.recent strong { color: var(--yellow); font-family: var(--black-face); font-size: 22px; }
.empty-card { margin-top: 24px; }
.empty-card .fill { flex-direction: column; align-items: stretch; padding: 16px; gap: 6px; height: auto; }
.empty-card b {
  font-family: var(--black-face);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 20px;
}
.empty-card p { margin: 0; font-family: var(--cond); color: var(--dim); font-size: 14px; }
.empty-card .solid { margin-top: 6px; }

.achieve { width: 100%; margin-bottom: 8px; text-align: left; opacity: 0.78; }
.achieve.on { opacity: 1; }
.achieve-row { justify-content: flex-start; gap: 12px; padding: 12px; min-height: 72px; }
.achieve-row > i { width: 4px; height: 36px; background: var(--elevated); flex: none; }
.achieve.on .achieve-row > i { background: var(--yellow); }
.achieve-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.achieve-copy b {
  font-family: var(--black-face);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 15px;
}
.achieve-copy small { color: var(--dim); font-family: var(--cond); font-size: 13px; }
.achieve em {
  font-style: normal;
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.achieve em.on { color: var(--yellow); }

.theme-card { width: 100%; margin-top: 10px; text-align: left; }
.theme-card:first-child { margin-top: 8px; }
.theme-card .fill { flex-direction: column; align-items: stretch; padding: 12px; gap: 0; height: auto; }
.theme-card b {
  margin-top: 8px;
  font-family: var(--black-face);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 16px;
}
.theme-state {
  margin-top: 2px;
  font-style: normal;
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.theme-card.on .theme-state, .theme-card.stroke-yellow .theme-state { color: var(--yellow); }
.swatch { height: 72px; position: relative; }
.swatch i {
  position: absolute;
  top: 7%;
  width: 52px;
  height: 86%;
  background: var(--edge);
  clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%);
}
.swatch i::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--shade);
  clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%);
}
.swatch .back { left: 18%; --shade: var(--back); }
.swatch .front { left: 40%; --shade: var(--face); }
.swatch .front::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 36%;
  top: 16%;
  width: 28%;
  height: 68%;
  background: var(--edge);
  clip-path: polygon(70% 0, 10% 52%, 48% 52%, 28% 100%, 95% 38%, 52% 38%);
}
.s0 { --back: #121212; --face: #1A1A1A; --edge: #F5C518; }
.s1 { --back: #140E09; --face: #22180F; --edge: #FF9F1C; }
.s2 { --back: #0A1016; --face: #101820; --edge: #3DE0FF; }

.setting { width: 100%; margin-top: 8px; }
.setting .fill { justify-content: space-between; padding: 12px; min-height: 64px; gap: 12px; }
.toggle { cursor: pointer; }
.toggle b {
  display: block;
  font-family: var(--black-face);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 15px;
}
.toggle small { display: block; font-family: var(--cond); color: var(--dim); font-size: 13px; }
.toggle input {
  appearance: none;
  width: 52px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  flex: none;
  border-radius: 16px;
  background: var(--elevated);
  position: relative;
}
.toggle input::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--dim);
  top: 4px;
  left: 4px;
}
.toggle input:checked { background: var(--yellow); }
.toggle input:checked::after { background: var(--black); left: 24px; }
.hint-copy { margin: 2px 0 0; font-family: var(--cond); color: var(--dim); font-size: 13px; }
.diff-row { display: flex; gap: 6px; margin-top: 8px; }
.diff {
  flex: 1;
  min-height: 52px;
  padding: 2px;
  border: 0;
  background: var(--yellow);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
}
.diff span {
  display: grid;
  place-items: center;
  min-height: 48px;
  background: var(--panel);
  color: var(--yellow);
  clip-path: inherit;
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 14px;
}
.diff.on { padding: 0; }
.diff.on span { background: var(--yellow); color: var(--black); }
.reset, .stack { width: 100%; margin-top: 8px; min-height: 52px; }
.reset { margin-top: 18px; }
.reset .fill, .stack .fill {
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 14px;
  color: var(--yellow);
}
.reset .fill { color: var(--wrong); }

.splash { position: relative; justify-content: flex-end; background: var(--bg); }
.splash-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.splash-brand {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 24px 28px;
}
.splash-brand strong {
  display: block;
  font-family: var(--black-face);
  font-size: 22px;
  letter-spacing: 0.12em;
  font-weight: 900;
}

.modal {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 8;
}
.sheet {
  width: min(92vw, 400px);
  background: var(--yellow);
  padding: 2px;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
}
.sheet-in {
  background: var(--panel);
  clip-path: inherit;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sheet-in h2 {
  margin: 0;
  color: var(--yellow);
  font-family: var(--black-face);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 22px;
}
.sheet-in p {
  margin: 0;
  font-family: var(--cond);
  color: var(--dim);
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-line;
}
.sheet-in .solid, .sheet-in .cut { width: 100%; margin-top: 8px; }
.sheet-in .cut .fill {
  color: var(--yellow);
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 48px;
}

@media (max-width: 360px) {
  .hero-play { width: min(200px, 86%); font-size: 16px; }
  .oct b { font-size: 24px; }
  .hud b { font-size: 18px; }
  .target { font-size: 48px; }
}
