/* SEALED — the game. Colours come from the brand settings and from each box. */
:root {
  --bg: #0F1B2D; --bg2: #16294A; --line: #3A5373; --ink: #EFE6D2; --soft: #C9D3E0; --dim: #8FA3BD;
  --accent: #E2B33C; --accent-ink: #0F1B2D; --paper: #EFE6D2; --paper-ink: #0F1B2D; --red: #B23A2E; --ok: #6FC3BC;
  --display: "Big Shoulders Display", "Oswald", "Bebas Neue", "Antonio", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "IBM Plex Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "IBM Plex Mono", Menlo, Consolas, monospace;
  --r: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
body { overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-stretch: condensed; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; line-height: .95; margin: 0; }
.mono { font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; font-size: 13px; }
.muted { color: var(--soft); }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--ok); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 6px; border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; text-decoration: none; letter-spacing: .02em; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { border-color: #E07A6E; color: #F2B4AC; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); background: transparent; cursor: pointer; padding: 0; }
.icon:hover { border-color: var(--accent); }
.icon svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------------- top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--display); font-stretch: condensed; font-weight: 900; font-size: 30px; color: var(--accent); text-decoration: none; letter-spacing: .03em; line-height: 1; }
.top .grow { flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--line); background: transparent; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px; }
.chip:hover { border-color: var(--accent); }
.badge { font: 700 11px var(--mono); letter-spacing: .1em; padding: 2px 6px; border-radius: 4px; background: var(--red); color: #fff; }

/* ---------------- pages */
.page { max-width: 1200px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-left)) 80px; display: grid; gap: 28px; }
.hero { display: grid; gap: 10px; }
.hero h1 { font-size: clamp(56px, 12vw, 120px); color: var(--accent); }
.hero p { margin: 0; max-width: 560px; color: var(--soft); font-size: 18px; }
.notice { padding: 14px 18px; border: 2px solid var(--accent); border-radius: var(--r); background: var(--bg2); }
.notice.warn { border-color: #E07A6E; }

/* ---------------- box covers */
.boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 24px; }
.cover { --c-bg: #0F1B2D; --c-ac: #E2B33C; position: relative; display: flex; flex-direction: column; text-decoration: none; color: #EFE6D2; border-radius: 6px; overflow: hidden; box-shadow: 0 18px 30px -18px rgba(0,0,0,.8); transition: transform .15s; background: #F6F0E2; }
.cover:hover { transform: translateY(-3px); }
.cover .art { position: relative; aspect-ratio: 1 / 1; background: var(--c-bg); padding: 20px; display: flex; flex-direction: column; overflow: hidden; }
.cover .art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .rings { position: absolute; right: -60px; top: 30px; width: 240px; height: 240px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--c-ac) 35%, transparent); box-shadow: 0 0 0 30px color-mix(in srgb, var(--c-ac) 8%, transparent), inset 0 0 0 30px color-mix(in srgb, var(--c-ac) 8%, transparent); }
.cover .vol { position: relative; font: 12px var(--mono); letter-spacing: .16em; color: #D7DEE8; }
.cover .logo { position: relative; font-family: var(--display); font-stretch: condensed; font-weight: 900; font-size: 46px; line-height: .85; color: var(--c-ac); margin-top: 10px; }
.cover .title { position: relative; margin-top: auto; font-family: var(--display); font-stretch: condensed; font-weight: 800; font-size: 30px; line-height: .95; text-transform: uppercase; }
.cover .meta { position: relative; display: flex; gap: 5px; align-items: center; margin-top: 12px; font: 12px var(--mono); color: #D7DEE8; }
.dots { display: inline-flex; gap: 4px; margin-right: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c-ac, var(--accent)); }
.dots i.on { background: var(--c-ac, var(--accent)); }
.cover .foot { padding: 12px 18px; color: #0F1B2D; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; min-height: 52px; }
.cover .foot b { font-weight: 700; }
.cover.locked .art { filter: grayscale(.8) brightness(.6); }
.cover .lock { position: absolute; inset: 0; display: grid; place-items: center; }
.cover .lock svg { width: 56px; height: 56px; fill: #EFE6D2; }
.stars { color: #B8860B; letter-spacing: 1px; white-space: nowrap; }
.stars.light { color: var(--accent); }

/* ---------------- box page */
.boxpage { display: grid; grid-template-columns: minmax(240px, 380px) 1fr; gap: 36px; align-items: start; }
@media (max-width: 760px) { .boxpage { grid-template-columns: 1fr; } }
.boxpage .cover { pointer-events: none; }
.facts { display: flex; flex-wrap: wrap; gap: 10px; }
.fact { border: 2px solid var(--line); border-radius: 6px; padding: 8px 14px; min-width: 86px; text-align: center; }
.fact b { display: block; font-family: var(--display); font-stretch: condensed; font-size: 30px; line-height: 1; }
.fact span { font: 11px var(--mono); letter-spacing: .12em; color: var(--soft); text-transform: uppercase; }
.envelopes { display: grid; gap: 10px; }
.env { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border: 2px solid var(--line); border-radius: 6px; }
.env .n { font-family: var(--display); font-weight: 900; font-size: 34px; color: var(--accent); line-height: 1; width: 44px; }
.env .seal { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px #8E2C23; display: grid; place-items: center; font: 800 15px var(--display); color: #F6EBD7; }
.env.done .seal { background: transparent; box-shadow: 0 0 0 2px var(--ok); color: var(--ok); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.board { width: 100%; border-collapse: collapse; font-size: 15px; }
.board th, .board td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.board th { font: 12px var(--mono); letter-spacing: .1em; color: var(--soft); text-transform: uppercase; }
.board tr.me td { color: var(--accent); font-weight: 700; }
.board td.num { font-family: var(--mono); }

/* ---------------- play screen */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0; min-height: calc(100dvh - 65px); }
@media (max-width: 900px) { .play { grid-template-columns: 1fr; } }
.stage { padding: 16px; display: grid; gap: 12px; align-content: start; }
.roomhead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.roomhead .n { font-family: var(--display); font-weight: 900; font-size: 44px; color: var(--accent); line-height: .9; }
.roomhead h2 { font-size: 32px; }
.track { display: flex; gap: 6px; margin-left: auto; }
.track i { width: 28px; height: 8px; border-radius: 4px; background: var(--line); }
.track i.done { background: var(--ok); } .track i.current { background: var(--accent); }
.scene { position: relative; width: 100%; aspect-ratio: 3 / 2; border-radius: var(--r); overflow: hidden; background: var(--room-bg, #14253D); box-shadow: 0 20px 40px -24px #000; user-select: none; }
.scene > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.spot { position: absolute; border: 2px dashed transparent; border-radius: 8px; background: transparent; cursor: pointer; padding: 0; transition: background .15s, border-color .15s; }
.spot:hover, .spot:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.spot .lbl { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -4px); white-space: nowrap; font: 600 12px var(--body); background: rgba(10,16,28,.9); color: var(--ink); padding: 3px 8px; border-radius: 4px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.spot:hover .lbl, .spot:focus-visible .lbl, .showspots .spot .lbl { opacity: 1; }
.spot .dot { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); animation: pulse 2s infinite; }
.spot.searched .dot { background: transparent; box-shadow: none; border: 2px solid var(--soft); animation: none; opacity: .7; }
.spot.locked .dot { background: #8FA3BD; animation: none; box-shadow: 0 0 0 4px rgba(143,163,189,.25); }
.showspots .spot { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .spot .dot { animation: none; } * { transition: none !important; } }
.scenebar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.intro { color: var(--soft); margin: 0; max-width: 760px; }

/* hand of cards */
.hand { border-left: 1px solid var(--line); padding: 16px; display: grid; gap: 10px; align-content: start; background: color-mix(in srgb, var(--bg2) 50%, var(--bg)); }
@media (max-width: 900px) { .hand { border-left: 0; border-top: 1px solid var(--line); } }
.hand h3 { font-size: 22px; display: flex; justify-content: space-between; align-items: baseline; }
.mini { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px; border-radius: 8px; border: 2px solid var(--line); background: var(--bg); cursor: pointer; }
.mini:hover { border-color: var(--accent); }
.mini .id { font-family: var(--display); font-weight: 900; font-size: 22px; color: var(--accent); }
.mini .t { font-weight: 600; line-height: 1.25; }
.mini .k { font: 11px var(--mono); letter-spacing: .1em; color: var(--soft); text-transform: uppercase; display: block; }
.mini.new { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.mini.solved { opacity: .75; }
.tag { font: 700 11px var(--mono); letter-spacing: .08em; padding: 3px 7px; border-radius: 4px; text-transform: uppercase; }
.tag.lock { background: var(--red); color: #fff; } .tag.ok { background: var(--ok); color: #0F1B2D; } .tag.exit { background: var(--accent); color: #0F1B2D; }
.stats { display: flex; gap: 16px; flex-wrap: wrap; font: 13px var(--mono); color: var(--soft); }
.stats b { color: var(--ink); }

/* timer */
.timer { font: 700 20px var(--mono); letter-spacing: .04em; padding: 4px 10px; border-radius: 6px; border: 2px solid var(--line); min-width: 92px; text-align: center; }
.timer.paused { color: var(--dim); border-style: dashed; }
.pen { font: 12px var(--mono); color: #F2B4AC; }

/* ---------------- dialogs */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: min(560px, calc(100vw - 24px)); width: 100%; max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(5,9,16,.75); backdrop-filter: blur(3px); }
.sheet { background: var(--bg2); border: 2px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 16px; overflow: auto; max-height: calc(100dvh - 24px); }
.sheet h2 { font-size: 34px; }
.sheet .x { position: absolute; right: 12px; top: 12px; }
.field { display: grid; gap: 6px; }
.field label { font: 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.field input { min-height: 48px; padding: 0 14px; border-radius: 6px; border: 2px solid var(--line); background: var(--bg); font-size: 18px; }
.field input:focus { border-color: var(--accent); outline: none; }
.err { color: #F2B4AC; min-height: 1.4em; margin: 0; }
.code { font: 700 26px var(--mono); letter-spacing: .1em; text-align: center; padding: 14px; border: 2px dashed var(--accent); border-radius: 8px; user-select: all; }

/* the card itself */
.card { position: relative; background: var(--paper); color: var(--paper-ink); border-radius: 14px; padding: 20px 20px 18px; display: grid; gap: 12px; border: 2px solid var(--paper-ink); }
.card.kind-riddle { --kc: #7A2A21; } .card.kind-item { --kc: #2E5C58; } .card.kind-note { --kc: #3E4B5E; }
.card .ch { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card .cid { font-family: var(--display); font-weight: 900; font-size: 34px; line-height: 1; color: var(--kc); }
.card .ck { font: 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--kc); }
.card h2 { font-size: 28px; color: var(--paper-ink); }
.card p.txt { margin: 0; white-space: pre-line; font-size: 17px; line-height: 1.5; }
.card img { width: 100%; border-radius: 8px; background: #16263F; }
.card .stamp { position: absolute; right: 18px; top: 56px; transform: rotate(-12deg); border: 3px solid #2E7D5B; color: #2E7D5B; font: 900 22px var(--display); letter-spacing: .08em; padding: 2px 10px; border-radius: 6px; }
.lockbox { display: grid; gap: 12px; padding: 16px; border-radius: 10px; background: var(--paper-ink); color: var(--paper); }
.lockbox .mono { color: var(--accent); }
.lockbox .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: center; }
.lockbox input.text { flex: 1; min-width: 160px; min-height: 48px; border-radius: 6px; border: 2px solid var(--accent); background: transparent; padding: 0 12px; font-size: 20px; text-transform: uppercase; letter-spacing: .05em; }
.msg { padding: 12px 14px; border-radius: 8px; background: #DCEBE3; color: #1E4A3A; font-weight: 600; }
.msg.bad { background: #F3D9D5; color: #7A2A21; }

/* wheels: one per symbol or digit */
.wheels { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.wheel { display: grid; justify-items: center; gap: 4px; }
.wheel button.arr { width: 52px; height: 32px; border-radius: 6px; border: 2px solid var(--accent); background: transparent; color: var(--accent); cursor: pointer; display: grid; place-items: center; }
.wheel button.arr svg { width: 18px; height: 18px; fill: currentColor; }
.wheel .face { width: 64px; height: 72px; border-radius: 8px; border: 3px solid var(--accent); display: grid; place-items: center; background: #0B1424; cursor: ns-resize; touch-action: none; position: relative; overflow: hidden; }
.wheel .face svg { width: 38px; height: 38px; }
.wheel .face .dg { font: 800 40px var(--display); color: var(--paper); }
.wheel .face .nm { position: absolute; bottom: 2px; font: 9px var(--mono); letter-spacing: .08em; color: var(--dim); text-transform: uppercase; }
.wheel .face:focus-visible { outline: 3px solid var(--ok); }

/* help ladder */
.help { display: grid; gap: 8px; }
.help .h { padding: 10px 12px; border-radius: 8px; border: 2px solid #3B6E6A; background: #EAF2EF; color: #1F3F3C; }
.help .h b { font: 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; display: block; margin-bottom: 2px; color: #2E5C58; }
.help .h.sol { border-color: #7A2A21; background: #F7E6E2; color: #4A1914; }
.help .h.sol b { color: #7A2A21; }
.card .btn.ghost { color: var(--paper-ink); border-color: var(--paper-ink); }

/* envelope / seal screen */
.sealscreen { min-height: calc(100dvh - 65px); display: grid; place-items: center; padding: 24px; }
.envelope { position: relative; width: min(420px, 92vw); aspect-ratio: 4 / 3; background: #D9C9A3; border: 2px solid #0F1B2D; border-radius: 6px; display: grid; place-items: end center; padding: 24px; color: #0F1B2D; text-align: center; overflow: hidden; }
.envelope::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 60%; background: #CDBB92; clip-path: polygon(0 0, 100% 0, 50% 100%); border-bottom: 2px solid #0F1B2D; }
.waxseal { position: absolute; left: 50%; top: 60%; transform: translate(-50%, -50%); width: 96px; height: 96px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 7px #8E2C23, 0 10px 18px rgba(0,0,0,.35); border: 0; color: #F6EBD7; font: 900 44px var(--display); cursor: pointer; transition: transform .25s; }
.waxseal:hover { transform: translate(-50%, -50%) scale(1.06) rotate(-6deg); }
.envelope .who { position: relative; font-family: var(--display); font-stretch: condensed; font-weight: 800; font-size: 28px; text-transform: uppercase; line-height: 1; }
.envelope.broken .waxseal { animation: crack .6s forwards; }
@keyframes crack { to { transform: translate(-50%, -50%) scale(1.3) rotate(20deg); opacity: 0; } }
.sealtext { max-width: 560px; display: grid; gap: 18px; justify-items: center; text-align: center; }
.sealtext p { margin: 0; color: var(--soft); font-size: 18px; }

/* finish */
.finish { text-align: center; justify-items: center; }
.finish .big { font: 800 64px var(--mono); color: var(--accent); line-height: 1; }
.finish .stars { font-size: 40px; color: var(--accent); }
.finish p { max-width: 640px; margin: 0 auto; font-size: 18px; color: var(--soft); }

#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%); background: var(--paper); color: var(--paper-ink); padding: 12px 18px; border-radius: 10px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5); transition: transform .25s, opacity .25s; z-index: 50; max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.err { background: #F3D9D5; color: #7A2A21; }
.boot { padding: 60px 20px; text-align: center; color: var(--soft); }
.top .grow > * { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .top { gap: 8px; padding: 8px 12px; }
  .top .icon { width: 40px; height: 40px; }
  .timer { font-size: 16px; min-width: 70px; padding: 4px 6px; }
  .pen { display: none; }
  .stage { padding: 12px; }
  .roomhead .n { font-size: 34px; } .roomhead h2 { font-size: 26px; }
  .brand { font-size: 26px; }
  .chip { padding: 0 10px; }
}
