@font-face { font-family: "Cinzel"; src: url("fonts/cinzel-latin-500-700-normal.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/nunito-latin-400-800-normal.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }

:root {
  --bg: #1b1233; --bg2: #241a44; --panel: #2c2054; --panel2: #382a68; --ink: #120c24; --text: #f4edff; --muted: #c4b6e6;
  --gold: #f0c860; --gold2: #c9a24b; --purple: #9a6bff; --good: #5fd38a; --bad: #ff6b8a; --line: #4a3a80;
  --head: "Cinzel", Georgia, serif; --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(ellipse at 50% -10%, #3a2870 0%, var(--bg) 55%, #120b24 100%) fixed; color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.4; overflow-x: hidden; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: var(--ink); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.err { color: var(--bad); min-height: 1.3em; margin: .3rem 0; font-weight: 700; }

.screen { max-width: 520px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); min-height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 4px 0 8px; }
.topbar .title { flex: 1; font-family: var(--head); font-weight: 700; font-size: 1.05rem; color: var(--gold); text-align: center; letter-spacing: .04em; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); font-size: 1.5rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.icon-btn:active, .chip-btn:active, .go:active, .key:active { transform: translateY(1px) scale(.98); }
.chip { background: var(--panel); border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: .9rem; white-space: nowrap; min-height: 32px; display: grid; place-items: center; }
.chip:empty { display: none; }

/* home */
.logo { text-align: center; padding-top: 6px; }
.kicker { margin: 0; letter-spacing: .3em; text-transform: uppercase; font-size: .72rem; color: var(--muted); }
h1 { font-family: var(--head); font-weight: 700; font-size: clamp(2rem, 9vw, 2.8rem); margin: .15em 0 0; color: var(--gold); text-shadow: 0 3px 0 #5a3d9a, 0 0 28px rgba(154, 107, 255, .5); line-height: 1.05; }
.sub { margin: .4em 0 0; color: var(--muted); }
.streakline { text-align: center; margin: .7rem 0 .2rem; font-weight: 800; color: var(--gold); min-height: 1.4em; }
.label { font-family: var(--head); font-size: .95rem; color: var(--muted); margin: 1rem 0 .4rem; text-transform: uppercase; letter-spacing: .12em; text-align: center; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme { border: 3px solid var(--line); border-radius: 16px; background: var(--panel); padding: 0 0 8px; cursor: pointer; overflow: hidden; text-align: center; }
.theme .thumb { aspect-ratio: 360 / 300; display: block; width: 100%; }
.theme b { display: block; font-family: var(--head); font-size: .78rem; line-height: 1.15; padding: 6px 4px 0; }
.theme[aria-checked="true"] { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240, 200, 96, .35), 0 6px 20px rgba(0, 0, 0, .35); background: var(--panel2); }
.theme-blurb { text-align: center; min-height: 2.6em; margin: .5rem 0 0; font-size: .92rem; color: var(--muted); }
.modes { display: grid; gap: 10px; margin: 1rem 0; }
.go { border: 2px solid var(--line); background: var(--panel); border-radius: 14px; padding: 13px 16px; font-weight: 800; font-size: 1.05rem; cursor: pointer; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.go small { font-weight: 600; color: var(--muted); font-size: .78rem; }
.go.primary { background: linear-gradient(#f4d578, #d9ac3c); color: var(--ink); border-color: #fff0b8; box-shadow: 0 4px 0 #8a6a1c; }
.go.ghost { background: transparent; }
.go:disabled { opacity: .5; cursor: not-allowed; }
.opts { display: grid; gap: 10px; background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 12px; }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 800; }
select, input[type="text"], input:not([type]), input[type="password"] { font: inherit; background: var(--ink); color: var(--text); border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 46px; }
.opt select { width: auto; max-width: 62%; }
input::placeholder { color: #8a7cb8; }
.seg { display: flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; background: var(--ink); border: 0; padding: 10px 12px; font-weight: 800; cursor: pointer; min-height: 44px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-checked="true"] { background: var(--gold); color: var(--ink); }
.home-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 1rem 0 0; }
.chip-btn { background: var(--panel); border: 2px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 800; font-size: .85rem; cursor: pointer; min-height: 40px; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 14px; margin: 0 0 12px; }
.card.center { text-align: center; }
.card h2, .card h3 { font-family: var(--head); margin: 0 0 .5rem; }
.card h2 { font-size: 1.25rem; color: var(--gold); } .card h3 { font-size: .95rem; color: var(--muted); margin-top: .8rem; }
.card label { display: block; font-weight: 800; margin: .7rem 0 .2rem; }
.card label.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.card label.check input { width: 22px; height: 22px; min-height: 0; }
.card .row { display: flex; gap: 10px; } .card .row .go { flex: 1; }
.secret { -webkit-text-security: disc; text-security: disc; letter-spacing: .08em; }
.secret.show { -webkit-text-security: none; text-security: none; }
.code-in { text-transform: uppercase; letter-spacing: .4em; text-align: center; font-weight: 800; font-size: 1.3rem; }

/* game */
#game { display: flex; flex-direction: column; gap: 6px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.scene-wrap { width: 100%; aspect-ratio: 360 / 300; max-height: 36dvh; border-radius: 16px; overflow: hidden; border: 3px solid var(--line); background: var(--ink); align-self: center; }
.scene-wrap svg { width: 100%; height: 100%; }
.status { text-align: center; font-weight: 800; color: var(--muted); font-size: .92rem; min-height: 1.3em; }
.status b { color: var(--gold); }
.word { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 5px; padding: 2px 0; }
.slot { width: var(--sw, 2.1rem); height: calc(var(--sw, 2.1rem) * 1.25); border-bottom: 4px solid var(--gold2); display: grid; place-items: center; font-family: var(--head); font-weight: 700; font-size: calc(var(--sw, 2.1rem) * .78); line-height: 1; color: var(--text); }
.slot.gap { border-bottom-color: transparent; width: calc(var(--sw, 2.1rem) * .5); }
.slot.new { animation: pop .3s; }
.slot.lost { color: var(--bad); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.rm .slot.new { animation: none; }
.wrong { text-align: center; min-height: 1.5em; font-weight: 800; letter-spacing: .12em; color: var(--bad); font-size: 1.05rem; }
.wrong .dots { letter-spacing: 0; color: var(--muted); font-size: .85rem; margin-left: .4em; }
.keys { display: grid; gap: 6px; margin-top: 4px; }
.krow { display: flex; justify-content: center; gap: 5px; }
.key { flex: 1; max-width: 44px; min-height: 48px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel); font-family: var(--head); font-weight: 700; font-size: 1.1rem; cursor: pointer; padding: 0; }
.key.hit { background: #1f5a3c; border-color: var(--good); color: #d9ffe8; }
.key.miss { background: #4a1f36; border-color: var(--bad); color: #ffd0da; text-decoration: line-through; }
.key:disabled { opacity: .85; cursor: default; }
.actions { display: flex; justify-content: center; margin-top: 4px; }
.actions .go { min-height: 44px; padding: 8px 18px; font-size: .95rem; }
.solve { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.solve input { flex: 1 1 100%; text-transform: uppercase; }
.solve .go { flex: 1; min-height: 44px; padding: 8px 12px; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; }
.pchip { flex: 0 0 auto; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 4px 10px; font-size: .78rem; font-weight: 800; min-width: 78px; text-align: center; }
.pchip.me { border-color: var(--gold); } .pchip.setter { background: var(--panel2); border-color: var(--purple); }
.pchip.won { border-color: var(--good); } .pchip.lost { border-color: var(--bad); opacity: .8; } .pchip.off { opacity: .45; }
.pchip i { font-style: normal; display: block; color: var(--muted); font-weight: 700; letter-spacing: .1em; }
.endcard { background: var(--panel); border: 3px solid var(--gold2); border-radius: 18px; padding: 14px; text-align: center; animation: rise .4s; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.rm .endcard { animation: none; }
.endcard h2 { font-family: var(--head); margin: 0; font-size: 1.35rem; color: var(--gold); }
.endcard .theword { font-family: var(--head); font-weight: 700; font-size: 1.5rem; letter-spacing: .08em; margin: .4rem 0 0; }
.endcard .meaning { margin: .2rem 0 .6rem; color: var(--muted); }
.endcard .btns { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 8px; }
.endcard .btns .go:only-child { grid-column: 1 / -1; }
.endcard .share { font-family: ui-monospace, Consolas, monospace; background: var(--ink); border-radius: 10px; padding: 8px; margin: .5rem 0; white-space: pre-wrap; }
.stand { list-style: none; margin: .4rem 0 0; padding: 0; text-align: left; counter-reset: s; }
.stand li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--line); counter-increment: s; }
.stand li::before { content: counter(s) "."; width: 1.6em; color: var(--muted); font-weight: 800; }
.stand .nm { flex: 1; font-weight: 800; } .stand .pt { font-weight: 800; color: var(--gold); } .stand .add { color: var(--good); font-size: .85rem; font-weight: 800; }
.stand .tag { font-size: .7rem; color: var(--purple); font-weight: 800; border: 1px solid var(--purple); border-radius: 6px; padding: 0 4px; margin-left: 4px; }

/* online */
.roomcode { font-family: var(--head); font-size: 2.6rem; font-weight: 700; letter-spacing: .3em; color: var(--gold); padding: 2px 0 8px .3em; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plist li.off { opacity: .5; } .plist .name { flex: 1; font-weight: 800; }
.tag { font-size: .7rem; font-weight: 800; border: 1px solid var(--gold2); border-radius: 6px; padding: 1px 6px; color: var(--gold); }
.plist button { background: transparent; border: 1px solid var(--bad); color: var(--bad); border-radius: 8px; padding: 4px 8px; cursor: pointer; font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--gold); color: var(--ink); font-weight: 800; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; z-index: 40; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.rm .toast { transition: none; }
@media (max-height: 700px) { .scene-wrap { max-height: 30dvh; } .key { min-height: 42px; } }
@media (min-width: 700px) { .screen { padding-top: 24px; } .key { min-height: 54px; } }
.stand.plain li::before { content: none; width: 0; }

/* Ad-prep: a phone on its side (844x390): the scene on the left, the word and the keyboard on the right, all on one screen */
@media (orientation: landscape) and (max-height: 520px) {
  #game { max-width: 900px; display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); column-gap: 16px; row-gap: 4px; align-content: start; min-height: 0; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  #game > .topbar, #game > .strip { grid-column: 1 / -1; padding: 0 0 2px; }
  #game .icon-btn { width: 44px; height: 44px; }
  #game > .scene-wrap { grid-column: 1; grid-row: 3 / span 8; max-height: none; align-self: start; }
  #game > .status, #game > .word, #game > .wrong, #game > .play, #game > .endcard, #game > .sr-only { grid-column: 2; }
  #game .key { min-height: 40px; }
  #game .keys { gap: 4px; margin-top: 0; }
  #game .actions { margin-top: 2px; }
  #game .actions .go { min-height: 40px; padding: 4px 14px; }
  #game .wrong { min-height: 1.2em; }
  #game .endcard { padding: 8px 12px; }
  #game .endcard .meaning { margin: .1rem 0 .3rem; }
}
.skip { min-height: 44px; display: inline-flex; align-items: center; padding: 10px 18px; font-weight: 800; }
