/* rstickr. Layout: a laptop lid. Stickers are physical objects and keep their own
   colors in both themes. Play view = rank meter on top, sticker left, R console right. */
@font-face {
  font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-mono.woff2") format("woff2");
}
:root {
  --lid: #D8DBE0; --sheen: rgba(255,255,255,.55); --pane: #F1F2F4; --pane-2: #E5E8EC;
  --ink: #15181D; --muted: #586170; --rule: #C2C7CE;
  --accent: #1F5FAD; --ok: #1A7F37; --err: #B3261E; --warn: #8F5600;
  --paper: #FBFBF8; --sticker-ink: #15181D; --edge: #12305A; --keyfill: #2A6EC4;
  --shadow: rgba(20,24,30,.30);
  --f-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --f-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --lid: #1F2226; --sheen: rgba(255,255,255,.05); --pane: #282C32; --pane-2: #30353C;
  --ink: #E7EAEE; --muted: #9BA4AF; --rule: #3D434B;
  --accent: #82B2EE; --ok: #3FB950; --err: #F08A80; --warn: #E8B062;
  --shadow: rgba(0,0,0,.6); color-scheme: dark } }
:root[data-theme="dark"] {
  --lid: #1F2226; --sheen: rgba(255,255,255,.05); --pane: #282C32; --pane-2: #30353C;
  --ink: #E7EAEE; --muted: #9BA4AF; --rule: #3D434B;
  --accent: #82B2EE; --ok: #3FB950; --err: #F08A80; --warn: #E8B062;
  --shadow: rgba(0,0,0,.6); color-scheme: dark }

html, body { min-height: 100% }
body {
  background: radial-gradient(ellipse 90% 60% at 20% -10%, var(--sheen), transparent 70%), var(--lid);
  color: var(--ink); font: 16px/1.5 var(--f-body);
  margin: 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
.wrap { max-width: 1100px; margin: 0 auto }
button { font: inherit; color: inherit }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }

/* header */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding-block: 12px 10px; border-bottom: 1px solid var(--rule) }
.brand { display: flex; align-items: center; gap: 10px; font: 600 1.35rem/1 var(--f-mono); letter-spacing: -.01em }
.brand svg { width: 22px; height: 26px }
.date { color: var(--muted); font-size: .9rem }
.tabs { margin-left: auto; display: flex; gap: 4px }
.tabs a { text-decoration: none; color: var(--muted); font-weight: 600; padding: 6px 12px; border-radius: 4px }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--pane) }
.tabs button { border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); padding: 6px 12px; border-radius: 4px }
.tabs button:hover, .tabs a:hover { color: var(--ink) }

/* every word found */
.done { max-width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--rule); border-radius: 8px; background: var(--pane); color: var(--ink); text-align: center }
.done::backdrop { background: rgba(10, 12, 16, .45) }
.done:focus-visible, .rules:focus-visible { outline: none }
.done h2 { margin: 0; font: 500 1.3rem var(--f-mono) }
.done-sticker { width: 150px; height: auto; margin: 14px auto 8px; display: block; overflow: visible; filter: drop-shadow(0 3px 6px var(--shadow)) }
.done-sticker text { font-family: var(--f-mono) }
.done-score { margin: 0; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums }
.done-marks { list-style: none; margin: 10px 0 0; padding: 0; font-size: .9rem; display: grid; gap: 4px }
.done-btns { display: flex; gap: 10px; justify-content: center; margin-top: 18px }
.done-btns a, .done-btns button {
  font: 400 .85rem var(--f-mono); padding: 8px 16px; cursor: pointer; text-decoration: none; color: var(--ink);
  background: var(--pane-2); border: 1px solid var(--rule); border-radius: 4px
}
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10 }
.confetti span {
  position: absolute; top: -20px; left: var(--x); width: var(--size); height: calc(var(--size) * 1.15);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  animation: fall 2.4s cubic-bezier(.3, .6, .5, 1) var(--delay) forwards
}
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(var(--spin)) } }

