/* Page furniture: the stage, overlay cards, buttons, the theme's plaques (stats, actions, the round sound and back
   buttons and the logo sign) and the lesson line. Colours come from the theme (js/themes.js sets the --skin-*
   variables); the moods (cartoon, chalk, parchment, ledger, steel) are small style presets. Carried over from the
   Nick Challenge library's shared css/game.css and css/plaques.css, without the library's header, votes and kit switch
   (as Pipeline and Territory have them). */
:root { --bg: #0d0e12; --panel: #16181f; --text: #f5f5f7; --muted: #a3a8b5; --accent: #f5a623; --cyan: #38e4ff; --good: #7dffb0; --bad: #ff3d81; --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
:root { --skin-panel: #16181f; --skin-frame: rgba(255,255,255,.14); --skin-text: #f5f5f7; --skin-accent: var(--skin-tint, #f5a623); --skin-font: var(--font); --skin-radius: 14px; }
html[data-mood="cartoon"] { --skin-radius: 20px; }
html[data-mood="steel"], html[data-mood="stone"] { --skin-radius: 8px; }
html[data-mood="parchment"] { --skin-radius: 10px; }
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--script-font, var(--font)); height: 100vh; height: 100dvh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; overscroll-behavior: none; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* the theme's backdrop behind everything: the wide picture on wide screens, the tall one on phones */
html.has-skin-bg body::before { content: ''; position: fixed; inset: 0; z-index: -1; background: linear-gradient(rgba(8,9,14,.42), rgba(8,9,14,.66)), var(--skin-bg-wide) center / cover no-repeat; }
@media (max-width: 900px) { html.has-skin-bg body::before { background-image: linear-gradient(rgba(8,9,14,.3), rgba(8,9,14,.6)), var(--skin-bg-portrait); } }
html.has-skin-bg body { background: transparent; }
html.has-skin-bg .panel { background: rgba(14,16,22,.94); }

.stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; justify-content: safe center; padding: 12px; overflow: hidden; }
.msg { position: absolute; top: 12px; left: 50%; transform: translate(-50%, -10px); background: rgba(0,0,0,.6); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: 0; transition: .25s; pointer-events: none; z-index: 5; white-space: nowrap; }
.msg.show { opacity: 1; transform: translate(-50%, 0); }
.msg.good { color: var(--good); } .msg.bad { color: var(--bad); }

/* overlay cards: they never scroll, js/ui.js zooms a card down until it fits. Every card stands on the same scene:
   the theme's own (art.splash, upright on a screen held upright), else the game's night sky */
:root { --splash-wide: url("../assets/splash-bg.jpg"); --splash-tall: url("../assets/splash-bg.jpg"); }
html.has-splash { --splash-wide: var(--reason-splash); --splash-tall: var(--reason-splash-portrait); }
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 20px; background: #0b0a24 var(--splash-wide) center / cover no-repeat; overflow: hidden; }
@media (max-aspect-ratio: 1/1) { .overlay { background-image: var(--splash-tall); } }
.overlay[hidden] { display: none; }
/* motion. An overlay comes in: the backdrop fades up, the card rises in, then its rows one after another; it leaves
   (.leaving, js/ui.js) the other way round and quicker. Entrances fill backwards only, so nothing lingers once they
   have played. Reduced motion: none of it (js/ui.js then hides a leaving overlay at once). */
