/* Täyskymppi — base: tokens, type, controls, screens
   Every colour, font, radius, pattern and texture below is a theme token. js/theme.js writes
   the active theme onto :root, so these values are only the no-JS fallback (the default theme).
   Text on a coloured fill always uses the matching --on-* token, never a fixed colour. */
:root {
  color-scheme: dark;
  --bg: #0D0F13;
  --bg-2: #111419;
  --surface: #171B21;
  --surface-2: #1E232B;
  --surface-3: #272D37;
  --line: rgba(214, 226, 255, 0.08);
  --line-2: rgba(214, 226, 255, 0.15);
  --fg: #EEF1F5;
  --fg-2: #A5ADBA;
  --fg-3: #6C7483;
  --ink: #0D0F13;
  --hi: #B4EC5C;

  --gold: #FFC83D;
  --ok: #3DE3A6;
  --bad: #FF5468;

  --t-tf: #5BB6FF;
  --t-num: #FFD24D;
  --t-ord: #A390FF;
  --t-era: #FF9152;
  --t-col: #FF70B0;
  --t-open: #B4EC5C;

  /* readable text on each fill (computed per theme) */
  --on-fg: #0D0F13; --on-ok: #0D0F13; --on-bad: #0D0F13; --on-gold: #0D0F13;
  --on-t-tf: #0D0F13; --on-t-num: #0D0F13; --on-t-ord: #0D0F13; --on-t-era: #0D0F13; --on-t-col: #0D0F13; --on-t-open: #0D0F13;
  --inv-t-tf: #F3F5F8; --inv-t-num: #F3F5F8; --inv-t-ord: #F3F5F8; --inv-t-era: #F3F5F8; --inv-t-col: #F3F5F8; --inv-t-open: #F3F5F8;
  --flap-top: #232832; --flap-bot: #1A1E25; --flap-fg: #F4F6F9;
  --shade: rgba(0, 0, 0, .7);
  --backdrop: rgba(5, 6, 9, .62);
  --seam: rgba(0, 0, 0, .55);
  --tx-mix: 0%;
  --pat-poster: none; --pat-tiles: none; --pat-op: .14;
  --texture: none; --texture-op: 0; --texture-blend: overlay;
  --app-bg: none;

  --font-logo: "Unbounded", "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --r-tile: 16px;
  --r-poster: 26px;
  --r-btn: calc(var(--r-tile) * .75);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.5, .64, 1);
}

@property --accent-c {
  syntax: '<color>';
  inherits: true;
  initial-value: #5BB6FF;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  height: 100%;
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  overflow: hidden;
  overscroll-behavior: none;
}
/* theme texture (grain / paper) laid over the app, under sheets and modals */
body::after {
  content: '';
  position: fixed; inset: 0;
  z-index: 30;
  pointer-events: none;
  background: var(--texture);
  opacity: var(--texture-op);
  mix-blend-mode: var(--texture-blend);
}
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
svg { display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus, var(--fg-2)); outline-offset: 2px; }

#app { position: relative; height: 100%; overflow: hidden; background: var(--app-bg); }

.screen {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: screenIn .45s var(--ease);
}
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

[data-icon] { display: inline-flex; }
[data-icon] svg { width: 1.15em; height: 1.15em; }

/* ---------- Controls ---------- */
.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r-btn);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--fg);
  font: 600 15px/1 var(--font-ui);
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s var(--ease), background .2s, border-color .2s, opacity .2s, color .2s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--fg); color: var(--on-fg); border-color: transparent; }
.btn.primary:hover, .btn.accent:hover, .btn.ok:hover, .btn.bad:hover { background-image: linear-gradient(rgba(255, 255, 255, .12), rgba(255, 255, 255, .12)); box-shadow: 0 10px 24px -14px var(--shade); }
.btn.accent { background-color: var(--accent-c); color: var(--on-accent, var(--ink)); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.ok { background-color: var(--ok); color: var(--on-ok); border-color: transparent; }
.btn.bad { background-color: var(--bad); color: var(--on-bad); border-color: transparent; }
.btn.lg { height: 54px; padding: 0 28px; font-size: 17px; border-radius: calc(var(--r-btn) + 2px); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: calc(var(--r-btn) - 2px); }
.btn .cost { font: 600 12px var(--font-mono); opacity: .8; display: inline-flex; align-items: center; gap: 4px; }
.btn.on { border-color: var(--ok); color: var(--tx-ok, var(--ok)); background: color-mix(in oklab, var(--ok) 10%, transparent); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-btn);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg-2);
  display: grid; place-items: center;
  cursor: pointer;
  flex: none;
  transition: background .2s, color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); border-color: var(--line-2); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: .28; pointer-events: none; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: calc(var(--r-btn) - 2px); }