/* rules */
.rules { max-width: min(560px, calc(100vw - 32px)); padding: 20px 24px; border: 1px solid var(--rule); border-radius: 8px; background: var(--pane); color: var(--ink) }
.rules::backdrop { background: rgba(10, 12, 16, .45) }
.rules-head { display: flex; align-items: center; justify-content: space-between; gap: 12px }
.rules h2 { margin: 0; font: 500 1.2rem var(--f-mono) }
.rules-head button { border: 0; background: none; cursor: pointer; font-size: 1.4rem; line-height: 1; color: var(--muted); padding: 2px 6px }
.rules ul { margin: 12px 0 0; padding-left: 1.2em; display: grid; gap: 8px; font-size: .95rem }
.rules code { font-family: var(--f-mono); font-size: .9em }
.ranks { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums }
.ranks th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--rule); padding: 4px 8px 4px 0 }
.ranks td { padding: 3px 8px 3px 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 50%, transparent) }

/* meter */
.meter { padding-block: 16px 4px }
/* The score sits centered above the sticker, so a screenshot of the sticker carries it. */
.scoreline { text-align: center; display: grid; gap: 2px }
.scoreline .p { font: 500 1.05rem var(--f-mono); font-variant-numeric: tabular-nums }
.rank { color: var(--muted); font-size: .88rem; margin-left: 6px }
.score { color: var(--ok); font-size: .8rem; font-variant-numeric: tabular-nums }
/* The main track runs to the full score. A gap, then a shorter dashed track holds bonus points. */
.tracks { display: flex; gap: 18px; margin-block: 6px 24px }
.track { position: relative; flex: 4; height: 3px; background: var(--rule); border-radius: 2px }
.track.bonus { flex: 1; background: repeating-linear-gradient(90deg, var(--rule) 0 4px, transparent 4px 7px) }
.track.bonus .fill { background: var(--ok) }
.track.bonus::after { content: "bonus"; position: absolute; top: 9px; right: 0; font: 600 .72rem/1 var(--f-mono); color: var(--muted) }
.fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width .4s ease }
.tick { position: absolute; top: -6.5px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; font: 600 .72rem/1 var(--f-mono); color: var(--muted) }
.tick::before { content: ""; width: 12px; height: 12px; box-sizing: border-box; border-radius: 50%; background: var(--lid); border: 2px solid var(--muted); transition: background .3s, border-color .3s }
.tick.on { color: var(--accent) }
.tick.on::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent) }
.tick.pulse::before { animation: tick-pulse 1.2s ease-out 2 }
@keyframes tick-pulse { 40% { transform: scale(1.6); box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 25%, transparent) } }

/* board */
.board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 28px; align-items: start; padding-top: 18px }
.lid-area { display: flex; flex-direction: column; align-items: center; gap: 10px }
.switch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: .85rem; color: var(--muted) }
.seg { display: inline-flex; background: var(--pane-2); border-radius: 6px; padding: 3px }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 4px; cursor: pointer; font-weight: 600; color: var(--muted) }
.seg button[aria-pressed="true"] { background: var(--pane); color: var(--ink); box-shadow: 0 1px 2px var(--shadow) }
.sticker { width: min(100%, 290px); height: auto; overflow: visible; filter: drop-shadow(0 3px 6px var(--shadow)) }
.sticker.strip { width: min(100%, 380px) }
.sticker { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none }
.cell { cursor: pointer; outline: none }
.cell text { font-family: var(--f-mono); font-weight: 500; pointer-events: none; transform-box: fill-box; transform-origin: center }
.cell:hover .face { filter: brightness(.95) }
/* Pressed: the cell darkens and its letter sinks a little, like a thumb on a sticker. */
.cell.pop .face { animation: pop-face .2s ease-out }
.cell.pop text { animation: pop-text .2s ease-out }
@keyframes pop-face { 35% { filter: brightness(.86) } }
@keyframes pop-text { 35% { transform: scale(.86) } }
/* Keyboard focus: a thin ring that follows the cell's own shape. */
.cell .ring { fill: none; stroke-width: 1.5; stroke-linejoin: round; opacity: 0; pointer-events: none }
.cell:focus-visible .ring { opacity: 1 }
.keys { display: flex; gap: 10px }
.keys button {
  font: 400 .85rem var(--f-mono); padding: 8px 16px; cursor: pointer;
  background: var(--pane); border: 1px solid var(--rule); border-radius: 4px;
}
.keys button:hover { border-color: var(--muted) }
.keys button:active { transform: translateY(1px) }