:root { --ease-out: cubic-bezier(.2,.8,.2,1); --ease-in: cubic-bezier(.5,0,.75,0); }
@keyframes ovIn { from { opacity: 0; } }
@keyframes ovOut { to { opacity: 0; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(24px) scale(.95); } }
@keyframes panelOut { to { opacity: 0; transform: translateY(-14px) scale(.97); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(16px); } }
@keyframes riseOut { to { opacity: 0; transform: translateY(-10px); } }
.overlay { animation: ovIn .4s var(--ease-out) backwards; }
.overlay > .panel { animation: panelIn .6s var(--ease-out) .06s backwards, splashGlow 4s ease-in-out infinite alternate; }
.overlay .panel > * { animation: riseIn .5s var(--ease-out) backwards; animation-delay: calc(.2s + var(--i, 0) * 70ms); }
.overlay .howto > div, .overlay .facts > .fact { animation: riseIn .45s var(--ease-out) backwards; animation-delay: calc(.42s + var(--j, 0) * 55ms); }
.overlay.leaving { animation: ovOut .32s var(--ease-in) .14s forwards; pointer-events: none; }
.overlay.leaving > .panel { animation: panelOut .3s var(--ease-in) .08s forwards, splashGlow 4s ease-in-out infinite alternate; }
.overlay.leaving .panel > * { animation: riseOut .22s var(--ease-in) forwards; animation-delay: calc(var(--i, 0) * 30ms); }
.overlay.leaving .howto > div, .overlay.leaving .facts > .fact { animation: none; }
.panel > :nth-child(2) { --i: 1; } .panel > :nth-child(3) { --i: 2; } .panel > :nth-child(4) { --i: 3; } .panel > :nth-child(5) { --i: 4; }
.panel > :nth-child(6) { --i: 5; } .panel > :nth-child(7) { --i: 6; } .panel > :nth-child(8) { --i: 7; }
.howto > :nth-child(2), .facts > :nth-child(2) { --j: 1; } .howto > :nth-child(3), .facts > :nth-child(3) { --j: 2; } .facts > :nth-child(4) { --j: 3; }
.facts > :nth-child(5) { --j: 4; } .facts > :nth-child(6) { --j: 5; } .facts > :nth-child(7) { --j: 6; } .facts > :nth-child(8) { --j: 7; }
@media (prefers-reduced-motion: reduce) { .overlay, .overlay > .panel, .overlay .panel > *, .overlay .howto > div, .overlay .facts > .fact { animation: none !important; } }
/* the title card comes up with its scene from the first frame (no fade over the board); the others fade theirs in */
#ov-title { animation: none; }
#ov-title.leaving { animation: ovOut .32s var(--ease-in) .14s forwards; }
/* every card glows in purple and blue, drifting slowly between them, above its scene's motes (js/ui.js), whose light
   is added to the scene's */