.label {
  font: 600 11px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--fg-3);
}
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-btn);
  color: var(--fg);
  font: 500 17px var(--font-ui);
  padding: 13px 14px;
  margin-top: 10px;
  outline: none;
  transition: border-color .2s;
}
.input:focus { border-color: var(--fg-3); }
.input::placeholder { color: var(--fg-3); }
textarea.input { resize: vertical; min-height: 96px; font: 500 14px/1.4 var(--font-mono); word-break: break-all; }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  margin-top: 10px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-tile);
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--fg-2);
  border-radius: var(--r-btn);
  padding: 10px 6px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background .2s, color .2s;
  min-width: 0;
}
.seg button b { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.seg button small { font: 500 11px var(--font-mono); color: var(--fg-3); letter-spacing: .02em; }
.seg button:hover { color: var(--fg); }
.seg button[aria-checked="true"] { background: var(--mc, var(--surface-3)); color: var(--on-mc, var(--fg)); }
.seg button[aria-checked="true"] small { color: color-mix(in srgb, currentColor 62%, transparent); }
@media (max-width: 460px) {
  .seg.four { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
}

.tok {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 12px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.tok::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 1.5px;
  background: var(--fg);
  transform: rotate(45deg);
  flex: none;
}

/* ---------- Home ---------- */
.home {
  display: grid;
  place-items: center;
  padding: 32px 20px 24px;
}
.home-inner {
  width: min(1040px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 5vh, 52px);
}
.brand { display: flex; flex-direction: column; gap: 18px; }
.lockup { display: flex; align-items: center; gap: .34em; font-size: clamp(30px, 6.6vw, 84px); }
.mark {
  --cell: .28em;
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  grid-template-rows: repeat(2, var(--cell));
  gap: .07em;
  flex: none;
}
.mark i {
  border-radius: .05em;
  background: var(--surface-3);
  animation: markWave 4.2s cubic-bezier(.45, 0, .2, 1) infinite;
  animation-delay: calc(var(--k) * 120ms);
}
@keyframes markWave {
  0%, 8% { background: var(--surface-3); transform: none; box-shadow: none; }
  18%, 58% { background: var(--c); transform: rotate(45deg) scale(.78); box-shadow: 0 0 .25em color-mix(in oklab, var(--c) 55%, transparent); }
  72%, 100% { background: var(--surface-3); transform: none; box-shadow: none; }
}
/* Logotype: TÄYSKYMPPI on ten split-flap tiles (ten letters = ten answers) */
.wordmark { margin: 0; display: flex; gap: .055em; font-size: 1em; line-height: 1; }
.flap {
  position: relative;
  display: grid; place-items: center;
  width: .74em; height: 1.06em;
  border-radius: .1em;
  background: linear-gradient(to bottom, var(--flap-top) 0 50%, var(--flap-bot) 50% 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 .09em .22em -.06em var(--shade);
  overflow: hidden;
  transition: background .35s;
}
.flap::after {
  content: '';
  position: absolute; left: 0; right: 0; top: 50%;
  height: .028em; margin-top: -.014em;
  background: var(--seam);
  box-shadow: 0 .014em 0 rgba(255, 255, 255, .05);
}
.flap-l {
  display: block;
  font: 600 .7em/1 var(--font-ui);
  letter-spacing: -0.01em;
  color: var(--flap-fg);
  transform-origin: 50% 50%;
  transition: color .35s;
}
.flap-l.tick { animation: flapTick .06s linear; }
@keyframes flapTick { from { transform: scaleY(.15); opacity: .5; } to { transform: none; opacity: 1; } }
.flap.tint { background: var(--rc); }
.flap.tint .flap-l { color: var(--on-rc, var(--ink)); }
.flap.tint::after { background: rgba(0, 0, 0, .28); }
:root[data-seams="off"] .flap::after { display: none; }
/* text and image logos (brand themes) */
.wordmark-text { font: 800 1em/.9 var(--font-logo); letter-spacing: -0.045em; color: var(--fg); white-space: nowrap; }
.wordmark-img { display: block; height: 1.1em; width: auto; max-width: min(78vw, 9em); object-fit: contain; }
.lockup.no-mark .mark { display: none; }
.brand-line { display: inline-flex; align-items: center; gap: 10px; font: 600 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-3); }
.brand-line i { width: 18px; height: 1px; background: var(--line-2); }
@media (prefers-reduced-motion: reduce) { .mark i { animation: none; background: var(--c); } }
.tagline { margin: 0; max-width: 34ch; color: var(--fg-2); font-size: clamp(16px, 2vw, 20px); line-height: 1.4; text-wrap: balance; }

.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 780px) { .modes { grid-template-columns: 1fr; } }
.mode {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  text-align: left;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 210px;
  padding: 22px;
  background: var(--mc);
  border: 0;
  border-radius: var(--r-poster);
  color: var(--mode-on, var(--on-mc, var(--ink)));
  cursor: pointer;
  transition: transform .6s cubic-bezier(.16, .84, .24, 1), box-shadow .6s cubic-bezier(.16, .84, .24, 1);
  animation: tileIn .8s cubic-bezier(.16, .84, .24, 1) backwards;
}
.modes .mode:nth-child(1) { animation-delay: .35s; }
.modes .mode:nth-child(2) { animation-delay: .45s; }
.modes .mode:nth-child(3) { animation-delay: .55s; }
@keyframes tileIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.mode:hover { transform: translateY(-4px); box-shadow: 0 28px 48px -30px var(--mc); }
.mode:active { transform: translateY(-2px) scale(.99); transition-duration: .2s; }
.mode:focus-visible { outline-color: var(--fg); }
.mode > * { position: relative; z-index: 1; }
.mode-ico { color: inherit; }
.mode-ico svg { width: 36px; height: 36px; stroke-width: 2; transition: transform .7s cubic-bezier(.16, .84, .24, 1); }
.mode:hover .mode-ico svg { transform: rotate(90deg); }
.mode[data-mode="host"]:hover .mode-ico svg { transform: translateY(-2px); }
/* the arrow pill grows a line that draws across the tile */
.mode-go::after {
  content: '';
  position: absolute; left: calc(100% + 10px); top: 50%;
  width: 0; height: 1.5px;
  background: color-mix(in srgb, currentColor 45%, transparent);
  transition: width .6s cubic-bezier(.16, .84, .24, 1);
}
.mode:hover .mode-go::after { width: 60px; }
.mode-title { font: 800 calc(30px * var(--ds, 1))/1 var(--font-display); letter-spacing: calc(-0.03em * var(--dt, 1)); margin-top: 10px; }
.mode-desc { color: color-mix(in srgb, currentColor 74%, transparent); font-size: 14.5px; font-weight: 520; line-height: 1.45; max-width: 36ch; }
.mode-go {
  position: relative;
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px 8px 14px;
  border-radius: 999px;
  background: var(--mode-on, var(--on-mc, var(--ink)));
  color: var(--mc);
  font: 600 12px var(--font-mono);
  letter-spacing: .03em;
  transition: gap .25s var(--ease);
}
.mode:hover .mode-go { gap: 10px; }
/* theme option modeText: 'light' = white text, icons and buttons on every mode tile */
:root[data-mode-text="light"] { --mode-on: #FFFFFF; }
:root[data-mode-text="light"] .mode-desc { color: rgba(255, 255, 255, .94); font-weight: 560; }
:root[data-mode-text="light"] .mode-go { font-weight: 700; }
@media (max-width: 780px) { .mode { min-height: 0; padding: 18px; border-radius: calc(var(--r-poster) * .85); } .mode-title { margin-top: 0; font-size: calc(26px * var(--ds, 1)); } .mode-ico svg { width: 28px; height: 28px; } }

.home-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.link-btn {
  background: none; border: 0; padding: 6px 0;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--fg-2);
  font: 500 14px var(--font-ui);
  cursor: pointer;
  transition: color .2s;
}
.link-btn:hover { color: var(--fg); }
.credit {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font: 500 12px var(--font-mono);
  color: var(--fg-3);
}
.credit a { text-decoration: none; }
.credit a:hover { color: var(--fg); }

/* ---------- Setup ---------- */
.setup { display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.topbar-title { margin: 0; font: 700 22px/1 var(--font-display); letter-spacing: -0.02em; }
.setup-body {
  flex: 1;
  width: min(620px, 100%);
  margin: 0 auto;
  padding: 10px 20px 28px;
  display: flex; flex-direction: column; gap: 28px;
}
.field-head { display: flex; justify-content: space-between; align-items: baseline; }
.hint { font: 500 12px var(--font-mono); color: var(--fg-3); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.player-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prow {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 7px 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  animation: rowIn .3s var(--ease);
}
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.prow .pc {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--pc);
  color: var(--on-pc, var(--ink));
  display: grid; place-items: center;
}
.prow .pc svg { width: 16px; height: 16px; }
.prow input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--fg);
  font: 500 16px var(--font-ui);
  padding: 8px 4px;
}
.prow input:focus { box-shadow: inset 0 -1px 0 var(--fg-3); }
.prow .ptag { font: 500 11px var(--font-mono); color: var(--fg-3); white-space: nowrap; }
.field-note { margin: 10px 0 0; font-size: 13px; line-height: 1.5; color: var(--fg-3); }
.setup-note { margin: 0; color: var(--fg-3); font-size: 13px; line-height: 1.5; }
.setup-note:empty { display: none; }
.setup-foot {
  position: sticky; bottom: 0;
  padding: 18px 20px 20px;
  display: flex; justify-content: center;
  background: linear-gradient(to bottom, transparent, var(--bg) 35%);
}
.setup-foot .btn { width: min(580px, 100%); }
.setup-foot .btn.primary { background-color: var(--mc, var(--fg)); color: var(--on-mc, var(--on-fg)); }

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fade .25s; }
.modal {
  position: relative;
  width: min(580px, 100%);
  max-height: calc(100% - 24px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 24px;
  animation: pop .32s var(--ease);
  box-shadow: 0 30px 80px -20px var(--shade);
}
.modal h3 { margin: 0 0 6px; font: 700 26px/1.1 var(--font-display); letter-spacing: -0.02em; }
.modal p { color: var(--fg-2); margin: 0 0 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.menu-list .btn { justify-content: flex-start; height: 50px; }
.form-error { color: var(--tx-bad, var(--bad)); font-size: 13px; margin: 8px 0 0; min-height: 1em; }

.rules h4 { margin: 22px 0 8px; font: 600 11px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fg-3); }
.rules p, .rules li { color: var(--fg-2); font-size: 14.5px; line-height: 1.55; }
.rules ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.rules b { color: var(--fg); font-weight: 600; }
.type-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 460px) { .type-legend { grid-template-columns: 1fr; } }
.type-legend > div { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-btn); background: var(--surface-2); }
.type-legend i { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 10px; background: var(--tc); color: var(--on-tc); box-shadow: 0 8px 18px -10px var(--tc); }
.type-legend i svg { width: 18px; height: 18px; stroke-width: 2; }
:root[data-mono="on"] .type-legend i { background: var(--pat-band), var(--surface-3); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line-2); }
.type-legend b { display: block; font-size: 14px; }
.type-legend span { color: var(--fg-3); font-size: 13px; line-height: 1.35; }

