:root {
  --bg: #eef3f9;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #5d6678;
  --line: #dde3ec;
  --black: #1a1a1a;
  --red: #dd0000;
  --gold: #ffce00;
  --good: #1f9d55;
  --good-bg: #e7f6ed;
  --bad: #d64545;
  --bad-bg: #fdecec;
  --accent: #2457d6;
  --accent-bg: #e8efff;
  --shadow: 0 6px 20px rgba(20, 30, 50, .12);
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: #bfe3ff;
  color: var(--ink);
  overflow: hidden;
  height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- hub ---------- */
#hub { position: fixed; inset: 0; }
#hub canvas { display: block; width: 100%; height: 100%; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(6px);
  padding: 8px 14px 8px 10px; border-radius: 14px; box-shadow: var(--shadow);
  min-width: 0;
}
.brand b { display: block; font-size: 1.05rem; }
.brand small { display: block; color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flag { display: grid; grid-template-rows: repeat(3, 6px); width: 26px; border-radius: 3px; overflow: hidden; flex: none; }
.flag i:nth-child(1), .welcome-flag i:nth-child(1) { background: #000; }
.flag i:nth-child(2), .welcome-flag i:nth-child(2) { background: var(--red); }
.flag i:nth-child(3), .welcome-flag i:nth-child(3) { background: var(--gold); }
.top-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.pill {
  background: rgba(255, 255, 255, .92); padding: 8px 12px; border-radius: 999px;
  font-weight: 700; font-size: .9rem; box-shadow: var(--shadow); white-space: nowrap;
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); font-size: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:active { transform: scale(.94); }

#hint-drag {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 4;
  background: rgba(26, 26, 26, .75); color: #fff; padding: 6px 12px; border-radius: 999px;
  font-size: .8rem; pointer-events: none; transition: opacity .5s; white-space: nowrap;
}
#hint-drag.gone, body.flat #hint-drag { opacity: 0; }

#nextcard {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  display: flex; justify-content: center; pointer-events: none;
}
.next {
  pointer-events: auto; width: 100%; max-width: 520px;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 20px; padding: 12px 12px 12px 16px; box-shadow: var(--shadow);
  border-top: 4px solid var(--gold);
}
.next .emo { font-size: 2.1rem; }
.next > div { flex: 1; min-width: 0; }
.next small { display: block; color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.next b { display: block; font-size: 1.1rem; }
.next .muted { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next .btn { flex: none; }

/* fallback list (no WebGL) */
body.flat { background: var(--bg); }
.daylist { display: grid; gap: 10px; max-width: 520px; margin: 0 auto; padding: 96px 16px 140px; height: 100%; overflow: auto; }
.day {
  display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.day .emo { font-size: 2rem; }
.day > span:nth-child(2) { flex: 1; }
.day small { display: block; color: var(--muted); }
.day .st { color: #f5b700; font-size: 1.2rem; }
.day.locked { opacity: .55; }
.day.next { border-color: var(--gold); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; min-height: 50px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--black); color: #fff; font-weight: 700; font-size: 1rem;
  transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.gold { background: var(--gold); color: var(--black); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
.btn.danger { color: var(--bad); }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.actions .btn { flex: 1 1 140px; max-width: 280px; }

/* ---------- level screen ---------- */
.level {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column; animation: rise .3s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.lvl-head {
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.lvl-head .icon-btn { box-shadow: none; background: var(--bg); }
.lvl-title { flex: 1; min-width: 0; }
.lvl-title small { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; font-weight: 600; letter-spacing: .04em; }
.lvl-title b { font-size: 1.1rem; }
.steps { display: flex; gap: 5px; }
.steps i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.done { background: var(--good); }
.steps i.now { background: var(--gold); }
.stage {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  width: 100%; max-width: 580px; margin: 0 auto;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.instr { background: var(--card); border-radius: var(--radius); padding: 14px 16px; border-left: 5px solid var(--gold); box-shadow: 0 2px 8px rgba(20, 30, 50, .06); }
.instr b { font-size: 1.1rem; }
.instr p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }
.de { font-weight: 600; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }

/* cards to pick */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.card-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 108px; padding: 8px 6px; text-align: center; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: 14px; font-size: .8rem;
  transition: transform .1s, border-color .15s, background .15s;
}
.card-item .emo { font-size: 2.2rem; line-height: 1.1; }
.card-item:active { transform: scale(.96); }
.card-item.sel { border-color: var(--accent); background: var(--accent-bg); }
.card-item.good { border-color: var(--good); background: var(--good-bg); }
.card-item.bad { border-color: var(--bad); background: var(--bad-bg); animation: shake .35s; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; align-items: flex-end; animation: rise .25s ease-out; }
.msg .avatar { font-size: 1.9rem; line-height: 1; flex: none; }
.bubble {
  position: relative; background: var(--card); padding: 10px 40px 10px 12px; max-width: 82%;
  border-radius: 16px 16px 16px 4px; box-shadow: 0 2px 8px rgba(20, 30, 50, .08); line-height: 1.4;
}
.bubble .who { font-size: .72rem; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.msg.me { flex-direction: row-reverse; }
.msg.me .bubble { background: #dbe6ff; border-radius: 16px 16px 4px 16px; }
.bubble.typing { display: flex; gap: 4px; padding: 14px; }
.bubble.typing i { width: 7px; height: 7px; border-radius: 50%; background: #aab2c0; animation: blink 1s infinite; }
.bubble.typing i:nth-child(2) { animation-delay: .15s; }
.bubble.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .2; } }
.speak {
  position: absolute; right: 6px; top: 6px; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--bg); cursor: pointer; font-size: .85rem;
}
.options { display: grid; gap: 8px; padding-top: 4px; }
.opt {
  text-align: left; padding: 12px 14px; min-height: 52px; cursor: pointer;
  border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  transition: transform .08s, border-color .15s;
}
.opt:hover { border-color: #b9c3d3; }
.opt:active { transform: scale(.98); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); animation: shake .35s; opacity: .7; }
.tip { background: #fff8db; border: 1px solid #f3dd8a; border-radius: 12px; padding: 10px 12px; font-size: .92rem; line-height: 1.4; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake { animation: shake .35s; }

/* waiting room */
.waiting { display: flex; gap: 12px; justify-content: center; }
.ticket, .board {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 140px; height: 120px; border-radius: 14px;
}
.ticket { background: var(--card); border: 2px dashed #b9c3d3; }
.ticket b, .board b { font-size: 2.4rem; font-variant-numeric: tabular-nums; }
.ticket small, .board small { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.board { background: #111; color: #ffb000; font-family: ui-monospace, Consolas, monospace; }
.board span { color: #fff; }
.board.flash { animation: flash .5s 3; }
@keyframes flash { 50% { background: #333; } }

/* rubbish game */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); padding: 10px 14px; border-radius: 14px; }
.timebar { flex: 1; height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--good); transition: width .1s linear; }
.timebar i.low { background: var(--bad); }
.trash-wrap { display: flex; justify-content: center; padding: 12px 0; min-height: 210px; align-items: center; }
.trash {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  width: 200px; padding: 18px 12px; background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  transition: transform .28s ease-in, opacity .28s;
}
.trash .emo { font-size: 4.2rem; line-height: 1.1; }
.trash .de { font-size: 1.15rem; }
.trash.pop { animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.bins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: auto; }
.bin {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-height: 96px; padding: 18px 2px 8px; border: none; border-radius: 10px 10px 16px 16px; cursor: pointer;
  font-size: .72rem; text-align: center; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .18);
}
.bin .lid { position: absolute; top: -4px; left: -3px; right: -3px; height: 12px; border-radius: 6px; background: inherit; filter: brightness(.8); }
.bin b { font-size: .78rem; line-height: 1.15; }
.bin .en { color: inherit; opacity: .85; font-size: .68rem; }
.bin:active { transform: translateY(3px); }
.bin-legend { display: grid; gap: 8px; }
.bin-legend > div { display: flex; align-items: center; gap: 10px; background: var(--card); padding: 10px 12px; border-radius: 12px; }
.bin-legend i { width: 22px; height: 26px; border-radius: 4px 4px 7px 7px; flex: none; }
.bin-legend span { color: var(--muted); margin-left: auto; font-size: .88rem; text-align: right; }

/* supermarket */
.shop { display: grid; grid-template-columns: minmax(120px, 0.8fr) 2fr; gap: 12px; align-items: start; }
.list-paper {
  background: #fffdf3; border-radius: 6px; padding: 12px; box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(transparent 0 27px, #e7e1c6 27px 28px);
  transform: rotate(-1.2deg);
}
.list-paper ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.list-paper li::before { content: '☐ '; }
.list-paper li.done { text-decoration: line-through; color: var(--muted); }
.list-paper li.done::before { content: '☑ '; color: var(--good); }
body.show-en .list-paper .en { display: inline; margin-left: 4px; }
.shelf {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: #c79a6b; padding: 10px; border-radius: 10px;
  box-shadow: inset 0 -8px 0 #a77a4b;
}
.shelf-item {
  aspect-ratio: 1; font-size: 2.2rem; border: none; border-radius: 10px; background: #fff7ec; cursor: pointer;
  transition: transform .1s, opacity .2s;
}
.shelf-item:active { transform: scale(.92); }
.shelf-item.taken { opacity: .25; }

/* U-Bahn map */
.netmap { width: 100%; max-height: 58vh; background: var(--card); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(20, 30, 50, .06); }
.netmap .line { fill: none; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; transition: stroke .3s; }
.netmap .line.closed { stroke: #c4c9d2; stroke-dasharray: 2 12; }
.netmap .station { cursor: pointer; outline: none; }
.netmap .station .hit { fill: transparent; }
.netmap .station .dot { fill: #fff; stroke: #1d2433; stroke-width: 3; transition: r .2s; }
.netmap .station text { font-size: 12.5px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.netmap .station.reach .dot { fill: var(--gold); r: 10; animation: glow 1s infinite alternate; }
@keyframes glow { to { stroke: var(--accent); stroke-width: 5; } }
.netmap .flag { font-size: 18px; }
.netmap .me { transition: transform .45s ease-in-out; pointer-events: none; }
.netmap .me circle { fill: var(--red); stroke: #fff; stroke-width: 3; }
.netmap .me text { font-size: 14px; }
.legend { display: flex; gap: 6px; justify-content: center; }
.chip { color: #fff; font-weight: 800; font-size: .8rem; padding: 3px 10px; border-radius: 6px; }

/* neighbour */
.door { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px 0; font-size: 1.4rem; }
.door .emo { font-size: 5rem; }
.ring { animation: ring .6s ease-in-out 3; transform-origin: top center; }
@keyframes ring { 25% { transform: rotate(18deg); } 75% { transform: rotate(-18deg); } }
.hearts { letter-spacing: 2px; }

/* result */
.result { display: flex; flex-direction: column; gap: 14px; text-align: center; padding-top: 10px; }
.result .big { font-size: 4.2rem; }
.result h2 { margin: 0; font-size: 1.7rem; }
.stars { display: flex; justify-content: center; gap: 10px; }
.stars span { font-size: 3.2rem; color: #d5d9e0; }
.stars span.on { color: #f5b700; animation: starpop .45s both; }
@keyframes starpop { from { transform: scale(0) rotate(-45deg); } 70% { transform: scale(1.3); } }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; text-align: left; }
.card p { margin: 6px 0 0; line-height: 1.5; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-word { background: var(--accent-bg); color: var(--accent); font-weight: 600; padding: 5px 10px; border-radius: 999px; font-size: .88rem; }
.fact { border-left: 5px solid var(--red); }

/* modal */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 30, .5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 440px; max-height: 90dvh; overflow: auto;
  background: var(--bg); border-radius: 22px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  display: flex; flex-direction: column; gap: 12px; animation: rise .25s ease-out;
}
.modal h2, .modal h3 { margin: 0; }
.modal p { margin: 0; line-height: 1.5; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.modal label small { color: var(--muted); font-weight: 400; }
.modal input[type=text] {
  font: inherit; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
.modal input[type=text]:focus { outline: none; border-color: var(--accent); }
.welcome-flag { display: grid; grid-template-rows: repeat(3, 8px); width: 64px; border-radius: 4px; overflow: hidden; }
.switch { flex-direction: row !important; align-items: center; justify-content: space-between; background: var(--card); padding: 12px 14px; border-radius: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 46px; height: 28px; border-radius: 14px; background: #c4c9d2; position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 2px; }
.wordlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.wordlist li { position: relative; display: flex; flex-direction: column; background: var(--card); padding: 10px 44px 10px 12px; border-radius: 12px; }
.wordlist li span { color: var(--muted); font-size: .9rem; }
.wordlist .speak { top: 50%; transform: translateY(-50%); right: 8px; }
.cert { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; background: var(--card); border: 3px double #c9a227; border-radius: 14px; padding: 22px 16px; }
.cert > small { text-transform: uppercase; letter-spacing: .12em; color: #a07d10; font-weight: 700; }
.cert h2 { font-size: 2rem; font-family: Georgia, "Times New Roman", serif; }
.cert-stats { display: flex; gap: 22px; margin: 6px 0; }
.cert-stats b { display: block; font-size: 1.4rem; }
.cert-stats small { color: var(--muted); }

.toast {
  position: fixed; left: 50%; top: max(76px, calc(env(safe-area-inset-top) + 64px)); transform: translateX(-50%); z-index: 60;
  background: var(--black); color: #fff; padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px);
  font-size: .92rem; box-shadow: var(--shadow); animation: fade .2s; text-align: center;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 400px) {
  .brand small { display: none; }
  .shop { grid-template-columns: 1fr; }
  .shelf { grid-template-columns: repeat(4, 1fr); }
  .list-paper { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- tap-to-translate ---------- */
.en { display: none; color: var(--muted); font-size: .84em; font-weight: 400; margin-top: 2px; }
body.show-en .en, .trw.reveal .en { display: block; }
.trw { display: block; }
.tr {
  display: inline-flex; align-items: center; justify-content: center; margin-top: 4px;
  font-size: .68rem; font-weight: 800; letter-spacing: .06em; color: var(--accent);
  background: var(--accent-bg); border-radius: 6px; padding: 2px 7px; cursor: pointer; user-select: none;
}
.trw.reveal .tr { background: var(--accent); color: #fff; }
body.show-en .tr { display: none; }
.tr.demo { margin: 0 2px; vertical-align: 1px; }
.w {
  cursor: help; border-radius: 3px;
  text-decoration: underline dotted rgba(36, 87, 214, .45); text-underline-offset: 4px; text-decoration-thickness: 2px;
  -webkit-touch-callout: none;
}
button .w { text-decoration-color: rgba(0, 0, 0, .18); }
.w.seen { text-decoration-style: solid; text-decoration-color: rgba(31, 157, 85, .55); }
.w:hover { background: rgba(36, 87, 214, .08); }
.wpop {
  position: fixed; z-index: 80; display: flex; align-items: center; gap: 10px; max-width: min(320px, calc(100vw - 16px));
  background: #1d2433; color: #fff; padding: 10px 10px 10px 14px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  animation: fade .15s;
}
.wpop b { font-size: 1.05rem; white-space: nowrap; }
.wpop span { color: #c9d3e6; font-size: .92rem; }
.wpop::after { content: ''; position: absolute; left: calc(var(--arrow) - 7px); width: 14px; height: 14px; background: #1d2433; transform: rotate(45deg); }
.wpop.above::after { bottom: -6px; }
.wpop.below::after { top: -6px; }
.wpop-say { flex: none; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255, 255, 255, .12); cursor: pointer; }
.hintline { background: var(--accent-bg); border-radius: 12px; padding: 10px 12px; font-size: .92rem; }

/* ---------- 3D map labels ---------- */
.blabels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.blabel {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; will-change: transform;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: rgba(255, 255, 255, .95); border: 2px solid transparent; border-radius: 14px; padding: 6px 12px 7px;
  box-shadow: 0 6px 16px rgba(20, 30, 50, .22); font: inherit; color: var(--ink); white-space: nowrap;
}
.blabel::after { content: ''; position: absolute; bottom: -7px; left: calc(50% - 6px); width: 12px; height: 12px; background: inherit; transform: rotate(45deg); border-right: inherit; border-bottom: inherit; }
.blabel small { font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.blabel b { font-size: .95rem; }
.blabel .st { font-size: .8rem; color: #f5b700; letter-spacing: 1px; }
.blabel.locked { background: rgba(236, 238, 242, .92); color: #8a8f99; }
.blabel.is-next { border-color: var(--gold); }

/* ---------- people ---------- */
.scene {
  position: relative; display: flex; align-items: flex-end; gap: 12px; min-height: 150px; overflow: hidden;
  border-radius: 20px; padding: 0 16px 0 6px;
  background: radial-gradient(circle at 25% 30%, rgba(255, 255, 255, .7), transparent 60%), var(--scene);
}
.scene .portrait { width: 150px; height: 150px; flex: none; object-fit: cover; margin-bottom: -2px; }
.scene .portrait.emo { display: flex; align-items: center; justify-content: center; font-size: 5rem; }
.nameplate { display: flex; flex-direction: column; gap: 2px; padding-bottom: 18px; min-width: 0; }
.nameplate b { font-size: 1.25rem; }
.nameplate .role { color: var(--muted); font-weight: 500; font-size: .9rem; }
img.avatar { width: 40px; height: 40px; border-radius: 50%; background: #e3eaf3; flex: none; object-fit: cover; }
.msg.me img.avatar { background: #dbe6ff; }
.avatar.emo { font-size: 1.9rem; line-height: 1; flex: none; }
.field-title { font-weight: 600; }
.field-title small { color: var(--muted); font-weight: 400; }
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.av { aspect-ratio: 1; border-radius: 16px; border: 3px solid var(--line); background: var(--card); padding: 0; cursor: pointer; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av .emo { font-size: 2rem; }
.av.on { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 206, 0, .35); }
.cert-face { width: 96px; height: 96px; border-radius: 50%; background: #e8eef6; }
.lbl { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.call .de { display: block; }

/* ---------- free movement ---------- */
.joy {
  position: fixed; z-index: 6; display: none; touch-action: none;
  left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 104px);
  width: 124px; height: 124px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .25), rgba(255, 255, 255, .45));
  border: 2px solid rgba(255, 255, 255, .8); box-shadow: 0 6px 18px rgba(20, 30, 50, .25); backdrop-filter: blur(4px);
}
.joy .knob {
  position: absolute; left: calc(50% - 28px); top: calc(50% - 28px); width: 56px; height: 56px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 4px 10px rgba(0, 0, 0, .25); pointer-events: none;
}
@media (pointer: coarse) { .joy { display: block; } }
.joy[hidden] { display: none !important; }
#enterbtn {
  position: fixed; z-index: 6; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 112px);
  flex-direction: column; gap: 0; padding: 10px 20px; box-shadow: var(--shadow); animation: pop .25s ease-out;
}
#enterbtn small { font-size: .7rem; font-weight: 600; opacity: .75; }
#enterbtn.locked { background: #e9ebef; color: var(--muted); }
#hint-drag { white-space: normal; text-align: center; max-width: calc(100% - 32px); }

/* ---------- small and landscape phones ---------- */
@media (max-width: 360px) {
  .brand { padding: 6px 10px 6px 8px; }
  .brand b { font-size: .95rem; }
  .pill { padding: 6px 9px; font-size: .82rem; }
  .icon-btn { width: 38px; height: 38px; }
  .grid3 { gap: 6px; }
  .card-item { min-height: 96px; font-size: .72rem; }
  .card-item .emo { font-size: 1.9rem; }
  .bin { min-height: 84px; font-size: .64rem; }
  .bin b { font-size: .68rem; }
  .next .emo { display: none; }
  .scene .portrait { width: 124px; height: 124px; }
}
@media (max-height: 520px) {
  #topbar { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .brand small, #hint-drag { display: none; }
  #nextcard { padding-top: 6px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .next { padding: 6px 8px 6px 12px; max-width: 460px; }
  .next .emo { display: none; }
  .next .muted { display: none; }
  .next .btn { min-height: 42px; padding: 8px 14px; }
  .joy { width: 104px; height: 104px; bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + 70px); }
  .joy .knob { left: calc(50% - 24px); top: calc(50% - 24px); width: 48px; height: 48px; }
  #enterbtn { bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + 74px); }
  .lvl-head { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .stage { padding-top: 10px; gap: 10px; }
  .scene { min-height: 96px; }
  .scene .portrait { width: 96px; height: 96px; }
  .nameplate { padding-bottom: 10px; }
  .trash-wrap { min-height: 130px; padding: 4px 0; }
  .trash { padding: 8px 12px; }
  .trash .emo { font-size: 2.6rem; }
  .bin { min-height: 64px; padding-top: 12px; }
  .grid3 { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .card-item { min-height: 84px; }
  .netmap { max-height: 70vh; }
  .modal { max-height: 94dvh; padding: 14px; gap: 8px; }
  .avatars { grid-template-columns: repeat(4, 72px); }
}
.card-item .de { overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
@media (max-width: 400px) {
  .card-item .de { font-size: .68rem; }
  .blabel { padding: 4px 9px 5px; border-radius: 12px; }
  .blabel b { font-size: .82rem; }
  .blabel small { font-size: .56rem; }
  .blabel .st { font-size: .7rem; }
}

/* ---------- map buttons (zoom / turn / back to me) ---------- */
#hub { touch-action: none; }
body { touch-action: manipulation; }
.stage, .modal, .daylist { touch-action: pan-y; }
.mapctrl {
  position: fixed; z-index: 6; right: max(12px, env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px;
}
.mapctrl[hidden] { display: none; }
.mapctrl button {
  width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: var(--shadow);
  font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.mapctrl button:active { transform: scale(.94); }
.mapctrl button.lit { background: var(--gold); }

/* ---------- phones: keep the map screen calm ---------- */
@media (max-width: 520px) {
  .brand small, #subtitle { display: none; }
  .brand { padding: 7px 12px 7px 9px; gap: 8px; }
  .brand b { font-size: .98rem; }
  .pill { padding: 7px 10px; font-size: .85rem; }
  .icon-btn { width: 40px; height: 40px; font-size: 1.05rem; }
  .blabel { padding: 4px 9px; border-radius: 11px; gap: 0; }
  .blabel small { display: none; }
  .blabel b { font-size: .8rem; }
  .blabel .st { font-size: .62rem; line-height: 1.1; }
  .next { gap: 10px; padding: 10px 10px 10px 14px; }
  .next .emo { display: none; }
  .next small, .next .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .next small { font-size: .68rem; }
  .next b { font-size: 1rem; }
  .next .btn { padding: 10px 14px; min-height: 44px; }
  .joy { width: 108px; height: 108px; opacity: .85; }
  .joy .knob { left: calc(50% - 24px); top: calc(50% - 24px); width: 48px; height: 48px; }
  .mapctrl { top: auto; transform: none; bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 104px); gap: 5px; }
  .mapctrl button { width: 38px; height: 38px; font-size: 1.1rem; }
  #enterbtn { right: 62px; }
}
.applink { text-decoration: none; }