/* console */
.console { background: var(--pane); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; min-width: 0 }
.con-head { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--pane-2); border-bottom: 1px solid var(--rule); font-size: .85rem }
.con-head strong { font-weight: 700 }
.con-head .path { font-family: var(--f-mono); color: var(--muted); font-size: .8rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
/* The Environment summary wraps rather than hide its well-known count. */
#env-sum { white-space: normal }
.nowrap { white-space: nowrap }
.con-head button { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: .82rem; font-weight: 600; padding: 2px 4px }
.con-body { font-family: var(--f-mono); font-size: .9rem; padding: 12px 14px; max-height: 180px; min-height: 100px; overflow-y: auto }
.con-body ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px }
.cmd { display: flex; gap: 8px; align-items: baseline }
.cmd .pr { color: var(--muted) }
.cmd .w { font-weight: 600 }
.cmd .pts { margin-left: auto; color: var(--ok); font-variant-numeric: tabular-nums }
.badge { font: 700 .68rem var(--f-body); text-transform: uppercase; letter-spacing: .06em; color: var(--paper); background: var(--keyfill); padding: 1px 6px; border-radius: 3px }
.out { padding-left: 2ch; display: grid; gap: 2px }
.def { display: flex; flex-wrap: wrap; gap: 0 10px }
.def .ns { color: var(--accent) }
.def .ttl { font-family: var(--f-body); color: var(--muted); font-size: .88rem }
.out details summary { cursor: pointer; color: var(--muted); font-family: var(--f-body); font-size: .82rem; list-style: none }
.out details summary::before { content: "+ " }
.out details[open] summary::before { content: "− " }
.out details .def { margin-top: 2px }
.prompt { position: relative; display: flex; gap: 8px; align-items: center; padding: 12px 14px; font: 1.25rem var(--f-mono); border-bottom: 1px solid var(--rule) }
.prompt .said { font-size: .95rem; font-weight: 400; letter-spacing: 0 }
/* An accepted word's points rise from the prompt and fade. */
.float { position: absolute; left: 2.4rem; top: 10px; color: var(--ok); font-weight: 600; pointer-events: none; animation: float-up .9s ease-out forwards }
@keyframes float-up { from { opacity: 1; transform: translateY(0) } to { opacity: 0; transform: translateY(-30px) } }
.con-body li.new { animation: flash 1.2s ease-out; border-radius: 4px }
@keyframes flash { from { background: color-mix(in srgb, var(--ok) 18%, transparent) } }
.said.err { color: var(--err) } .said.warn { color: var(--warn) } .said.ok { color: var(--ok) }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }
.prompt .pr { color: var(--muted) }
.prompt .g { font-weight: 500; letter-spacing: .02em; min-height: 1.5em; word-break: break-all }
.prompt .g .k { color: var(--accent) }
.prompt .g.shake { animation: shake .3s }
@keyframes shake { 25% { transform: translateX(-4px) } 75% { transform: translateX(4px) } }
.caret { width: 2px; height: 1.2em; background: var(--accent); animation: blink 1s steps(1) infinite }
@keyframes blink { 50% { opacity: 0 } }
.placeholder { color: var(--muted); font-weight: 400; font-family: var(--f-body); font-size: 1rem }