/* ---------- Toast & banner ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  transform: translate(-50%, 20px);
  padding: 11px 16px;
  border-radius: var(--r-btn);
  background: var(--fg); color: var(--on-fg);
  font: 600 14px var(--font-ui);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .3s var(--ease);
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Event banner: centred glass card with an icon in the event colour ---------- */
.banner {
  position: fixed; left: 50%; top: 44%;
  z-index: 45;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  min-width: min(340px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  padding: 40px 64px 34px;
  border-radius: calc(var(--r-lg) + 10px);
  background: color-mix(in oklab, var(--surface) 93%, transparent);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  backdrop-filter: blur(26px) saturate(1.5);
  border: 1px solid color-mix(in oklab, var(--bc, var(--fg)) 26%, var(--line-2));
  color: var(--fg);
  /* the huge spread dims the page around the card while it is shown */
  box-shadow: 0 0 0 100vmax color-mix(in oklab, var(--bg) 30%, transparent), 0 50px 110px -40px var(--shade), 0 30px 70px -44px var(--bc, var(--fg)), inset 0 1px 0 rgba(255, 255, 255, .06);
  opacity: 0;
  overflow: hidden;
  isolation: isolate;
}
/* soft coloured aura behind the icon */
.banner::before {
  content: '';
  position: absolute; z-index: -1;
  left: 50%; top: -70%;
  width: 150%; aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, color-mix(in oklab, var(--bc, var(--fg)) 26%, transparent), transparent 72%);
  pointer-events: none;
}
.bn-ico {
  position: relative;
  display: grid; place-items: center;
  width: 64px; height: 64px;
  margin-bottom: 20px;
  border-radius: 50%;
  background: var(--bc, var(--fg));
  color: var(--on-bc, var(--bg));
  box-shadow: 0 16px 34px -14px var(--bc, var(--fg));
}
.bn-ico::after {
  content: '';
  position: absolute; inset: -9px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in oklab, var(--bc, var(--fg)) 42%, transparent);
}
.bn-ico svg { width: 30px; height: 30px; stroke-width: 2; }
.bn-ico.init b { font: 800 26px/1 var(--font-display); letter-spacing: -0.02em; }
.bn-title { display: block; font: 800 calc(clamp(30px, 5.4vw, 54px) * var(--ds, 1))/1 var(--font-display); letter-spacing: calc(-0.035em * var(--dt, 1)); }
.bn-sub { display: block; margin-top: 14px; font: 600 11.5px/1.4 var(--font-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--fg-2); }
.bn-sub:empty { display: none; }
.banner.show { animation: bannerIn var(--bd, 1.1s) cubic-bezier(.2, .8, .2, 1) forwards; }
.banner.show .bn-ico { animation: bnIco .7s cubic-bezier(.3, 1.5, .45, 1) .05s both; }
.banner.show .bn-ico::after { animation: bnRing .9s cubic-bezier(.2, .7, .2, 1) .2s both; }
.banner.show .bn-title { animation: bnRise .55s cubic-bezier(.2, .8, .2, 1) .1s both; }
.banner.show .bn-sub { animation: bnRise .55s cubic-bezier(.2, .8, .2, 1) .18s both; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.93); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  84% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -53%) scale(.985); }
}
@keyframes bnIco { from { opacity: 0; transform: scale(.35) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes bnRing { 0% { opacity: 0; transform: scale(.75); } 55% { opacity: 1; transform: scale(1.06); } 100% { opacity: .9; transform: scale(1); } }
@keyframes bnRise { from { opacity: 0; transform: translateY(12px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@media (max-width: 560px) { .banner { padding: 30px 36px 26px; } .bn-ico { width: 52px; height: 52px; margin-bottom: 14px; } .bn-ico svg { width: 24px; height: 24px; } }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (prefers-reduced-motion: reduce) {
  .banner.show { animation: none !important; opacity: 1; }
}
@media (max-width: 560px) {
  .lockup { flex-direction: column; align-items: flex-start; gap: .28em; font-size: calc((100vw - 40px) / 8.05); }
  .mark { --cell: .2em; gap: .05em; }
}

/* ---------- Text logo, drop target ---------- */
.wordmark-text::after { content: ''; display: inline-block; width: .15em; height: .15em; margin-left: .05em; border-radius: .03em; background: var(--hi); }
.wordmark-text .ch { display: inline-block; }
.wordmark-text.in .ch { animation: wmIn .8s cubic-bezier(.16, .84, .24, 1) backwards; animation-delay: calc(var(--i) * 45ms + 80ms); }
@keyframes wmIn { from { opacity: 0; transform: translateY(.35em); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.home.drop::after {
  content: 'Pudota korttipakka';
  position: fixed; inset: 12px;
  display: grid; place-items: center;
  border: 2px dashed var(--fg-3); border-radius: var(--r-lg);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  font: 700 22px var(--font-display); color: var(--fg);
  z-index: 20; pointer-events: none;
}

/* ---------- Wrapping segmented control (pack picker) ---------- */
/* topic picker: 4 x 3 grid (3 x 4 on phones); long names wrap */
.seg.topics { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg.topics button { padding: 10px 4px 9px; justify-content: center; }
.tp-ico { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 2px; border-radius: 9px; background: color-mix(in srgb, currentColor 9%, transparent); }
.tp-ico svg { width: 18px; height: 18px; stroke-width: 1.8; }
.seg.topics button[aria-checked="true"] .tp-ico { background: color-mix(in srgb, currentColor 16%, transparent); }
.seg.topics button b { font-size: 14px; line-height: 1.15; text-align: center; max-width: 100%; overflow-wrap: anywhere; hyphens: auto; }
@media (max-width: 560px) { .seg.topics { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Kartta / Aikajana: a row of two wide tiles under the subject topics, marked with the question-type colour */
.tp-types { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.seg.topics button.tp-type { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; text-align: left; }
.tp-type .tp-ico { flex: none; width: 36px; height: 36px; margin: 0; border-radius: 10px; background: var(--tc); color: var(--on-tc); }
.tp-type .tp-ico svg { width: 20px; height: 20px; }
.seg.topics button.tp-type[aria-checked="true"] .tp-ico { background: var(--tc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--on-mc, var(--fg)) 35%, transparent); }
.tp-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.seg.topics button.tp-type b { text-align: left; }
.tp-type small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .seg.topics button.tp-type { gap: 10px; padding: 10px; } .tp-type .tp-ico { width: 32px; height: 32px; } }
.field-note:empty { display: none; }
.seg.wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.seg.wrap button b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Theme picker ---------- */
.modal.wide { width: min(920px, 100%); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 12px; margin-top: 6px; }
.theme-opt {
  display: flex; flex-direction: column; gap: 10px;
  padding: 8px 8px 12px;
  border-radius: calc(var(--r-tile) + 4px);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: border-color .25s, transform .3s var(--ease), box-shadow .3s;
}
.theme-opt:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 18px 36px -24px var(--shade); }
.theme-opt[aria-checked="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.tp-preview {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  padding: 10px;
  aspect-ratio: 16 / 10;
  border-radius: var(--r-tile);
  background: var(--p-bg);
  color: var(--p-fg);
  overflow: hidden;
}
.tp-logo { font: 800 12px/1 var(--p-logo); letter-spacing: -0.01em; text-transform: none; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-board { flex: 1; display: grid; grid-template-columns: .9fr 1.2fr; gap: 6px; min-height: 0; }
.tp-poster {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  padding: 7px;
  border-radius: calc(var(--p-r) * 1.4);
  background: var(--p-acc); color: var(--p-on);
  overflow: hidden; isolation: isolate;
}
.tp-poster::after { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--p-pat); background-size: 9px 9px; opacity: var(--p-pat-op); }
.tp-q { font: 750 11px/1.05 var(--p-display); letter-spacing: -0.02em; }
.tp-poster b { align-self: flex-end; font: 800 20px/.8 var(--p-display); letter-spacing: -0.05em; }
.tp-tiles { display: grid; grid-template-rows: repeat(4, 1fr); gap: 4px; min-height: 0; }
.tp-tile { display: flex; align-items: center; gap: 5px; padding: 0 6px 0 3px; min-height: 0; border-radius: var(--p-r); background: var(--p-surface); border: 1px solid var(--p-line); font: 600 8.5px/1 var(--p-display); color: var(--p-fg); overflow: hidden; }
.tp-tile i { font: 700 7px/1 var(--font-mono); font-style: normal; padding: 2px 3px; border-radius: calc(var(--p-r) * .6); background: var(--p-acc); color: var(--p-on); }
.theme-opt.outline .tp-tile { background: transparent; }
.theme-opt.outline .tp-tile i { background: transparent; color: var(--p-acc); box-shadow: inset 0 0 0 1px var(--p-acc); }
.theme-opt .tp-tile.ok { background: var(--p-ok); color: var(--p-on-ok); border-color: transparent; }
.theme-opt .tp-tile.bad { background: var(--p-bad); color: var(--p-on-bad); border-color: transparent; }
.tp-tile.ok i, .tp-tile.bad i { visibility: hidden; }
.tp-sw { display: flex; gap: 4px; padding: 0 4px; }
.tp-sw i { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); }
.tp-meta { display: flex; flex-direction: column; gap: 3px; padding: 0 4px; }
.tp-meta b { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 700 16px/1.2 var(--font-display); letter-spacing: -0.01em; }
.tp-meta > span { color: var(--fg-3); font-size: 13px; line-height: 1.4; }
@media (max-width: 520px) {
  .theme-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .theme-opt { padding: 6px 6px 10px; gap: 8px; }
  .tp-preview { padding: 7px; gap: 6px; }
  .tp-meta > span { display: none; }
  .tp-meta b { font-size: 14px; }
  .tp-sw i { width: 10px; height: 10px; }
  .tp-tile { font-size: 7px; }
  .tp-q { font-size: 9px; }
  .modal { padding: 20px 18px; }
}
.tp-check { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--fg); color: var(--on-fg); opacity: 0; transform: scale(.6); transition: opacity .25s, transform .35s var(--spring); }
.tp-check svg { width: 14px; height: 14px; stroke-width: 2.6; }
.theme-opt[aria-checked="true"] .tp-check { opacity: 1; transform: none; }

/* ---------- Card packs ---------- */
.pack-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 14px; }
.pack-row { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.pack-sw { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-btn); background: var(--surface-3); color: var(--fg-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.pack-sw svg { width: 20px; height: 20px; }
.pack-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pack-txt b { font-size: 15.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pack-txt span { font: 500 11.5px var(--font-mono); color: var(--fg-3); }
.pack-txt small { font-size: 13px; color: var(--fg-2); line-height: 1.35; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 16px;
  border-radius: var(--r);
  border: 1.5px dashed var(--line-2);
  background: color-mix(in oklab, var(--surface-2) 60%, transparent);
  text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.over { border-color: var(--fg-3); background: var(--surface-2); }
.dropzone b { font-size: 15px; }
.dropzone > span:last-child { font: 500 12px var(--font-mono); color: var(--fg-3); }
.dz-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); color: var(--fg); margin-bottom: 4px; }
.dz-ico svg { width: 20px; height: 20px; }
.pack-report { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r); background: color-mix(in oklab, var(--t-num) 12%, transparent); font-size: 13.5px; line-height: 1.45; }
.pack-report.bad { background: color-mix(in oklab, var(--bad) 13%, transparent); }
.pack-report ul { margin: 6px 0 0; padding-left: 18px; color: var(--fg-2); }
.pack-report small { display: block; margin-top: 4px; color: var(--fg-3); }

/* theme editor preview: staged states appear without transitions */
.tk-instant *, .tk-instant *::before, .tk-instant *::after { transition: none !important; animation-duration: 1ms !important; animation-delay: 0ms !important; }
.tp-del { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 3px 8px 3px 6px; border-radius: 99px; font: 600 11px var(--font-mono); color: var(--fg-3); box-shadow: inset 0 0 0 1px var(--line-2); }
.tp-del:hover { color: var(--fg); }
.tp-del svg { width: 12px; height: 12px; }
.theme-opt.hard .tp-tile, .theme-opt.hard .tp-poster { border: 1.5px solid var(--p-fg); box-shadow: 2px 2px 0 var(--p-fg); }

/* ---------- Brändipakka (example packs) ---------- */
.brandpack {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 40px; align-items: start;
  padding: 26px 28px 22px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: var(--bw, 1px) solid var(--line);
}
@media (max-width: 780px) { .brandpack { grid-template-columns: 1fr; padding: 22px 20px 16px; } }
.bp-title { margin: 0 0 10px; font: 700 calc(26px * var(--ds, 1)) / 1.05 var(--font-display); letter-spacing: var(--dt, -0.02em); color: var(--fg); }
.bp-pitch p { margin: 0; max-width: 42ch; font-size: 15px; line-height: 1.55; color: var(--fg-2); }
.bp-pitch p + p { margin-top: 8px; }
.bp-link { display: inline-flex; align-items: center; gap: 3px; color: var(--fg); font-weight: 650; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--line-2); white-space: nowrap; transition: text-decoration-color .2s; }
.bp-link:hover { text-decoration-color: currentColor; }
.bp-link svg { width: 15px; height: 15px; transition: transform .3s cubic-bezier(.16, .84, .24, 1); }
.bp-link:hover svg { transform: translateX(3px); }
.bp-list { display: flex; flex-direction: column; min-width: 0; }
.bp-list .label { margin-bottom: 4px; }
.bp-rows { display: flex; flex-direction: column; }
.bp-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 11px 2px; border: 0; border-bottom: 1px solid var(--line); background: none;
  color: var(--fg); text-align: left; cursor: pointer; font: inherit;
}
.bp-row:last-child { border-bottom: 0; }
.bp-row b { font: 650 15px/1.2 var(--font-ui); white-space: nowrap; }
.bp-row span { font: 500 12px var(--font-mono); color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-row svg { width: 16px; height: 16px; color: var(--fg-3); transition: transform .3s cubic-bezier(.16, .84, .24, 1), color .2s; }
.bp-row:hover svg, .bp-row:focus-visible svg { transform: translateX(3px); color: var(--fg); }
.bp-row:hover b { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.bp-row.on b::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--hi); vertical-align: 2px; }
.demo-bar {
  position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  z-index: 26;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  border: 1px solid var(--line-2);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 14px 34px -18px var(--shade);
  font-size: 13px; white-space: nowrap; max-width: calc(100% - 24px);
}
.db-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hi); box-shadow: 0 0 0 3px color-mix(in oklab, var(--hi) 25%, transparent); flex: none; }
.db-txt { overflow: hidden; text-overflow: ellipsis; color: var(--fg-2); }
.db-txt b { color: var(--fg); font-weight: 650; }
.db-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--fg); font: 600 12.5px var(--font-ui); cursor: pointer; }
.db-btn:hover { background: var(--surface-3); }
.db-btn svg { width: 14px; height: 14px; }
body[data-screen="s-game"] .demo-bar, body[data-screen="s-end"] .demo-bar { display: none; }
body.in-demo .home { padding-top: 64px; }
@media (max-width: 560px) { .db-btn span { display: none; } .db-btn { width: 30px; padding: 0; justify-content: center; } }

