:root {
  --bg: #0b0d12; --panel: #141821; --panel-2: #1b2030; --text: #eef0f6; --muted: #9aa2b8; --line: #2a3145;
  --accent: #7cf0c5; --accent-ink: #062018; --bad: #ff7a7a; --good: #7cf0c5; --star: #ffd166;
  --name: #ffffff; --count: #7cc7ff; --object: #ffb86b; --place: #a6e3a1; --inject: #ff6b8a;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Every game: a way back to the others, and who's signed in. */
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.bar .home { color: var(--muted); text-decoration: none; }
.bar .home:hover { color: var(--text); }
.bar .account { color: var(--muted); text-align: right; }
.bar .account strong { color: var(--text); }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { font-size: clamp(30px, 7vw, 44px); margin: 4px 0 12px; letter-spacing: -0.02em; }
h1::after { content: "_"; color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
h2 { font-size: 16px; margin: 0; }

button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stats > div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stats .label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stats strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.meter { height: 5px; background: var(--line); border-radius: 3px; margin-top: 5px; overflow: hidden; }
#meter-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s, background 0.25s; }
#meter-fill.full { background: var(--bad); }
#compute { letter-spacing: 2px; color: var(--accent); }
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

.incoming {
  min-height: 92px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 12px;
}
.incoming .kind { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 6px; }
.incoming .msg { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; margin: 0; font-size: 15px; line-height: 1.5; }
.incoming .said { margin: 8px 0 0; }
.incoming .verdict { font-weight: 700; }
.incoming.good { border-color: var(--good); }
.incoming.bad { border-color: var(--bad); }
.incoming .fell { color: var(--bad); font-size: 13px; margin: 8px 0 0; }
.hint { color: var(--muted); margin: 0; }
.good { color: var(--good); }
.bad { color: var(--bad); }

.window { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.window-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.window-head .tip { color: var(--muted); font-size: 13px; }
#lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#lines li {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid transparent; transition: border-color 0.3s, background 0.3s;
}
#lines li.used { border-color: var(--accent); }
#lines li.used.badline { border-color: var(--bad); }
#lines li.injection { background: #2a1520; }
#lines li.fresh { animation: arrive 0.35s ease-out; }
@keyframes arrive { from { transform: translateY(8px); opacity: 0; } }
.star { color: var(--star); width: 1em; flex: none; padding-top: 3px; }
.tokens { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.tok {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px;
  padding: 2px 6px; border-radius: 5px; background: #222839; border: 1px solid #2f3750; color: var(--text);
}
.tok:hover { text-decoration: line-through; border-color: var(--bad); }
.tok.filler { color: var(--muted); font-style: italic; }
.tok.name { font-weight: 800; color: var(--name); }
.tok.count { color: var(--count); }
.tok.object { color: var(--object); }
.tok.place { color: var(--place); }
.tok.color { font-weight: 700; }
.tok.hedge { color: var(--star); border-style: dashed; }
.tok.inject { color: var(--inject); }
.tok.command { color: #fff; background: var(--inject); border-color: var(--inject); font-weight: 800; }
.actions { display: flex; gap: 4px; flex: none; }
.actions button { padding: 2px 8px; font-size: 14px; min-width: 32px; }
.empty { color: var(--muted); margin: 6px 0 2px; font-style: italic; }

.controls { display: flex; justify-content: center; margin: 16px 0; }
.controls .primary { font-size: 18px; padding: 12px 24px; width: min(100%, 360px); }

.log summary { cursor: pointer; color: var(--muted); }
.log ol { padding-left: 20px; }
.log li { margin: 6px 0; font-size: 14px; }

dialog {
  max-width: 560px; width: calc(100% - 32px); background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 20px;
}
dialog::backdrop { background: rgba(5, 6, 10, 0.75); }
dialog h2 { font-size: 24px; margin-bottom: 8px; }
dialog .lede { line-height: 1.5; }
dialog ul { padding-left: 18px; line-height: 1.5; }
dialog table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
dialog td { padding: 4px 0; border-bottom: 1px solid var(--line); }
dialog td:last-child { text-align: right; white-space: nowrap; padding-left: 8px; font-weight: 700; }
dialog form { margin-top: 12px; text-align: right; }
.key { font-family: ui-monospace, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.cmd { background: var(--inject); color: #fff; padding: 0 4px; border-radius: 4px; font-family: ui-monospace, monospace; }
.small { color: var(--muted); font-size: 14px; }
.big { font-size: 32px; font-weight: 800; margin: 4px 0 12px; }
.breakdown { list-style: none; padding: 0; }
.breakdown li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 4px 0; }
.end-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
