:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  background: #090b12;
  color: #f2f4f8;
  --page: #090b12;
  --panel: #121722;
  --line: #31384a;
  --muted: #b7c0d4;
  --acid: #c6f26a;
  --acid-ink: #14200b;
  --pink: #ff8eae;
  --food: #ffbe78;
  --mono: "Cascadia Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-width: 20rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 8% 0%, rgb(88 112 160 / 16%), transparent 28rem),
    var(--page);
}

body.splash-open { overflow: hidden; }

button, input { font: inherit; }

button {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 3px;
}

.brand-mark {
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  border: 1px solid rgb(198 242 106 / 45%);
  border-radius: 0.45rem;
  transform: rotate(-8deg);
}

.brand-mark i {
  width: 0.22rem;
  height: 0.72rem;
  border-radius: 0.2rem;
  background: var(--acid);
}

.brand-mark i:nth-child(2) { height: 1rem; }

.app {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(0.35rem, env(safe-area-inset-top))
    max(0.55rem, env(safe-area-inset-right))
    max(0.35rem, env(safe-area-inset-bottom))
    max(0.55rem, env(safe-area-inset-left));
}

.topbar {
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.topbar h1 {
  margin: 0;
  color: inherit;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-transform: none;
  white-space: nowrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-decoration: none;
}

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

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.play {
  display: flex;
  justify-content: center;
  min-height: 0;
}

.eyebrow,
.kicker {
  margin: 0;
  color: var(--acid);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

.status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.15rem;
  margin: 0.1rem 0 0.2rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status[data-tone="warning"] { color: var(--food); }
.status[data-tone="good"] { color: var(--acid); }

#runStateLabel {
  color: var(--acid);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.thinking {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0.6rem rgb(198 242 106 / 80%);
}

.board-wrap {
  position: relative;
  width: min(100%, calc(100dvh - 8rem));
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: #0b0f17;
  line-height: 0;
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.board-wrap.is-running #board { cursor: crosshair; }

.board-overlay {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgb(7 9 14 / 62%);
}

.board-overlay.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  width: min(18rem, 100%);
  padding: 1rem;
  border: 1px solid rgb(198 242 106 / 35%);
  border-radius: 0.85rem;
  background: rgb(12 15 23 / 94%);
  text-align: center;
}

.overlay-card h2 {
  margin: 0.3rem 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.overlay-card h2:focus { outline: none; }

.overlay-card p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.meters {
  display: flex;
  gap: 0.75rem;
  margin: 0 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meters span { white-space: nowrap; }

.meters strong {
  color: var(--acid);
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

.dock {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
  padding-top: 0.45rem;
}

.primary,
.ghost,
.bomb-button {
  min-height: 2.75rem;
  border-radius: 0.7rem;
  cursor: pointer;
}

.primary {
  border: 1px solid var(--acid);
  background: var(--acid);
  color: var(--acid-ink);
  font-weight: 700;
}

.ghost,
.bomb-button {
  border: 1px solid var(--line);
  background: #151a26;
  color: #e7ebf4;
}

.bomb-button:disabled,
.primary:disabled {
  cursor: default;
  opacity: 0.62;
}

.primary,
.reset,
.ghost { padding-inline: 0.85rem; }

.bomb-meter { min-width: 0; }

.bomb-meter strong {
  display: block;
  overflow: hidden;
  color: var(--food);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track {
  height: 0.28rem;
  overflow: hidden;
  margin-top: 0.28rem;
  border-radius: 1rem;
  background: #302b32;
}

.track span {
  width: 0;
  height: 100%;
  display: block;
  background: linear-gradient(90deg, #d28b4d, var(--pink));
}

.bomb-button { min-width: 6.2rem; padding-inline: 0.7rem; }

.toast {
  position: absolute;
  z-index: 4;
  right: 0.55rem;
  bottom: 0.45rem;
  left: 0.55rem;
  margin: 0;
  color: var(--pink);
  font-size: 0.82rem;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 2px rgb(0 0 0 / 80%);
}

.toast:empty { display: none; }

dialog {
  width: min(36rem, calc(100vw - 1.25rem));
  max-height: min(92dvh, 44rem);
  margin: auto;
  padding: 1.1rem 1rem 1rem;
  overflow: auto;
  border: 1px solid #3c4458;
  border-radius: 1rem;
  background: linear-gradient(160deg, #171c29, #0e121b 70%);
  color: inherit;
}

dialog::backdrop { background: rgb(7 9 15 / 86%); }

dialog h2 {
  margin: 0.4rem 0 0.6rem;
  font-size: clamp(2rem, 10vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -0.06em;
  line-height: 0.95;
}

dialog h2 span { color: var(--acid); }

.kicker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lede {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.rules {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.rules li {
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
}

.rules strong,
.rules span { display: block; }

.rules span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

dialog .primary { width: 100%; }

@media (min-width: 40rem) {
  .rules { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar h1 { font-size: 1.05rem; }
}

@media (max-width: 24rem) {
  .topbar h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .meters { gap: 0.45rem; }
}

@media (prefers-reduced-motion: reduce) {
  .thinking { box-shadow: none; }
}