/* ---------- Setup: option rows with a switch (assisted player, optional rules) ---------- */
.label-opt { margin-left: 6px; font: 500 11px var(--font-mono); letter-spacing: .04em; text-transform: none; color: var(--fg-3); }
.rules { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
#f-solo .opt-row { margin-top: 10px; }
.opt-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); cursor: pointer; transition: border-color .2s, background .2s; }
.opt-row[hidden] { display: none; }
.opt-row:hover { border-color: var(--line-2); }
.opt-row:has(.tsw:checked) { border-color: color-mix(in oklab, var(--mc, var(--hi)) 60%, var(--line)); background: color-mix(in oklab, var(--mc, var(--hi)) 7%, var(--surface)); }
.opt-ico { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--fg-2); }
.opt-ico svg { width: 18px; height: 18px; stroke-width: 1.8; }
.opt-row:has(.tsw:checked) .opt-ico { background: var(--mc, var(--hi)); color: var(--on-mc, var(--ink)); }
.opt-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.opt-tx b { font-weight: 650; font-size: 15px; color: var(--fg); }
.opt-tx small { font-size: 12.5px; line-height: 1.4; color: var(--fg-3); }
.tsw { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 26px; margin: 0; border-radius: 99px; background: var(--surface-3); cursor: pointer; transition: background .2s; }
.tsw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg-2); box-shadow: 0 1px 3px var(--shade); transition: transform .25s var(--spring, ease), background .2s; }
.tsw:checked { background: var(--mc, var(--hi)); }
.tsw:checked::after { transform: translateX(18px); background: var(--on-mc, #fff); }
.tsw:focus-visible { outline: 2px solid var(--mc, var(--hi)); outline-offset: 2px; }
.opt-sub { display: flex; align-items: center; gap: 14px; padding: 4px 14px 6px 60px; }
.opt-sub[hidden] { display: none; }
.opt-sub output { min-width: 48px; text-align: right; font: 700 15px var(--font-mono); color: var(--fg); }
.opt-range { -webkit-appearance: none; appearance: none; flex: 1; height: 28px; margin: 0; background: transparent; cursor: pointer; }
.opt-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--mc, var(--hi)) var(--v, 40%), var(--surface-3) var(--v, 40%)); }
.opt-range::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--mc, var(--hi)) var(--v, 40%), var(--surface-3) var(--v, 40%)); }
.opt-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: var(--fg); border: 3px solid var(--surface); box-shadow: 0 1px 4px var(--shade); }
.opt-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--fg); border: 3px solid var(--surface); }
/* party rows: the child / assisted toggle */
.pkid { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px 6px 7px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--fg-3); font: 600 12px var(--font-ui); cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.pkid svg { width: 16px; height: 16px; stroke-width: 1.9; }
.pkid:hover { color: var(--fg); }
.pkid[aria-pressed="true"] { background: var(--mc, var(--hi)); border-color: transparent; color: var(--on-mc, var(--ink)); }
@media (max-width: 420px) { .pkid span { display: none; } .pkid { padding: 6px; } }