/* environment: every word as blanks, and free hints on one blank */
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0 }
.env { background: var(--pane); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; min-width: 0 }
.env-body { padding: 12px 14px; display: grid; gap: 12px }
.chips { display: flex; flex-wrap: wrap; gap: 4px 8px }
.chip {
  display: inline-flex; gap: 2px; align-items: flex-end; padding: 4px 5px; border: 0; border-radius: 4px;
  background: none; font: 400 .9rem/1.3 var(--f-mono)
}
button.chip { cursor: pointer }
button.chip:hover { background: var(--pane-2) }
button.chip[aria-pressed="true"] { background: var(--pane-2); box-shadow: inset 0 0 0 1px var(--accent) }
.chip .sl { display: inline-block; width: 1ch; height: 1.05em; line-height: 1; text-align: center; border-bottom: 1px solid var(--muted) }
.chip.found { color: var(--muted) }
.chip.found .sl { border-bottom-color: var(--rule) }
/* Well-known words are always marked: their blanks get a blue tint. */
.chip.wk { background: color-mix(in srgb, var(--accent) 18%, transparent) }
.chip.wk .sl { border-bottom: 2px solid var(--accent) }
.hint { border-top: 1px solid var(--rule); padding-top: 10px; font-size: .9rem; display: grid; gap: 8px }
.hint:empty { display: none }
.hint-note { margin: 0; color: var(--muted); font-size: .85rem }
.hint-note a { color: var(--accent) }
.hint-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px }
.hint-btns { margin-left: auto; display: flex; gap: 6px }
.hint-btns button {
  font: 400 .8rem var(--f-mono); padding: 4px 10px; cursor: pointer;
  background: var(--pane); border: 1px solid var(--rule); border-radius: 4px
}
.hint-btns button:hover:not(:disabled) { border-color: var(--muted) }
.hint-btns button:disabled { cursor: default; color: var(--muted); opacity: .6 }
.hint-out { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px }
.code { font-family: var(--f-mono) }
.hint .out .ttl { font-family: var(--f-body); color: var(--muted) }
.hint .out .code { overflow-wrap: anywhere }
.cmt { color: var(--muted) }

/* hexwall */
.wall-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; padding-block: 24px 6px }
.wall-head h2 { margin: 0; font: 500 1.4rem var(--f-mono); letter-spacing: -.01em }
.wall-head p { margin: 0; color: var(--muted) }
.wall-box { overflow-x: auto; padding-block: 12px }
.wall-month h3 { margin: 18px 0 0; font: 500 1rem var(--f-mono) }
.wall-month h3 span { color: var(--muted); font-family: var(--f-body); font-size: .85rem }
.wall { width: 100%; min-width: 520px; max-width: 760px; height: auto; display: block }
.wall .stk { filter: drop-shadow(0 3px 4px var(--shadow)) }
.wall text { font-family: var(--f-mono) }
.note { color: var(--muted); font-size: .88rem; max-width: 65ch }
.legend { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-block: 16px }
.legend figure { margin: 0; display: flex; align-items: center; gap: 12px; max-width: 340px }
.legend svg { width: 64px; flex: none; overflow: visible }
.legend .stk { filter: drop-shadow(0 3px 4px var(--shadow)) }
.legend text { font-family: var(--f-mono) }
.legend .note { margin: 0 }
.defs { position: absolute; width: 0; height: 0; overflow: hidden }
.stk .holo { opacity: .38; mix-blend-mode: screen }
.stk .stamp { font-family: var(--f-mono); font-weight: 600; letter-spacing: .02em }

@media (max-width: 820px) {
  .board { grid-template-columns: minmax(0, 1fr) }
  .tabs { margin-left: 0 }
  .con-body { max-height: 170px; min-height: 80px }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important } }

/* hexwall slots, empty view, footer */
.wall .slot { fill: none; stroke: var(--rule); stroke-width: 1.5 }
.wall .slot.past { stroke-dasharray: 4 4 }
.wall .slot.future { opacity: .5 }
.wall .slot.today { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 4 }
.wall .day { fill: var(--muted); font-size: 10px }
.wall .day.today { fill: var(--accent); font-size: 11px }
.empty { padding-block: 48px; text-align: center; color: var(--muted) }
.empty h2 { font: 500 1.4rem var(--f-mono); color: var(--ink); margin: 0 0 8px }
footer { margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--rule); color: var(--muted); font-size: .8rem }
footer a { color: inherit }
footer p { margin: 0 }
footer p + p { margin-top: 6px }
.social { display: flex; gap: 14px; margin-top: 10px }
.social a { display: inline-flex; padding: 4px; margin: -4px }
.social a:hover, .social a:focus-visible { color: var(--accent) }
.social svg { width: 18px; height: 18px; fill: currentColor }
.def .ver { color: var(--muted); font-size: .78rem }