.overlay > .panel { position: relative; z-index: 1; border-color: rgba(192,132,252,.6); }
.overlay > .stars { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: screen; pointer-events: none; animation: ovIn 1.4s ease-out .15s backwards; }
@keyframes splashGlow {
  from { border-color: rgba(192,132,252,.85); box-shadow: 0 0 20px 3px rgba(168,85,247,.75), 0 0 60px 12px rgba(168,85,247,.35), 0 30px 80px rgba(0,0,0,.6); }
  to { border-color: rgba(96,165,250,.85); box-shadow: 0 0 20px 3px rgba(59,130,246,.8), 0 0 60px 12px rgba(59,130,246,.38), 0 30px 80px rgba(0,0,0,.6); }
}
@media (prefers-reduced-motion: reduce) { .overlay > .panel { box-shadow: 0 0 20px 3px rgba(124,108,247,.75), 0 0 60px 12px rgba(124,108,247,.35), 0 30px 80px rgba(0,0,0,.6); } }
.panel { width: min(640px, 100%); margin: auto; text-align: center; background: rgba(22,24,31,.94); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 28px 28px 24px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
/* one card design: the title card's big script heading on every card (the others' a little smaller, they carry more) */
.panel h1 { font-size: clamp(4rem, 10vw, 6rem); line-height: 1.05; text-wrap: balance; margin: 0 0 6px; letter-spacing: -.03em; font-weight: 900; }
.panel h2 { font-size: clamp(3rem, 7vw, 4.4rem); line-height: 1.05; text-wrap: balance; margin: 0 0 12px; letter-spacing: -.03em; font-weight: 900; }
.panel h1, .panel h2 { font-family: var(--script-font, var(--skin-font)); }
.panel p { color: #d8dbe3; margin: 0 0 14px; line-height: 1.5; font-size: 15px; }
#title-intro { font-size: 30px; line-height: 1.35; }   /* the title card's sentence: twice the cards' text */
.panel .muted { color: var(--muted); font-size: 13px; }
.panel .score { margin: 4px 0 10px; font-size: 18px; font-weight: 900; color: var(--skin-accent); font-variant-numeric: tabular-nums; }
.panel .score[hidden] { display: none; }
.howto { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; text-align: start; }
.howto div { background: rgba(255,255,255,.04); border-radius: 8px; padding: 12px; font-size: 12.5px; line-height: 1.4; color: #d8dbe3; }
.howto b { display: block; color: #fff; margin-bottom: 4px; font-size: 13px; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.btn { border: 0; border-radius: 6px; padding: 12px 24px; font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.btn--primary { background: #fff; color: #000; }
.btn--primary:hover { background: rgba(255,255,255,.85); }
.btn--accent { background: var(--accent); color: #1a1100; }
.btn--ghost { background: rgba(255,255,255,.1); color: #fff; }
.btn--ghost:hover { background: rgba(255,255,255,.18); }
.btn[hidden] { display: none; }
.keys { margin-top: 14px; font-size: 12px; color: var(--muted); }
.panel .tagline { margin: -2px 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--skin-accent); }
/* the numbers on a card: two to four tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 14px 0; }
.stats > div { background: rgba(255,255,255,.04); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.stats > div[hidden] { display: none; }
.stats span { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.progress { width: min(560px, 100%); height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; margin: 4px 0 8px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--good)); transition: width .25s; }

/* the lesson line: what the theme is about */
#lesson-host { width: 100%; max-width: 100%; flex: none; }
.lesson { width: 100%; max-width: 100%; text-align: center; font-size: 13px; color: var(--muted); padding: 6px 12px 0; }
.lesson b { color: var(--skin-tint, var(--accent)); }
.lesson__text { color: #d8dbe3; }
.lesson__text::before { content: ': '; color: var(--muted); }
html.has-skin-bg .lesson { background: rgba(8,9,14,.62); border-radius: 10px; padding: 6px 12px; }
html.has-skin-bg .lesson__text { color: #fff; }

/* facts on the clear card: two columns where there is room, and at most six rows (three on phones) */
.asset { width: 100%; height: 100%; object-fit: contain; display: block; }
.asset--text { display: grid; place-items: center; font-size: 11px; font-weight: 700; text-align: center; color: #fff; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 10px 0; text-align: start; }
.fact { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,.05); font-size: 13px; line-height: 1.3; min-width: 0; }
.fact img, .fact .asset--text { width: 36px; height: 36px; flex: none; border-radius: 8px; }
.fact b { color: #fff; }
/* the card's facts are every card of the line, in its order (up to eight): one column on a narrow card */
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .howto { grid-template-columns: 1fr; gap: 4px; margin: 10px 0; }
  .howto div { padding: 6px 8px; font-size: 11.5px; line-height: 1.3; } .howto b { display: inline; margin: 0; margin-inline-end: 4px; font-size: 12px; }
  .panel { padding: 16px 14px 14px; } .panel h1 { font-size: 3.4rem; } .panel h2 { font-size: 2.6rem; } .panel p { font-size: 13.5px; margin-bottom: 10px; } #title-intro { font-size: 27px; }
  .keys { margin-top: 8px; }
  .stats { margin: 10px 0; gap: 8px; } .stats b { font-size: 17px; }
  .stage { padding: 8px; }
}
/* short viewports (phones, small laptops): the how-to cards go, the intro line carries the instructions */
@media (max-height: 700px) { .howto { display: none; } .panel { padding-top: 16px; padding-bottom: 14px; } .panel h1 { margin-bottom: 4px; } }
/* phones and short screens: the theme's name and subject only (on two lines at most), never a sentence cut short */
@media (max-width: 900px), (max-height: 700px) { .lesson { font-size: 12px; line-height: 1.3; padding-top: 4px; } .lesson__text { display: none; } }

/* ---------- plaques: a top row with the round buttons and the game's sign, stat plaques, chunky action buttons */
.column { width: min(100%, 560px); height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar__btns { display: flex; align-items: center; gap: 8px; flex: none; }
.round-btn { width: 50px; height: 50px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: var(--skin-text); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.2); flex: none; padding: 0; }
.round-btn[hidden] { display: none; }
.round-btn svg { width: 24px; height: 24px; }
/* the sound button shows the speaker, or the crossed speaker while muted */
#btn-mute .snd-off { display: none; }
#btn-mute[aria-pressed="true"] .snd-on { display: none; }
#btn-mute[aria-pressed="true"] .snd-off { display: block; }
.plaque-logo { display: flex; align-items: center; justify-content: flex-end; min-width: 0; }
.plaque-logo img { height: 66px; width: auto; max-width: 100%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); }
.plaque-logo img[hidden] { display: none; } .plaque-logo img:not([hidden]) + b { display: none; }
.plaque-logo b { font-size: clamp(1.6rem, 7vw, 2.4rem); font-weight: 900; line-height: 1.1; color: var(--skin-accent); -webkit-text-stroke: 1.5px rgba(0,0,0,.45); text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 8px 20px rgba(0,0,0,.5); font-family: var(--script-font, var(--skin-font)); }
.statrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
/* stats sit on frosted glass: the scene blurred 10px under a light black tint, readable on any backdrop */
.splaque { display: flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 12px; background: rgba(0,0,0,.28); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 0; color: var(--skin-text); min-width: 0; }
.splaque__icon { flex: none; width: 36px; height: 36px; border-radius: 9px; background: none; color: var(--skin-accent); display: grid; place-items: center; filter: drop-shadow(0 3px 5px rgba(0,0,0,.55)); }
.splaque__icon svg { width: 24px; height: 24px; }
.splaque__icon img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.splaque__icon img[hidden] { display: none; } .splaque__icon img:not([hidden]) + svg { display: none; }
.splaque div { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.splaque span { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; font-weight: 800; opacity: .95; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.6), 0 2px 5px rgba(0,0,0,.7); }
.splaque b { font-size: 1.05rem; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; unicode-bidi: isolate; align-self: flex-start; text-shadow: 0 1px 1px rgba(0,0,0,.65), 0 2px 7px rgba(0,0,0,.75); }
.actions-row { display: grid; grid-template-columns: 44px 1fr 1fr 1fr 44px; gap: 8px; align-items: center; }
.abtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 14px; border: 2px solid var(--skin-frame); background: var(--skin-panel); color: var(--skin-text); font: inherit; font-size: 15px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,.35), 0 8px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18); }
.abtn svg { width: 20px; height: 20px; }
.abtn--dark { background: linear-gradient(180deg, #2a3442, #161d27); border-color: rgba(255,255,255,.2); color: #fff; }
.abtn--hint { background: linear-gradient(180deg, #ffd766, #f5a623); color: #1a1100; border-color: #ffe9a8; }
.abtn--round { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 22px; background: rgba(0,0,0,.35); }
.abtn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18); }
.abtn[disabled] { opacity: .35; cursor: default; }
html[data-mood="steel"] .splaque, html[data-mood="steel"] .abtn, html[data-mood="steel"] .round-btn { border-radius: 0; }
@media (min-width: 900px) { .column { width: min(100%, 600px); } }
@media (max-height: 760px) { .column { gap: 6px; } .plaque-logo img { height: 54px; } .round-btn { width: 42px; height: 42px; } .splaque { padding: 5px 7px; gap: 6px; } .splaque__icon { width: 28px; height: 28px; } .splaque__icon svg { width: 18px; height: 18px; } .splaque span { font-size: 8.5px; } .splaque b { font-size: .95rem; } .abtn { height: 40px; font-size: 13px; } .abtn--round { width: 38px; height: 38px; } }
@media (max-width: 420px) { .statrow { gap: 4px; } .splaque { padding: 4px 5px; gap: 5px; border-radius: 10px; } .splaque__icon { width: 26px; height: 26px; border-radius: 7px; } .splaque__icon svg { width: 17px; height: 17px; } .splaque span { font-size: 8px; letter-spacing: .08em; } .splaque b { font-size: .9rem; } .abtn { font-size: 12px; gap: 5px; } .abtn svg { width: 16px; height: 16px; } }

@media (prefers-reduced-motion: reduce) { .msg, .progress i { transition: none; } }

/* ---------- languages (js/i18n.js sets <html lang dir> from ?lang=)
   Hebrew and Arabic are set in Rubik, one family for every script on the page (Bible rule 1, §5.5.4): switched here on
   the page's language, never by a per-glyph fallback chain. Latin keeps the theme's font. */
:root:lang(he), :root:lang(ar) { --script-font: 'Rubik', system-ui, sans-serif; }
/* letter-spacing breaks Arabic joining and does nothing for Hebrew */
html:is(:lang(he), :lang(ar)) :is(.panel h1, .panel h2, .panel .tagline, .stats span, .splaque span, .abtn, .msg, .plaque-logo b) { letter-spacing: 0; }
