/* FLIP — "Sadu board game" look.
   Every control is a game tile: raised pieces (buttons, answers, map cells) sit on a
   darker edge and sink when pressed; inputs are recessed wells. Plain background, so
   the pieces carry the look. Fonts: Alexandria (as in the logo) + Readex Pro. */
:root {
  --bg: #14233D;
  --bg-2: #1B2E4F;
  --bg-3: #24395F;
  --well: #0C1729;
  --edge: #0C1729;
  --line: rgba(246, 245, 241, .14);
  --text: #F6F5F1;
  --muted: #B9C2D3;
  --cream: #F6F5F1;
  --cream-edge: #C9C4B5;
  --pink: #E74D98;
  --pink-edge: #A3326A;
  --pink-soft: rgba(231, 77, 152, .22);
  --navy: #3E72CF;
  --navy-edge: #26498C;
  --navy-soft: rgba(62, 114, 207, .25);
  --gold: #F3BD57;
  --gold-edge: #B8862A;
  --mint: #48C79A;
  --mint-edge: #2A8E6A;
  --bad: #FF6B6B;
  --bad-edge: #B84444;
  --radius: 12px;
  --display: "Alexandria", "Readex Pro", system-ui, sans-serif;
  --font: "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; padding-bottom: 80px; }
button, input { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
h1, h2, h3 { margin: 0; font-family: var(--display); }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

/* ---------- icons and team markers ---------- */
.ic { width: 1.15em; height: 1.15em; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.gold { color: var(--gold); }
.ic.ok { color: var(--mint); }
.tdot { display: inline-block; width: .7em; height: .7em; vertical-align: .02em; }
.tdot.pink { background: var(--pink); transform: rotate(45deg) scale(.9); border-radius: 2px; }
.tdot.navy { background: var(--navy); border-radius: 50%; }

/* ---------- pieces: buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: var(--radius); padding: 14px 18px; min-height: 54px;
  font-family: var(--display); font-size: 1.08rem; font-weight: 800; white-space: nowrap;
  background: var(--cream); color: var(--bg); box-shadow: 0 5px 0 var(--cream-edge);
  margin-bottom: 5px; transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--cream-edge); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.secondary { background: var(--bg-3); color: var(--text); box-shadow: 0 5px 0 var(--edge); }
.btn.secondary:active:not(:disabled) { box-shadow: 0 1px 0 var(--edge); }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 5px 0 var(--pink-edge); }
.btn.pink:active:not(:disabled) { box-shadow: 0 1px 0 var(--pink-edge); }
.btn.navy { background: var(--navy); color: #fff; box-shadow: 0 5px 0 var(--navy-edge); }
.btn.navy:active:not(:disabled) { box-shadow: 0 1px 0 var(--navy-edge); }
.btn.gold { background: var(--gold); color: #1d1606; box-shadow: 0 4px 0 var(--gold-edge); }
.btn.gold:active:not(:disabled) { box-shadow: 0 1px 0 var(--gold-edge); }
.btn.small { padding: 8px 12px; min-height: 40px; font-size: .9rem; width: auto; display: inline-flex; margin-bottom: 3px; }
.btn.small.secondary { box-shadow: 0 3px 0 var(--edge); }
.btn.small.gold { box-shadow: 0 3px 0 var(--gold-edge); }
.row { display: flex; gap: 10px; align-items: center; }
.stack > * + * { margin-top: 12px; }
.card { background: var(--bg-2); border-radius: 16px; padding: 16px; box-shadow: 0 4px 0 var(--edge); }
.muted { color: var(--muted); }
.center { text-align: center; }
.label { font-family: var(--display); font-size: .85rem; color: var(--muted); font-weight: 700; }

/* ---------- wells: inputs ---------- */
.field {
  width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 2px solid #2A3F66;
  background: var(--well); box-shadow: inset 0 4px 0 rgba(0, 0, 0, .35); font-size: 1.1rem; min-height: 54px;
}
.field::placeholder { color: #6F7E9C; }
.field:focus { outline: none; border-color: var(--gold); }

/* ---------- landing ---------- */
.brand { text-align: center; padding: 44px 0 26px; }
.brand p { margin: 14px 0 0; color: var(--text); font-family: var(--display); font-weight: 500; font-size: 1.08rem; }
.brand mark { background: var(--pink); color: #fff; font-weight: 800; padding: 0 6px; border-radius: 5px; }
.brand .logo { margin: 0 auto; max-width: 250px; }
.brand .logo img { display: block; width: 100%; height: auto; animation: rise .6s ease; }
main > .stack > div > .label { color: var(--gold); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-family: var(--display); font-size: .85rem; font-weight: 700; }
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: repeating-linear-gradient(90deg, #2A3F66 0 6px, transparent 6px 10px); }
.code-input { text-transform: uppercase; letter-spacing: .45em; text-align: center; direction: ltr; font-family: var(--display); font-weight: 800; }
.pills { display: flex; justify-content: center; gap: 8px; margin: 26px 0 0; }
.pill { font-family: var(--display); font-weight: 700; font-size: .82rem; padding: 6px 10px; border-radius: 8px; }
.pill.pink { background: var(--pink); color: #fff; box-shadow: 0 3px 0 var(--pink-edge); }
.pill.navy { background: var(--navy); color: #fff; box-shadow: 0 3px 0 var(--navy-edge); }
.pill.cream { background: var(--cream); color: var(--bg); box-shadow: 0 3px 0 var(--cream-edge); }

/* ---------- lobby ---------- */
.room-code { display: flex; justify-content: center; gap: 8px; direction: ltr; margin: 10px 0 16px; }
.room-code span {
  width: 54px; height: 62px; border-radius: 10px; background: var(--cream); color: var(--bg);
  box-shadow: 0 5px 0 var(--cream-edge); display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 2rem;
}
.room-code span:nth-child(odd) { transform: rotate(-2deg); }
.room-code span:nth-child(even) { transform: rotate(2deg); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-col { border-radius: 16px; padding: 8px; background: var(--well); box-shadow: inset 0 3px 0 rgba(0, 0, 0, .3); min-width: 0; }
.team-col h3 { font-size: 1rem; margin: 2px 4px 10px; display: flex; justify-content: space-between; align-items: center; }
.team-col.pink h3 > span:first-child { color: #FF8DC4; }
.team-col.navy h3 > span:first-child { color: #8FB2FF; }
.chip {
  display: flex; align-items: center; gap: 5px; padding: 8px; border-radius: 10px;
  background: var(--bg-3); box-shadow: 0 3px 0 var(--edge); margin-bottom: 9px; font-size: .92rem; min-height: 42px; overflow: hidden;
}
.team-col.pink .chip { box-shadow: 0 3px 0 var(--pink-edge); }
.team-col.navy .chip { box-shadow: 0 3px 0 var(--navy-edge); }
.chip .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.me { outline: 2px solid var(--gold); }
.chip.off { opacity: .5; }
.chip .x { background: none; border: 0; color: var(--muted); padding: 0 2px; display: flex; }
.slot { border: 2px dashed #2A3F66; border-radius: 10px; padding: 6px 10px; color: var(--muted); font-size: .9rem; margin-bottom: 9px; min-height: 42px; display: flex; align-items: center; }
.tag { font-size: .7rem; padding: 2px 6px; border-radius: 5px; background: rgba(255, 255, 255, .1); color: var(--muted); font-family: var(--display); font-weight: 700; }
.tag.ok { background: var(--mint); color: #08241a; }
.tag.host { background: none; color: var(--gold); padding: 0; font-size: 1rem; display: flex; }

/* ---------- HUD ---------- */
.hud { position: sticky; top: 0; z-index: 5; background: #0E1A2F; }
.hud { box-shadow: 0 4px 0 var(--edge); }
.hud-inner { max-width: 560px; margin: 0 auto; padding: 12px 16px 10px; }
.score-strip { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.score { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; }
.score.navy { flex-direction: row-reverse; justify-content: flex-start; }
.score .num {
  width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; line-height: 1; color: #fff;
}
.score.pink .num { background: var(--pink); box-shadow: 0 4px 0 var(--pink-edge); }
.score.navy .num { background: var(--navy); box-shadow: 0 4px 0 var(--navy-edge); }
.score .nm { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-size: .9rem; }
.score.navy .nm { align-items: flex-end; }
.score .mine { font-size: .68rem; padding: 1px 6px; border-radius: 4px; background: var(--gold); color: #1d1606; transform: rotate(-4deg); }
.round-pill { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: .75rem; color: var(--muted); }
.round-pill b { font-family: var(--display); font-weight: 700; font-size: .78rem; color: var(--muted); }
.timer { display: flex; gap: 4px; margin-top: 12px; direction: ltr; }
.timer i { flex: 1; height: 8px; border-radius: 2px; background: var(--bg-3); transition: background .25s, transform .25s; }
.timer i.on { background: var(--cream); }
.timer.warn i.on { background: var(--gold); }
.timer.danger i.on { background: var(--bad); }
.timer-text { font-size: .75rem; color: var(--muted); text-align: center; margin-top: 4px; min-height: 1em; }
.mini-map { display: grid; grid-template-columns: repeat(3, 11px); gap: 3px; justify-self: center; direction: ltr; }
.mini-map i { width: 11px; height: 11px; border-radius: 3px; background: var(--bg-3); }
.mini-map i.pink { background: var(--pink); box-shadow: 0 2px 0 var(--pink-edge); }
.mini-map i.navy { background: var(--navy); box-shadow: 0 2px 0 var(--navy-edge); }

/* ---------- map ---------- */
.map {
  /* Fixed square cells: Safari mis-sizes aspect-ratio grid items, which made tiles overlap the text below. */
  --c: calc((min(310px, 100vw - 32px) - 20px) / 3);
  display: grid; grid-template-columns: repeat(3, var(--c)); grid-auto-rows: calc(var(--c) + 6px);
  gap: 4px 10px; justify-content: center; direction: ltr; margin: 14px auto 0; perspective: 600px;
}
.cell {
  width: var(--c); height: var(--c); min-width: 0; -webkit-appearance: none; appearance: none; border-radius: 14px; border: 0; position: relative;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700;
  background: var(--bg-3); color: var(--muted); box-shadow: 0 6px 0 var(--edge); margin: 0;
  transition: transform .2s, box-shadow .2s; padding: 0;
}
.cell .n { position: absolute; top: 6px; left: 8px; font-family: var(--display); font-size: .75rem; opacity: .75; }
.cell .sh { position: absolute; bottom: 5px; right: 6px; font-size: 1rem; display: flex; color: var(--gold); }
.cell > .tdot { width: 22px; height: 22px; background: rgba(255, 255, 255, .3); }
.cell.pink { background: var(--pink); color: #fff; box-shadow: 0 6px 0 var(--pink-edge); }
.cell.navy { background: var(--navy); color: #fff; box-shadow: 0 6px 0 var(--navy-edge); }
.cell.legal { outline: 3px dashed var(--gold); outline-offset: 3px; animation: pulse 1.4s infinite; }
.cell.sel { outline: 3px solid var(--gold); outline-offset: 3px; transform: translateY(4px); box-shadow: 0 2px 0 var(--edge); animation: none; }
.cell.pink.sel { box-shadow: 0 2px 0 var(--pink-edge); }
.cell.navy.sel { box-shadow: 0 2px 0 var(--navy-edge); }
.cell.target { outline: 3px solid var(--bad); outline-offset: 3px; }
.cell.flash-capture, .cell.flash-captured { animation: flip .8s cubic-bezier(.3, 1.4, .5, 1); }
.cell.flash-fortify, .cell.flash-blocked { animation: shield .8s ease; }
.cell.flash-defended { animation: shake .5s ease; }
.cell .mv { display: flex; font-size: 1.9rem; color: var(--gold); }
@keyframes pulse { 50% { outline-color: rgba(243, 189, 87, .35); } }
@keyframes flip { 0% { transform: rotateX(180deg); } 100% { transform: rotateX(0); } }
@keyframes shield { 30% { transform: scale(1.08); outline: 4px solid var(--gold); } }
@keyframes shake { 25% { transform: translateX(-5px) rotate(-2deg); } 75% { transform: translateX(5px) rotate(2deg); } }

/* ---------- phase screens ---------- */
.phase-title { text-align: center; padding: 6px 0 2px; }
.phase-title .k {
  display: inline-block; font-family: var(--display); font-size: .82rem; color: #1d1606; background: var(--gold);
  font-weight: 800; padding: 4px 10px; border-radius: 6px;
}
.phase-title h2 { font-size: 1.5rem; margin-top: 8px; }
.intro { text-align: center; padding: 26px 0 10px; }
.intro .label { color: var(--gold); }
.intro .big {
  width: 120px; height: 120px; margin: 10px auto; border-radius: 20px; background: var(--cream); color: var(--bg);
  box-shadow: 0 8px 0 var(--cream-edge); display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 4.2rem; font-weight: 800; line-height: 1; animation: flip .7s cubic-bezier(.3, 1.4, .5, 1);
}
.intro.final .big { background: var(--gold); box-shadow: 0 8px 0 var(--gold-edge); color: #1d1606; }
.final-band { background: var(--bg-2); outline: 2px dashed var(--gold); outline-offset: -2px; }
.event-card {
  border-radius: 18px; padding: 18px; background: var(--cream); color: var(--bg); box-shadow: 0 6px 0 var(--cream-edge);
  text-align: center; animation: rise .6s ease;
}
.event-card .label { color: var(--gold-edge) !important; }
.event-card .ico {
  width: 56px; height: 56px; margin: 8px auto; border-radius: 12px; background: var(--gold); color: #1d1606;
  box-shadow: 0 4px 0 var(--gold-edge); display: flex; align-items: center; justify-content: center; font-size: 1.7rem;
}
.event-card h3 { font-size: 1.3rem; margin: 4px 0; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.captain { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.captain .ic { color: var(--gold); }
.captain.me { color: var(--gold); font-weight: 700; }
.prompt {
  font-family: var(--display); font-size: 1.5rem; font-weight: 800; line-height: 1.5; text-align: center;
  padding: 24px 16px; background: var(--cream); color: var(--bg); border-radius: 16px; box-shadow: 0 6px 0 var(--cream-edge);
  position: relative; margin-bottom: 8px;
}
.prompt::before {
  content: ""; position: absolute; top: -9px; right: 18px; width: 18px; height: 18px; border-radius: 4px;
  background: linear-gradient(135deg, var(--pink) 50%, var(--navy) 50%); transform: rotate(8deg);
}
.prompt.ltr-mix { unicode-bidi: plaintext; }
.duel { display: flex; justify-content: center; align-items: center; gap: 10px; font-weight: 700; flex-wrap: wrap; }
.duel .t { padding: 5px 10px; border-radius: 8px; display: inline-flex; align-items: center; gap: 5px; }
.duel .t.pink { background: var(--pink); color: #fff; box-shadow: 0 3px 0 var(--pink-edge); }
.duel .t.navy { background: var(--navy); color: #fff; box-shadow: 0 3px 0 var(--navy-edge); }

.choices { display: grid; gap: 12px; }
.choices.grid2 { grid-template-columns: 1fr 1fr; }
.choice {
  border: 0; background: var(--bg-3); color: var(--text); border-radius: 14px; box-shadow: 0 6px 0 var(--edge);
  padding: 16px 16px 16px 16px; font-size: 1.15rem; font-weight: 600; min-height: 64px; text-align: center;
  unicode-bidi: plaintext; position: relative; margin-bottom: 6px; transition: transform .08s, box-shadow .08s, background .15s;
}
.choices.grid2 .choice { min-height: 88px; font-family: var(--display); font-size: 1.45rem; font-weight: 800; }
.choice .key { position: absolute; top: 7px; right: 10px; font-family: var(--display); font-size: .72rem; font-weight: 700; color: #8D9AB3; }
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--edge); }
.choice.sel { background: #FCE4F0; color: var(--bg); outline: 3px solid var(--pink); outline-offset: -3px; transform: translateY(4px); box-shadow: 0 2px 0 var(--pink-edge); }
.choice.sel .key { color: var(--pink-edge); }
.choice.sel::after { content: ""; position: absolute; top: 8px; left: 10px; width: 20px; height: 20px; border-radius: 6px; background: var(--pink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17l9-10'/%3E%3C/svg%3E") center / 14px no-repeat; }
/* The send button is the cream "play" piece with a gap above, so it never reads as a fifth answer. */
.choices + #sendBtn { margin-top: 18px !important; }
.choice:disabled { cursor: default; }
.choice:disabled:not(.sel) { opacity: .6; }
.choice.big-emoji { font-size: 2.2rem; padding: 10px; }
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.memory-grid div { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; background: var(--cream); border-radius: 12px; box-shadow: 0 4px 0 var(--cream-edge); animation: flip .45s ease backwards; }
.order-list .choice { display: flex; align-items: center; gap: 10px; text-align: start; }
.order-list .choice .ix { width: 30px; height: 30px; border-radius: 8px; background: var(--well); display: inline-flex; align-items: center; justify-content: center; font-family: var(--display); font-size: .95rem; flex: none; }
.order-list .choice.sel .ix { background: var(--cream); color: var(--bg); }

.status-line { text-align: center; font-size: .95rem; color: var(--muted); min-height: 1.4em; }
.locked-banner { text-align: center; padding: 14px; border-radius: var(--radius); background: var(--mint); color: #08241a; box-shadow: 0 4px 0 var(--mint-edge); font-family: var(--display); font-weight: 800; }
.sugs { display: grid; gap: 8px; }
.sug { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--well); font-size: .95rem; }
.sug .who { color: var(--muted); font-size: .85rem; }
.sug .what { flex: 1; font-weight: 600; unicode-bidi: plaintext; }
.opp { display: flex; justify-content: center; gap: 10px; font-size: .85rem; color: var(--muted); }

.result-team { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--bg-2); box-shadow: 0 4px 0 var(--edge); }
.result-team .mark { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex: none; }
.result-team .mark.ok { background: var(--mint); color: #08241a; box-shadow: 0 3px 0 var(--mint-edge); }
.result-team .mark.bad { background: var(--bad); color: #fff; box-shadow: 0 3px 0 var(--bad-edge); }
.result-team .mark.none { background: var(--bg-3); color: var(--muted); box-shadow: 0 3px 0 var(--edge); }
.result-team .body { flex: 1; min-width: 0; }
.result-team .ans { font-family: var(--display); font-weight: 800; font-size: 1.15rem; unicode-bidi: plaintext; overflow-wrap: anywhere; }
.result-team.win { outline: 2px solid var(--mint); }
.result-team.pink { box-shadow: 0 4px 0 var(--pink-edge); }
.result-team.navy { box-shadow: 0 4px 0 var(--navy-edge); }
.correct-ans { text-align: center; padding: 14px; border-radius: 14px; background: var(--cream); color: var(--bg); box-shadow: 0 5px 0 var(--cream-edge); }
.correct-ans .muted { color: #5B6780; font-size: .9rem; }
.correct-ans b { font-family: var(--display); font-size: 1.4rem; font-weight: 800; unicode-bidi: plaintext; }
.verdict { text-align: center; font-family: var(--display); font-size: 1.3rem; font-weight: 800; padding: 10px; line-height: 1.5; animation: rise .4s ease; }
.verdict.us { color: var(--gold); }

.moves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.move-btn { border: 0; background: var(--bg-3); border-radius: 14px; box-shadow: 0 5px 0 var(--edge); padding: 12px 6px; text-align: center; min-height: 80px; margin-bottom: 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.move-btn > .ic { font-size: 1.5rem; color: var(--gold); }
.move-btn .nm { font-family: var(--display); font-weight: 700; font-size: 1rem; display: block; }
.move-btn .ct { font-size: .75rem; color: var(--muted); display: block; }
.move-btn.sel { background: var(--gold); color: #1d1606; transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-edge); }
.move-btn.sel > .ic, .move-btn.sel .ct { color: #1d1606; }
.move-btn:disabled { opacity: .35; }
.hint { font-size: .9rem; color: var(--muted); text-align: center; }

.timeline { display: grid; gap: 8px; }
.tl { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; background: var(--well); border-radius: 10px; font-size: .9rem; }
.tl .r { font-family: var(--display); font-weight: 800; width: 26px; height: 26px; border-radius: 7px; background: var(--bg-3); flex: none; display: flex; align-items: center; justify-content: center; }
.tl .ev { color: var(--gold); }
.winner-banner { text-align: center; padding: 24px 12px; margin-bottom: 8px; border-radius: 20px; overflow: hidden; color: #fff; animation: rise .6s ease; }
.winner-banner.pink { background: var(--pink); box-shadow: 0 7px 0 var(--pink-edge); }
.winner-banner.navy { background: var(--navy); box-shadow: 0 7px 0 var(--navy-edge); }
.winner-banner.draw { background: var(--bg-3); box-shadow: 0 7px 0 var(--edge); }
.winner-banner h2 { font-size: 2.3rem; font-weight: 800; }
.winner-banner .final-score { font-family: var(--display); font-size: 1.6rem; font-weight: 800; margin-top: 4px; }
.star .ic { font-size: 1.2rem; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.stats-table td, .stats-table th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: start; }
.stats-table th { font-family: var(--display); font-size: .78rem; color: var(--muted); }

/* ---------- chat ---------- */
.chat { position: fixed; inset: auto 0 0 0; z-index: 10; pointer-events: none; }
.chat > * { pointer-events: auto; }
.chat-toggle {
  position: absolute; bottom: 16px; left: 14px; border: 0; background: var(--bg-3); display: flex; align-items: center; gap: 8px;
  border-radius: 12px; padding: 10px 16px; font-family: var(--display); font-size: .9rem; font-weight: 700; box-shadow: 0 4px 0 var(--edge);
}
.badge { background: var(--pink); color: #fff; border-radius: 6px; padding: 0 7px; font-size: .75rem; }
.chat-panel {
  position: absolute; bottom: 74px; left: 12px; right: 12px; max-width: 420px; max-height: 55dvh;
  background: var(--bg-2); border-radius: 16px; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 6px 0 var(--edge), 0 16px 40px rgba(0, 0, 0, .45);
}
.chat-list { flex: 1; overflow-y: auto; padding: 10px; display: grid; gap: 6px; align-content: start; min-height: 120px; }
.chat-msg { font-size: .92rem; overflow-wrap: anywhere; }
.chat-msg b { color: var(--muted); font-weight: 600; margin-inline-end: 4px; }
.chat-msg.sig { color: var(--gold); }
.chat-signals { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; }
.chat-signals button { border: 0; background: var(--bg-3); box-shadow: 0 3px 0 var(--edge); border-radius: 8px; padding: 6px 10px; font-size: .85rem; display: inline-flex; align-items: center; gap: 5px; }
.chat-signals button .ic { color: var(--gold); }
.chat-form { display: flex; gap: 6px; padding: 10px; background: var(--well); }
.chat-form input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 2px solid #2A3F66; background: var(--bg); }
.chat-form button { border: 0; border-radius: 10px; padding: 0 14px; background: var(--cream); color: var(--bg); box-shadow: 0 3px 0 var(--cream-edge); font-family: var(--display); font-weight: 800; }

/* ---------- toast / modal / conn ---------- */
.toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--bad); color: #fff; box-shadow: 0 4px 0 var(--bad-edge); padding: 10px 16px; border-radius: 12px; font-family: var(--display); font-weight: 700; max-width: calc(100% - 32px); text-align: center; }
.toast.ok { background: var(--mint); color: #08241a; box-shadow: 0 4px 0 var(--mint-edge); }
.conn { position: fixed; top: 0; inset-inline: 0; z-index: 40; background: var(--gold); color: #1d1606; text-align: center; padding: 6px; font-family: var(--display); font-weight: 700; font-size: .9rem; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(8, 14, 26, .78); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--bg-2); border-radius: 18px; padding: 20px; max-width: 460px; width: 100%; max-height: 90dvh; overflow-y: auto; box-shadow: 0 7px 0 var(--edge); }
.step { display: flex; gap: 12px; align-items: flex-start; line-height: 1.7; }
.step .no { width: 34px; height: 34px; border-radius: 9px; background: var(--gold); color: #1d1606; box-shadow: 0 3px 0 var(--gold-edge); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; flex: none; }
.step .ic { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 600px) {
  .prompt { font-size: 1.75rem; }
}

/* guidance */
.coach { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 2px dashed rgba(243, 189, 87, .45); font-size: .9rem; line-height: 1.7; color: var(--muted); }
.coach .tip { flex: none; font-family: var(--display); font-weight: 800; font-size: .72rem; background: var(--gold); color: #1d1606; padding: 2px 7px; border-radius: 5px; margin-top: 3px; transform: rotate(-3deg); }
.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border-radius: 3px; background: var(--bg-3); display: inline-block; }
.lg.pink { background: var(--pink); } .lg.navy { background: var(--navy); }
.guide { display: grid; gap: 8px; }
.gs { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--well); color: var(--muted); font-weight: 600; }
.gs .no { width: 26px; height: 26px; border-radius: 7px; background: var(--bg-3); display: inline-flex; align-items: center; justify-content: center; flex: none; font-family: var(--display); font-size: .85rem; }
.gs.now { color: var(--text); outline: 2px solid var(--gold); outline-offset: -2px; }
.gs.now .no { background: var(--gold); color: #1d1606; }
.gs.done { color: var(--mint); }
.gs.done .no { background: var(--mint); color: #08241a; }
.demo-map { display: grid; grid-template-columns: repeat(3, 34px); gap: 5px; justify-content: center; direction: ltr; }
.demo-map i { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-3); box-shadow: 0 3px 0 var(--edge); }
.demo-map i.pink { background: var(--pink); box-shadow: 0 3px 0 var(--pink-edge); }
.demo-map i.navy { background: var(--navy); box-shadow: 0 3px 0 var(--navy-edge); }
