/* polyglot/game.css — ことばハンター. Retro pixel look, mobile first. */
:root {
    --bg: #1b1f3a; --bg2: #262b52; --panel: #f4ecd8; --ink: #2a2238; --muted: #6d6480;
    --line: #2a2238; --gold: #ffcf3f; --red: #e8494f; --green: #3fbf5f; --blue: #3f7fe8; --sky: #8fd3ff;
    --pink: #ff7eb6; --white: #fffaf0;
    --px: 4px;
    /* One sans-serif family for everything (owner 2026-12-05: the pixel font,
       the serif IPA font and the word font did not match). The system UI face
       first (SF / Segoe / Roboto cover IPA), then CJK by page language, then
       Noto for the other scripts. */
    --cjk: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo";
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, var(--cjk),
        "Noto Sans Thai", "Noto Sans Devanagari", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Ethiopic",
        "Noto Sans Myanmar", "Noto Sans Khmer", "Noto Sans Georgian", "Noto Sans Armenian", "Noto Sans Bengali",
        "Noto Sans Tamil", "Noto Sans Telugu", "Noto Sans Kannada", "Noto Sans Malayalam", "Noto Sans Gujarati",
        "Noto Sans Gurmukhi", "Noto Sans Oriya", "Noto Sans Sinhala", "Noto Sans Lao", "Noto Sans Tibetan", sans-serif;
    --wordfont: var(--font);
    --ipafont: var(--font);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg); color: var(--white); font: 16px/1.5 var(--font);
    background-image: radial-gradient(#ffffff10 1px, transparent 1px); background-size: 12px 12px;
    overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100%; min-height: 100dvh; display: flex; flex-direction: column;
    padding: env(safe-area-inset-top) 10px calc(10px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
select { font: inherit; font-size: 16px; }   /* 16px+: iOS does not zoom in on focus */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- pixel frame ---------- */
.px {
    background: var(--panel); color: var(--ink); border: 0; position: relative;
    box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--line), 0 var(--px) 0 0 var(--line),
        calc(-1 * var(--px)) 0 0 0 var(--line), var(--px) 0 0 0 var(--line),
        inset 0 calc(-1 * var(--px)) 0 0 #d8ccb0;
    margin: var(--px);
}
.btn {
    display: block; width: calc(100% - 2 * var(--px)); min-height: 52px; padding: 12px 14px; font-size: 18px; text-align: center;
    transition: transform .06s;
}
.btn:active { transform: translateY(3px); }
.btn.primary { background: var(--gold); }
.btn.big { font-size: 22px; padding: 14px; }
.btn.blue { background: var(--blue); color: var(--white); box-shadow: 0 -4px 0 0 var(--line), 0 4px 0 0 var(--line), -4px 0 0 0 var(--line), 4px 0 0 0 var(--line), inset 0 -4px 0 0 #2a5fb8; }
.btn.ghost { background: transparent; color: var(--white); box-shadow: none; text-decoration: underline; font-size: 14px; }
.btn:disabled { opacity: .45; }
.btn small { display: block; font-size: 12px; opacity: .75; }

/* ---------- HUD ---------- */
#hud { display: flex; align-items: center; gap: 6px; padding: 8px 2px 4px; font-size: 15px; }
.hud-l { flex: 1 1 0; min-width: 0; } .hud-c { flex: 0 0 auto; text-align: center; } .hud-r { flex: 1 1 0; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
#hearts { display: inline-flex; flex-wrap: wrap; gap: 1px; line-height: 1; }
#hearts canvas { width: 18px; height: 18px; image-rendering: pixelated; }
#hearts canvas.lost { animation: heartlost .5s steps(4) forwards; }
@keyframes heartlost { 50% { transform: scale(1.6); } 100% { transform: scale(1); opacity: .9; } }
#score { color: var(--gold); min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
#score.bump { animation: bump .3s steps(3); }
@keyframes bump { 50% { transform: scale(1.4); } }
.dots { display: block; letter-spacing: 1px; font-size: 10px; color: #8a90c0; }
.dots b { color: var(--gold); font-weight: normal; } .dots i { color: var(--red); font-style: normal; }
.px-icon { background: var(--bg2); border: 0; width: 34px; height: 34px; font-size: 20px; line-height: 1;
    box-shadow: 0 -3px 0 0 #000, 0 3px 0 0 #000, -3px 0 0 0 #000, 3px 0 0 0 #000; color: var(--white); }

/* ---------- scene ---------- */
#stageWrap { position: relative; margin: 4px 4px 6px; }
#scene { display: block; width: min(100%, calc(26vh * 160 / 72)); width: min(100%, calc(26dvh * 160 / 72)); margin: 0 auto; aspect-ratio: 160 / 72; image-rendering: pixelated; image-rendering: crisp-edges;
    box-shadow: 0 -4px 0 0 #000, 0 4px 0 0 #000, -4px 0 0 0 #000, 4px 0 0 0 #000; background: var(--sky); }
#stageWrap.shake { animation: shake .3s steps(6); }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translate(-6px, 2px); } 40% { transform: translate(6px, -2px); } 60% { transform: translate(-4px, 0); } 80% { transform: translate(4px, 1px); } }
#stageWrap.flash::after { content: ""; position: absolute; inset: 0; background: #fff; animation: flash .25s steps(2) forwards; pointer-events: none; }
@keyframes flash { to { opacity: 0; } }
#combo { position: absolute; right: 8px; top: 6px; font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 #000, -2px 2px 0 #000, 2px -2px 0 #000, -2px -2px 0 #000; pointer-events: none; }
#combo.pop { animation: combopop .45s steps(4); }
@keyframes combopop { 0% { transform: scale(.4); } 60% { transform: scale(1.5) rotate(-6deg); } 100% { transform: scale(1); } }
#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-size: 30px; pointer-events: none;
    color: var(--white); text-shadow: 3px 3px 0 #000, -3px 3px 0 #000, 3px -3px 0 #000, -3px -3px 0 #000; }
#banner.go { animation: banner 1s steps(8) forwards; }
@keyframes banner { 0% { transform: scale(0); } 20% { transform: scale(1.25); } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
#banner.good { color: var(--gold); } #banner.bad { color: #ff9a9a; }

/* ---------- screen ---------- */
#screen { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; }
.card { padding: 12px 14px; }
.title { text-align: center; padding: 14px 0 4px; }
.title .logo { margin: 0; font-size: 34px; color: var(--gold); letter-spacing: 2px; font-weight: normal;
    text-shadow: 3px 3px 0 #b8402f, 6px 6px 0 #000; }
.title p { margin: 6px 0 0; color: #c6c9ec; font-size: 14px; }
.subhead { font-size: 15px; color: #c6c9ec; margin: 10px 4px 2px; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.region { padding: 10px 6px; font-size: 15px; line-height: 1.25; }
.region .em { font-size: 26px; display: block; }
.region.sel { background: var(--gold); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.mode { padding: 10px 8px; font-size: 15px; }
.mode.sel { background: var(--sky); }
.mode .em { font-size: 24px; display: block; }

/* question */
.q { text-align: center; padding: 10px 12px 12px; }
.q .meaning { font-size: 15px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.q .meaning .em { font-size: 26px; }
.q .word { font: 40px/1.3 var(--wordfont); margin: 4px 0 0; overflow-wrap: anywhere; color: var(--ink); }
.q .word.long { font-size: 30px; }
.q .ipa { font: 16px/1.3 var(--ipafont); color: var(--muted); }
.q .ask { margin-top: 6px; font-size: 17px; }
.speak { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; margin: 8px auto 0; font-size: 16px; background: var(--sky); }
.speak.big { font-size: 22px; padding: 14px 22px; }
.speak.playing { animation: pulse .5s steps(2) infinite; }
@keyframes pulse { 50% { background: #c8ecff; } }
.choices { display: flex; flex-direction: column; gap: 3px; }
.choice { font-size: 19px; padding: 13px 10px; text-align: center; }
.choice.right { background: var(--green); color: #fff; }
.choice.wrong { background: var(--red); color: #fff; }
.choice.gone { opacity: .25; text-decoration: line-through; pointer-events: none; }
.choice .sub { display: block; font: 15px/1.3 var(--wordfont); opacity: .9; }
.items { display: flex; gap: 4px; justify-content: center; margin-top: 2px; }
.item { padding: 6px 10px; font-size: 14px; background: var(--bg2); color: var(--white);
    box-shadow: 0 -3px 0 0 #000, 0 3px 0 0 #000, -3px 0 0 0 #000, 3px 0 0 0 #000; margin: 3px; border: 0; }
.item b { color: var(--gold); font-weight: normal; }
.item:disabled { opacity: .35; }

/* reveal */
.reveal { padding: 10px 12px; }
.reveal h2 { margin: 0; font-size: 22px; font-weight: normal; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reveal .native { font: 15px var(--wordfont); color: var(--muted); }
.reveal .new { background: var(--pink); color: #fff; font-size: 12px; padding: 1px 6px; }
.reveal .facts { margin: 6px 0 0; font-size: 14px; color: var(--ink); display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.reveal .facts dt { color: var(--muted); } .reveal .facts dd { margin: 0; }
.reveal .bigword { font: 28px/1.3 var(--wordfont); margin: 6px 0 0; }
.others { margin-top: 8px; font-size: 13px; color: var(--muted); }
.others span { display: inline-block; margin-right: 10px; }
.others bdi { font-family: var(--wordfont); color: var(--ink); }
.minimap { display: block; width: 100%; max-height: 150px; object-fit: contain; image-rendering: pixelated; margin-top: 8px; background: #2f6db5; }

/* intro (new languages) */
.intro h2 { margin: 0 0 4px; font-size: 18px; font-weight: normal; color: var(--pink); }
.intro .lang { font-size: 24px; }
.intro .example { font: 30px/1.3 var(--wordfont); margin: 6px 0 0; }
.owl { display: flex; gap: 8px; align-items: flex-start; }
.owl canvas { width: 48px; height: 48px; image-rendering: pixelated; flex: 0 0 48px; }
.owl .say { flex: 1; font-size: 15px; }

/* puzzle */
.pz-head { text-align: center; font-size: 17px; margin: 4px 0; }
.pz { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.pz .col { display: flex; flex-direction: column; gap: 2px; }
.tile { padding: 12px 6px; font-size: 16px; min-height: 58px; display: flex; align-items: center; justify-content: center; text-align: center; flex-direction: column; }
.tile.w { font: 20px/1.25 var(--wordfont); }
.tile.sel { background: var(--gold); }
.tile.done { pointer-events: none; color: #fff; }
.tile.bad { animation: shake .3s steps(6); background: #ffb0b0; }

/* clear / map / dex */
.stars { text-align: center; font-size: 40px; letter-spacing: 4px; }
.stars span { display: inline-block; filter: grayscale(1) brightness(.6); }
.stars span.on { filter: none; animation: starpop .4s steps(4) backwards; }
@keyframes starpop { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.4); } }
.tally { font-size: 16px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.tally b { color: #b8402f; font-weight: normal; text-align: right; }
.worldmap { display: block; width: 100%; image-rendering: pixelated; background: #2f6db5; box-shadow: 0 -4px 0 0 #000, 0 4px 0 0 #000, -4px 0 0 0 #000, 4px 0 0 0 #000; margin: 4px; width: calc(100% - 8px); }
.bars { font-size: 13px; display: grid; grid-template-columns: auto 1fr auto; gap: 3px 8px; align-items: center; }
.bar { height: 10px; background: #d8ccb0; } .bar i { display: block; height: 100%; background: var(--green); }
.rank { text-align: center; font-size: 15px; color: var(--gold); }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 2px; }
.dex button { padding: 8px 4px; font-size: 13px; line-height: 1.25; }
.dex button .w { display: block; font: 18px/1.3 var(--wordfont); }
.dex button.lock { opacity: .35; }
.row { display: flex; gap: 2px; }
.row > * { flex: 1; }
.small { font-size: 12px; color: #a9acd0; text-align: center; margin: 4px; }
.small a { color: #c6c9ec; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; image-rendering: pixelated; width: 100%; height: 100%; }
.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal .card { max-width: 420px; width: 100%; max-height: 90vh; overflow: auto; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 15px; gap: 8px; }
.toggle select, .toggle button { font: inherit; }
@media (min-width: 560px) { .choices.c3 { grid-template-columns: 1fr 1fr; } .choices.c3 .choice:last-child { grid-column: 1 / -1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* ---------- 2026-12 mobile pass ---------- */
/* the main action sits at the bottom, in thumb reach, on every screen */
.dock { position: sticky; bottom: 0; z-index: 5; margin-top: auto; padding: 8px 0 calc(4px + env(safe-area-inset-bottom));
    background: linear-gradient(transparent, var(--bg) 30%); }
.dock .btn { margin-top: 4px; margin-bottom: 4px; }
.regions .region { min-height: 72px; }
.region[aria-pressed="true"] { box-shadow: 0 -4px 0 0 var(--line), 0 4px 0 0 var(--line), -4px 0 0 0 var(--line), 4px 0 0 0 var(--line), inset 0 0 0 3px #fff; }

/* question: the meaning is spelled out in the player's language, not only an emoji */
.q .meaning { color: var(--ink); font-size: 20px; gap: 8px; }
.q .meaning .em { font-size: 30px; line-height: 1; }
.q .meaning .lab { background: #fff6dc; padding: 1px 10px; border: 2px solid #d8ccb0; }
.q .word { font-size: 42px; margin-top: 6px; }
.q .ipa { display: flex; align-items: center; justify-content: center; gap: 6px; }
.speak.sm { margin: 0; padding: 4px 10px; font-size: 16px; min-width: 44px; min-height: 36px; justify-content: center; }
.choices { display: grid; grid-template-columns: 1fr; gap: 4px; }
.choices.c2, .choices.c4, .choices.c5 { grid-template-columns: 1fr 1fr; }
.choices.c5 .choice:last-child { grid-column: 1 / -1; }
.choice { min-height: 58px; font-size: 18px; line-height: 1.2; padding: 10px 8px; overflow-wrap: anywhere; display: flex; align-items: center; justify-content: center; }
.choice:active { transform: translateY(3px); }
.item { display: flex; flex-direction: column; align-items: center; line-height: 1.2; min-height: 44px; padding: 6px 12px; }
.item small { font-size: 10px; color: #c6c9ec; }

/* result */
.verdict { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 26px; padding: 6px 8px;
    text-shadow: 2px 2px 0 #000; animation: verdict .35s steps(4); }
.verdict.ok { color: var(--gold); } .verdict.ng { color: #ff9a9a; }
.verdict .mark { font-size: 30px; text-shadow: none; }
.verdict small { display: block; font-size: 15px; color: var(--white); text-shadow: none; }
@keyframes verdict { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } }
.reveal .cap { font-size: 12px; color: var(--muted); }
.gloss { display: inline-flex; align-items: center; gap: 4px; font: 15px/1.3 var(--font); color: var(--muted); background: #fff6dc; border: 2px solid #d8ccb0; padding: 0 6px; }
.gloss .em { font-size: 20px; }
.reveal .bigword, .intro .example { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reveal .bigword .w, .intro .example .w { font: 28px/1.3 var(--wordfont); color: var(--ink); }
.reveal .ipa { font: 15px var(--ipafont); color: var(--muted); }
.others { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.others .picked { background: #ffd6d6; padding: 0 4px; }
.intro .lang .native { font: 15px var(--wordfont); color: var(--muted); }
.tile .gloss { font-size: 12px; margin-bottom: 4px; }
.pz-word { font-size: 28px; }

/* settings */
.mh { margin: 0 0 6px; font-weight: normal; font-size: 20px; }
.toggle { min-height: 48px; }
.toggle select { min-height: 40px; max-width: 60%; }
.sw { padding: 6px 16px; min-width: 72px; min-height: 40px; background: #d8ccb0; }
.sw.on { background: var(--green); color: #fff; }

/* short phones: shrink the scene, keep the choices on screen */
@media (max-height: 700px) {
    #scene { width: min(100%, calc(20vh * 160 / 72)); width: min(100%, calc(20dvh * 160 / 72)); }
    .q { padding: 6px 10px 8px; } .q .word { font-size: 36px; } .q .word.long { font-size: 26px; }
    .title { padding-top: 6px; }
}
[dir="rtl"] .reveal .facts { direction: rtl; }

/* ---------- 2026-12-04 fixed layout ----------
   Owner: parts moved with the length of the words and the eyes had to hunt
   for them. Every slot now has a fixed size; text in a [data-fit] box shrinks
   (game.js fit()) instead of wrapping and pushing what is below it. */
#hud { height: 50px; flex-wrap: nowrap; }
#hearts { flex-wrap: nowrap; }
#hearts.many canvas { width: 13px; height: 13px; }

.q .meaning { height: 40px; }
.q .meaning .lab { display: inline-block; white-space: nowrap; overflow: hidden; max-width: calc(100% - 52px); }
.q .word, .q .word.long { height: 56px; line-height: 56px; font-size: 42px; margin-top: 4px; white-space: nowrap; overflow: hidden; }
.q .ipa { height: 40px; }
.q .ipa .it { white-space: nowrap; overflow: hidden; min-width: 0; max-width: calc(100% - 64px); }
.q .ask { height: 26px; margin-top: 2px; white-space: nowrap; overflow: hidden; }

/* always two columns: 2 → 1 row, 3 → 2+1, 4 → 2+2, 5 → 2+2+1 */
.choices, .choices.c2, .choices.c3, .choices.c4, .choices.c5 { grid-template-columns: 1fr 1fr; }
.choices.c3 .choice:last-child, .choices.c5 .choice:last-child { grid-column: 1 / -1; }
.choice { height: 58px; min-height: 0; padding: 4px 8px; overflow: hidden; }
.choice > span { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; overflow: hidden; line-height: 1.2; }

/* items live at the bottom of the screen, like the "next" button */
.dock.items { display: flex; gap: 6px; justify-content: center; }
.dock.items .item { flex: 1 1 0; min-width: 0; margin: 3px; }
.item .nm { white-space: nowrap; }
.item small { display: block; width: 100%; white-space: nowrap; overflow: hidden; }

/* map hint: over the scene, so nothing below it moves */
.hint-over { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); width: min(46%, 170px); background: var(--panel); padding: 3px;
    box-shadow: 0 -3px 0 0 #000, 0 3px 0 0 #000, -3px 0 0 0 #000, 3px 0 0 0 #000; z-index: 3; }
.hint-over .minimap { margin: 0; max-height: none; }
.hint-over .hl { font-size: 12px; color: var(--ink); text-align: center; line-height: 1.3; }

/* result */
.verdict { height: 64px; }
.verdict .vt { display: flex; flex-direction: column; min-width: 0; max-width: calc(100% - 50px); }
.verdict .vh { white-space: nowrap; overflow: hidden; }
.verdict small { white-space: nowrap; overflow: hidden; }
.reveal .cap { height: 18px; }
.reveal h2 { height: 32px; flex-wrap: nowrap; }
.reveal h2 .nm { white-space: nowrap; overflow: hidden; min-width: 0; }
.reveal h2 .new { flex: none; }
.reveal .native { height: 20px; white-space: nowrap; overflow: hidden; }
.reveal .bigword { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; height: 46px; flex-wrap: nowrap; margin-top: 4px; }
.reveal .bigword .gloss { max-width: 40vw; min-width: 0; }
.reveal .bigword .gl { white-space: nowrap; overflow: hidden; min-width: 0; }
.reveal .bigword .w { white-space: nowrap; overflow: hidden; }
.reveal .ipa { height: 20px; white-space: nowrap; overflow: hidden; }
.reveal .facts { grid-auto-rows: 21px; }
.reveal .facts dt, .reveal .facts dd { white-space: nowrap; overflow: hidden; }
.reveal .minimap { height: 110px; max-height: none; object-fit: contain; }
.others-h { height: 18px; margin-top: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.others, .reveal .others { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 20px; height: 42px; gap: 2px 10px; margin-top: 0; }
.others span { display: block; margin: 0; white-space: nowrap; overflow: hidden; min-width: 0; }

/* puzzle tiles */
.tile { height: 58px; min-height: 0; padding: 4px 6px; overflow: hidden; }
.tile .tw { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; }
.tile .gloss { max-width: 100%; white-space: nowrap; overflow: hidden; }
.tile .tw2 { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; overflow: hidden; line-height: 1.2; }

@media (max-height: 700px) {
    #scene { width: min(100%, calc(16vh * 160 / 72)); width: min(100%, calc(16dvh * 160 / 72)); }
    .q .word, .q .word.long { height: 48px; line-height: 48px; font-size: 36px; }
    .verdict { height: 52px; font-size: 22px; } .verdict .mark { font-size: 24px; }
    .reveal { padding: 8px 12px; }
    .reveal .facts { grid-auto-rows: 19px; font-size: 13px; }
    .reveal .minimap { height: 56px; margin-top: 4px; }
    .dock { padding-top: 4px; }
}

/* ---------- 2026-12-05 type + icons ----------
   Owner: one sans-serif face; the speaker button in the same place on every
   screen; outlines drawn as a stroke, not as text shifted four ways (blurry);
   the ⭕ before "Genius!" sat low. */
html:lang(ko) { --cjk: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic"; }
html:lang(zh) { --cjk: "PingFang SC", "Noto Sans SC", "Microsoft YaHei"; }
html:lang(zh-HK) { --cjk: "PingFang HK", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei"; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* outlined text: a stroke painted under the fill (crisp at any size) */
.title .logo, #banner, #combo, .verdict .vh {
    text-shadow: none; -webkit-text-stroke: 0; paint-order: stroke fill; font-weight: 800;
}
.title .logo { -webkit-text-stroke: 6px #1b1230; letter-spacing: 1px; }
#banner { -webkit-text-stroke: 6px #000; }
#combo { -webkit-text-stroke: 5px #000; }
.verdict .vh { -webkit-text-stroke: 5px #000; paint-order: stroke fill; }
.verdict small { -webkit-text-stroke: 0; font-weight: 600; }
.reveal h2, .intro h2, .pz-head, .subhead, .rank { font-weight: 700; }

/* verdict: the mark sits on the headline's own row (it used to be centred on
   headline + second line, so next to "Genius!" — whose second line is empty —
   it hung low); the "you chose" line goes under that row */
.verdict { flex-direction: column; align-items: center; justify-content: center; gap: 0; }
.verdict .vrow { display: flex; align-items: center; justify-content: center; gap: 10px; max-width: 100%; min-width: 0; }
.verdict .vh { line-height: 1.2; white-space: nowrap; overflow: hidden; min-width: 0; max-width: calc(100vw - 90px); padding: 0 3px; }
.verdict small { max-width: 100%; line-height: 1.3; }
.verdict .mark { display: flex; flex: none; width: 36px; height: 36px; font-size: 0; line-height: 0; }
.verdict .mark svg { width: 100%; height: 100%; display: block; }
.verdict.ok .mark { color: var(--gold); } .verdict.ng .mark { color: #ff6b6b; }
@media (max-height: 700px) { .verdict .mark { width: 30px; height: 30px; } }

/* every speaker button: same size, same frame, icon centred */
.speak, .speak.sm, .speak.big { display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 44px; height: 40px; min-width: 0; min-height: 0; padding: 0; margin: var(--px); font-size: 0; line-height: 0; }
.speak .ico { width: 22px; height: 22px; display: block; color: var(--ink); }
/* the row: [left] [word] [speaker], speaker always the last 52px column */
/* (.intro .example / .reveal .bigword carried older flex rules of higher specificity) */
.q .wline, .intro .wline, .reveal .wline, .wline { display: grid; grid-template-columns: auto minmax(0, 1fr) 52px; align-items: center; column-gap: 8px; }
.wline > .speak { justify-self: end; }
.q .wline.center, .wline.center { grid-template-columns: 52px minmax(0, 1fr) 52px; column-gap: 4px; }
.wline.center .word { text-align: center; min-width: 0; }
.wline .gloss { max-width: 40vw; min-width: 0; }
.wline .gl { white-space: nowrap; overflow: hidden; min-width: 0; }
.wline .w { white-space: nowrap; overflow: hidden; min-width: 0; }
.intro .wline.example { height: 48px; margin-top: 4px; font-size: 16px; }
.intro .example .w { font-size: 26px; }
.reveal .bigword { grid-template-columns: auto minmax(0, 1fr) 52px; }
.q .ipa { justify-content: center; }
.q .ipa .it { max-width: 100%; }

/* collection tiles: word + speaker mark on one line, label below */
.dex .dw { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.dex .dw .dwl { display: grid; grid-template-columns: minmax(0, 1fr) 18px; align-items: center; column-gap: 4px; }
.dex .dw .w { font-size: 17px; white-space: nowrap; overflow: hidden; text-align: start; }
.dex .dw .spk { width: 18px; height: 18px; color: #3f7fe8; } .dex .dw .spk .ico { width: 100%; height: 100%; display: block; }
.dex .dw .dg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--muted); text-align: start; }
/* the speaker sits the same distance from the card's edge everywhere */
.q, .reveal, .intro { padding-left: 12px; padding-right: 12px; }
@media (max-height: 700px) { .q, .reveal { padding-left: 12px; padding-right: 12px; } }
/* the scene's frame is as wide as the scene, so the combo / banner / map hint
   laid over it stay inside the picture */
#stageWrap { width: min(calc(100% - 8px), calc(26vh * 160 / 72)); width: min(calc(100% - 8px), calc(26dvh * 160 / 72)); margin: 4px auto 6px; }
#stageWrap #scene { width: 100%; }
@media (max-height: 700px) {
    #stageWrap { width: min(calc(100% - 8px), calc(16vh * 160 / 72)); width: min(calc(100% - 8px), calc(16dvh * 160 / 72)); }
}
/* verdict = headline row (36) + "you chose" line (20): the box holds both, so
   the second line is never squeezed (and auto-fit never shrinks it to 9px) */
.verdict { height: 66px; padding: 4px 8px; }
.verdict .vrow, .verdict small { flex: none; }
.verdict small { height: 20px; font-size: 14px; line-height: 20px; }
@media (max-height: 700px) {
    .verdict { height: 56px; padding: 2px 8px; }
    .verdict small { height: 18px; font-size: 13px; line-height: 18px; }
}

/* ---------- 2026-12-05 result fanfare ----------
   Owner: the correct-answer screen was too plain for a game — loud, contrasty,
   exaggerated, moving. Wrong answers stay calmer, so the two feel different. */
.verdict { position: relative; isolation: isolate; height: 74px; overflow: visible; }
.verdict.ok .vh { font-size: 34px; color: #ffe14a; -webkit-text-stroke: 7px #2a1200; letter-spacing: 1px; }
.verdict.ok .vrow { animation: vpop .6s cubic-bezier(.2, 1.7, .4, 1) both, vbob 1.4s ease-in-out .7s infinite; }
.verdict.ok .mark { width: 42px; height: 42px; animation: markspin .55s cubic-bezier(.2, 1.5, .4, 1) both; }
.verdict.ok small { animation: chip .4s cubic-bezier(.2, 1.8, .4, 1) .45s both; }
.verdict .pts { color: #ffe14a; font-size: 17px; -webkit-text-stroke: 4px #2a1200; paint-order: stroke fill; }
.verdict .cmb { color: #8fe3ff; font-size: 15px; -webkit-text-stroke: 4px #08223a; paint-order: stroke fill; margin-left: 6px; }
/* rotating sunburst behind the headline, spilling over the scene above */
.verdict .rays { position: absolute; left: 50%; top: 50%; width: 340px; height: 340px; margin: -170px 0 0 -170px; z-index: -1; pointer-events: none;
    background: repeating-conic-gradient(from 0deg, #ffd84a66 0deg 9deg, transparent 9deg 22.5deg);
    -webkit-mask: radial-gradient(circle, #000 18%, transparent 62%); mask: radial-gradient(circle, #000 18%, transparent 62%);
    animation: raysin .5s ease-out both, spin 7s linear infinite; }
.verdict .spark { position: absolute; left: calc(50% + var(--x)); top: calc(50% + var(--y)); font-size: 18px; line-height: 1; color: #fff6b0;
    pointer-events: none; text-shadow: 0 0 6px #ffd84a; animation: twinkle 1.1s ease-in-out var(--d) infinite both; }
.verdict .spark:nth-child(odd) { color: #ffd84a; font-size: 13px; }
@keyframes vpop { 0% { transform: scale(0) rotate(-14deg); } 55% { transform: scale(1.35) rotate(5deg); } 75% { transform: scale(.92) rotate(-2deg); } 100% { transform: scale(1); } }
@keyframes vbob { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3px) scale(1.04); } }
@keyframes markspin { 0% { transform: scale(0) rotate(-270deg); } 70% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes chip { 0% { transform: translateY(10px) scale(.3); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes raysin { 0% { opacity: 0; scale: .2; } 100% { opacity: 1; scale: 1; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes twinkle { 0% { transform: scale(0) rotate(0); opacity: 0; } 40% { transform: scale(1.4) rotate(90deg); opacity: 1; } 100% { transform: scale(0) rotate(180deg); opacity: 0; } }
/* wrong: the ✕ slams down and the line shakes once, no rays */
.verdict.ng .vh { font-size: 26px; color: #ffb0b0; -webkit-text-stroke: 5px #2a0000; }
.verdict.ng .vrow { animation: vshake .5s ease-out .1s both; }
.verdict.ng .mark { animation: markslam .35s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes vshake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes markslam { 0% { transform: scale(2.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* the answer card: gold frame and a bouncy slide-up when right */
.reveal.ok { --line: #e6a400; animation: cardin .5s cubic-bezier(.2, 1.4, .4, 1) .12s both; }
.reveal.ok h2 .nm { background: linear-gradient(transparent 58%, #ffe27a 58%); padding: 0 2px; }
.reveal.ng { animation: cardin2 .35s ease-out .1s both; }
@keyframes cardin { 0% { transform: translateY(40px) scale(.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes cardin2 { 0% { transform: translateY(14px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* the foreign word: letters arrive one by one (or the whole word, for joined scripts) */
.lt, .wfx { display: inline-block; animation-delay: var(--d, 0ms); animation-fill-mode: both; white-space: pre; }
.lt.drop { animation-name: ltdrop; animation-duration: .45s; animation-timing-function: cubic-bezier(.2, 1.7, .4, 1); }
.lt.jump { animation-name: ltjump; animation-duration: .6s; animation-timing-function: cubic-bezier(.2, 1.6, .4, 1); color: #b8402f; }
.wfx.drop { animation-name: wfxdrop; animation-duration: .5s; animation-timing-function: cubic-bezier(.2, 1.6, .4, 1); }
.wfx.jump { animation-name: wfxjump; animation-duration: .7s; animation-timing-function: cubic-bezier(.2, 1.6, .4, 1); color: #b8402f; }
@keyframes ltdrop { 0% { transform: translateY(-0.9em) scale(.3); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes ltjump { 0% { transform: translateY(.6em) scale(0) rotate(-30deg); opacity: 0; } 60% { transform: translateY(-.35em) scale(1.35) rotate(8deg); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes wfxdrop { 0% { transform: scale(.2); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes wfxjump { 0% { transform: scale(0) rotate(-12deg); opacity: 0; } 60% { transform: scale(1.3) rotate(4deg); opacity: 1; } 100% { transform: none; opacity: 1; } }

/* speaker right after the word (owner: at the far edge it was too far away);
   the gap word → speaker is the same 10px everywhere */
.q .wline, .intro .wline, .reveal .wline, .wline { grid-template-columns: auto minmax(0, max-content) 44px; justify-content: start; column-gap: 10px; }
.reveal .bigword { grid-template-columns: auto minmax(0, max-content) 44px; }
.q .wline.center, .wline.center { display: flex; justify-content: center; align-items: center; gap: 10px; }
.wline.center > span:first-child { display: none; }
.wline.center .word { flex: 0 1 auto; min-width: 0; max-width: calc(100% - 54px); }
.wline > .speak { justify-self: start; margin: 0; }
.dex .dw .dwl { grid-template-columns: minmax(0, max-content) 18px; justify-content: start; }
@media (max-height: 700px) {
    .verdict { height: 62px; } .verdict.ok .vh { font-size: 28px; } .verdict.ok .mark { width: 34px; height: 34px; }
    .verdict .rays { width: 260px; height: 260px; margin: -130px 0 0 -130px; }
}
/* "⭕ Correct!" sits in the middle of the band between the scene and the card:
   the points / combo line is a sticker on the headline's corner, out of the flow */
.verdict.ok { justify-content: center; }
.verdict.ok small { position: absolute; right: 6px; top: -4px; height: auto; width: auto; max-width: 46%;
    transform: rotate(-8deg); animation-name: sticker; z-index: 2; line-height: 1.1; text-align: right; }
.verdict.ok .cmb { display: block; margin: 0; }
@keyframes sticker { 0% { transform: rotate(-8deg) scale(0); opacity: 0; } 70% { transform: rotate(-8deg) scale(1.4); opacity: 1; } 100% { transform: rotate(-8deg) scale(1); opacity: 1; } }
.verdict.ng small { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; }
/* even the band: the scene frame above and the card frame below differ by 4px */
.verdict { height: 70px; margin-top: 4px; }
@media (max-height: 700px) { .verdict { height: 58px; } }
.verdict.ok small { right: 18px; top: -2px; font-size: 15px; }
.verdict .pts { font-size: 20px; }
.reveal.ok .px { --line: #2a2238; }   /* gold frame on the card only, not on its buttons */
.verdict .pts { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.verdict.ok small { right: auto; inset-inline-end: 18px; }

/* ---------- 2026-12-05 round 3 ----------
   pixel lettering, finite rays kept out of the card, fact tiles, zoomed map,
   speaker button at the start of every word row */
canvas.pxt { display: inline-block; vertical-align: middle; image-rendering: pixelated; image-rendering: crisp-edges; max-width: 100%; height: auto; }
[data-pix] { -webkit-text-stroke: 0 !important; text-shadow: none !important; }
.title .logo { line-height: 1; }
#banner canvas, #combo canvas { display: inline-block; }
#combo { text-shadow: none; -webkit-text-stroke: 0; }
#banner { text-shadow: none; -webkit-text-stroke: 0; }

/* rays: spin a couple of seconds, then fade; never below the band (the card is there) */
.verdict .rays { animation: rays 2.8s ease-out both; clip-path: inset(0 0 calc(50% - 30px) 0); }
@keyframes rays { 0% { opacity: 0; scale: .2; rotate: 0deg; } 15% { opacity: 1; scale: 1; } 70% { opacity: 1; } 100% { opacity: 0; scale: 1.15; rotate: 200deg; } }
.verdict .spark { animation-iteration-count: 2; }
.verdict.ok .vrow { animation: vpop .6s cubic-bezier(.2, 1.7, .4, 1) both, vbob 1.4s ease-in-out .7s 2; }
.verdict .vh canvas { max-height: 40px; width: auto; }
.verdict.ok small { display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
.verdict small canvas { height: 22px; width: auto; }
.verdict small .cmb canvas { height: 18px; }

/* answer header: caption + pixel name + NEW + native name on one line */
.ans-h { display: flex; align-items: center; gap: 8px; height: 36px; white-space: nowrap; overflow: hidden; }
.ans-h .cap { font-size: 11px; color: var(--muted); flex: none; writing-mode: horizontal-tb; }
.ans-h .nm { font-size: 26px; flex: none; max-width: 60%; }
.ans-h .nm canvas { height: 30px; width: auto; max-width: 100%; }
.reveal.ok .ans-h .nm { background: linear-gradient(transparent 55%, #ffe27a 55%); padding: 0 3px; }
.ans-h .new { flex: none; background: var(--pink); color: #fff; font-size: 12px; padding: 1px 6px; animation: newbadge 1s steps(2) 3; }
@keyframes newbadge { 50% { transform: scale(1.2) rotate(-6deg); } }
.ans-h .native { min-width: 0; overflow: hidden; color: var(--muted); font: 14px var(--font); }

/* the word row: [speaker][word][meaning] — the button is always first */
.q .wline, .intro .wline, .reveal .wline, .wline, .reveal .bigword { grid-template-columns: 44px minmax(0, max-content) auto; justify-content: start; column-gap: 10px; }
.wline > .speak { justify-self: start; margin: 0; }
.reveal .bigword { height: 46px; margin-top: 2px; }
.reveal .bigword .gloss, .intro .wline .gloss { justify-self: start; }
.reveal .ipa, .intro .ipa { padding-inline-start: 54px; }
/* question: meaning, then [speaker][word], IPA under the word */
.q { text-align: start; }
.q .meaning { justify-content: flex-start; }
.q .wline.qw { display: grid; grid-template-columns: 44px minmax(0, 1fr); height: 60px; }
.q .wline.qw .word { text-align: start; margin: 0; }
.q .ipa { justify-content: flex-start; padding-inline-start: 54px; }
.q .ask { text-align: center; }

/* fact tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.tile-f { position: relative; height: 66px; padding: 5px 8px; overflow: visible; color: var(--ink);
    box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 -3px 0 0 #0002;
    margin: 3px; animation: tilein .45s cubic-bezier(.2, 1.6, .4, 1) var(--d, .5s) both; }
.tile-f.sp { background: #fff1b8; } .tile-f.rk { background: #ffd6e8; } .tile-f.fm { background: #d6f5d0; } .tile-f.sc { background: #d4ecff; }
.tile-f .th { font-size: 11px; color: #6d6480; white-space: nowrap; overflow: hidden; line-height: 14px; }
.tile-f .tv { font-size: 20px; font-weight: 800; line-height: 26px; height: 26px; white-space: nowrap; overflow: hidden; }
.tile-f .tv.sm { font-size: 15px; }
.tile-f.sp .tv { color: #b8402f; } .tile-f.rk .tv { color: #c0307a; font-size: 22px; }
.tile-f .tv.done { animation: numpop .4s cubic-bezier(.2, 1.8, .4, 1); }
.tile-f .ts { font-size: 11px; line-height: 14px; height: 14px; white-space: nowrap; overflow: hidden; color: var(--ink); font-weight: 600; }
.tile-f .wow { position: absolute; top: -9px; inset-inline-end: -6px; background: #e8494f; color: #fff; font-size: 12px; font-weight: 800; padding: 1px 6px;
    transform: rotate(10deg); box-shadow: 2px 2px 0 #000; animation: wow .5s cubic-bezier(.2, 2, .4, 1) calc(var(--d, .5s) + 1s) both; z-index: 2; }
@keyframes tilein { 0% { transform: scale(.3) rotate(-4deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes numpop { 50% { transform: scale(1.25); } }
@keyframes wow { 0% { transform: rotate(10deg) scale(0); } 70% { transform: rotate(10deg) scale(1.5); } 100% { transform: rotate(10deg) scale(1); } }

/* zoomed map */
.mapbox { position: relative; margin-top: 8px; }
.zmap { display: block; width: 100%; height: 84px; image-rendering: pixelated; image-rendering: crisp-edges; background: #2f6db5;
    box-shadow: 0 -3px 0 0 #000, 0 3px 0 0 #000, -3px 0 0 0 #000, 3px 0 0 0 #000; }
.mapcap { position: absolute; inset-inline-start: 6px; bottom: 4px; background: #000a; color: #fff; font-size: 12px; padding: 1px 6px; font-weight: 700; }

/* collection tiles: speaker mark first */
.dex .dw .dwl { grid-template-columns: 18px minmax(0, max-content); justify-content: start; }

@media (max-height: 700px) {
    .tile-f { height: 58px; padding: 3px 7px; } .tile-f .tv { font-size: 17px; line-height: 22px; height: 22px; }
    .zmap { height: 52px; }
    .ans-h { height: 32px; } .ans-h .nm canvas { height: 26px; }
    .reveal .bigword { height: 42px; }
    .q .wline.qw { height: 52px; }
}
.tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.tile-f { min-width: 0; }
.zmap { object-fit: cover; }
