/* =========================================================
   Climb Mount Góry — chunky, bright, platformer-inspired UI
   ========================================================= */
:root {
  --ink: #2a1f3d;
  --ink-soft: #4a3f5e;
  --muted: #6b6280;
  --paper: #ffffff;
  --cream: #fff8e7;
  --cream-2: #fff1cf;
  --red: #e4312b;
  --red-d: #b3221d;
  --gold: #ffcc00;
  --gold-d: #d9a400;
  --green: #5cc23c;
  --green-d: #3e9a25;
  --blue: #2b6ee4;
  --blue-d: #1d4fae;
  --sky-top: #4cb8f5;
  --sky-bottom: #b9ecff;
  --radius: 14px;
  --shadow: 0 4px 0 var(--ink);
  --shadow-sm: 0 3px 0 var(--ink);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* Vocabulary and lesson recaps share the mountain's bright, chunky panels. */
.vocabulary-view { height: 100%; display: flex; flex-direction: column; }
.vocabulary-body { overflow-y: auto; padding: 24px 18px calc(32px + var(--safe-bottom)); }
.vocabulary-intro, .vocabulary-list { max-width: 1000px; margin: 0 auto 24px; padding: 24px; }
.vocabulary-intro h1 { margin: 0; font-size: clamp(24px, 4vw, 36px); }
.vocabulary-intro p { max-width: 650px; line-height: 1.6; }
.vocabulary-list h2 { margin-top: 0; }
.word-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.word-stats > div { background: white; border: 2px solid var(--ink); border-radius: 12px; padding: 16px 10px; text-align: center; }
.word-stats strong { display: block; font-size: 30px; color: var(--blue-d); }
.word-stats span { display: block; font-size: 14px; }
.word-filters { display: grid; grid-template-columns: 2fr 1.5fr 1fr; gap: 14px; }
.word-filters label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; min-width: 0; }
.word-filters input, .word-filters select { width: 100%; min-height: 46px; border: 2px solid var(--ink); border-radius: 10px; background: white; padding: 10px; font: inherit; font-size: 16px; }
.word-filters select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%232a1f3d' stroke-width='2'/%3E%3C/svg%3E"); background-position: right 10px center; background-repeat: no-repeat; }
.vocabulary-list > .muted { font-size: 14px; line-height: 1.6; }
.word-results { margin: 20px 0 10px; font-size: 14px; }
.word-table-wrap { overflow-x: auto; }
.word-table { width: 100%; border-collapse: collapse; }
.word-table th { background: var(--cream-2); text-align: left; font-size: 14px; }
.word-table th, .word-table td { padding: 14px 12px; border-bottom: 2px solid #e4dcc7; }
.word-table th:not(:first-child), .word-table td:not(:first-child) { text-align: center; width: 20%; }
.word-label { position: relative; display: flex; flex-direction: column; gap: 4px; padding-right: 38px; min-width: 140px; }
.word-label strong { font-size: 18px; }
.word-label span { font-size: 16px; }
.word-label small { color: var(--muted); font-size: 14px; }
.word-listen { position: absolute; right: 0; top: 0; background: white; border: 1px solid var(--ink); border-radius: 8px; padding: 6px; }
.word-new { display: block; font-size: 14px; color: var(--blue-d); }
.word-empty { padding: 28px 8px; text-align: center; }
.modal-panel.lesson-modal { width: min(660px, 95vw); }
.lesson-emblem { text-align: center; font-size: 40px; }
.lesson-summary > p { line-height: 1.6; }
.lesson-words { padding: 0; list-style: none; }
.lesson-words li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 2px solid #e4dcc7; }
.word-count { font-size: 14px; text-align: right; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
@media (max-width: 600px) {
  .vocabulary-body { padding: 16px 10px calc(24px + var(--safe-bottom)); }
  .vocabulary-intro, .vocabulary-list { padding: 16px; }
  .word-filters { grid-template-columns: 1fr 1fr; }
  .word-filters label:first-child { grid-column: 1 / -1; }
  .word-stats { gap: 6px; }
  .word-stats span { font-size: 14px; }
  .word-stats strong { font-size: 24px; }
  .word-table th, .word-table td { padding: 12px 6px; }
  .finish-lesson { font-size: 14px; padding: 6px 8px; }
  .lesson-words li { flex-wrap: wrap; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-weight: 700;
  color: var(--ink);
  background: var(--sky-bottom);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.sprite { display: block; image-rendering: pixelated; }

/* ---------- sky ---------- */
#sky {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 70%);
  transition: background 2s;
}
body[data-sky='dawn'] { --sky-top: #f7a58c; --sky-bottom: #ffe3b8; }
body[data-sky='sunset'] { --sky-top: #6a5acd; --sky-bottom: #ffb27a; }
body[data-sky='night'] { --sky-top: #0f1640; --sky-bottom: #33407e; }
.sun {
  position: absolute; top: 7%; right: 9%; width: 64px; height: 64px; border-radius: 50%;
  background: #ffe066; border: 3px solid var(--ink); box-shadow: 0 0 0 10px rgba(255, 224, 102, 0.35);
}
body[data-sky='night'] .sun { background: #f4f1de; box-shadow: inset -14px -6px 0 #d6d2bc, 0 0 0 10px rgba(244, 241, 222, 0.12); }
body[data-sky='sunset'] .sun { background: #ff9f43; top: 18%; }
.stars {
  position: absolute; inset: 0; opacity: 0; transition: opacity 2s;
  background-image:
    radial-gradient(2px 2px at 10% 20%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 30% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 55% 15%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 75% 30%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 12%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 20% 40%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 65% 45%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 42% 32%, #fff 50%, transparent 51%);
}
body[data-sky='night'] .stars { opacity: 1; }
.cloud {
  position: absolute; width: 130px; height: 54px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 130 54'%3E%3Cpath d='M22 50h86a16 16 0 0 0 2-32 22 22 0 0 0-40-9 18 18 0 0 0-31 9 16 16 0 0 0-17 32z' fill='%23fff' stroke='%232a1f3d' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M30 42h60' stroke='%23d8eefa' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
  animation: drift linear infinite;
}
body[data-sky='night'] .cloud { opacity: 0.35; }
.cloud.c1 { top: 9%; animation-duration: 90s; animation-delay: -20s; }
.cloud.c2 { top: 22%; animation-duration: 120s; animation-delay: -70s; transform: scale(0.7); }
.cloud.c3 { top: 4%; animation-duration: 140s; animation-delay: -100s; transform: scale(0.85); }
.cloud.c4 { top: 32%; animation-duration: 100s; animation-delay: -45s; transform: scale(0.6); }
@keyframes drift { from { left: -160px; } to { left: 100%; } }

#app { position: relative; z-index: 1; height: 100%; }

/* ---------- boot ---------- */
.boot { height: 100%; display: grid; place-content: center; gap: 24px; justify-items: center; }
.boot-title { font-family: var(--pixel); font-size: 18px; color: #fff; text-shadow: 3px 3px 0 var(--ink); text-align: center; }
.boot-spinner {
  width: 28px; height: 28px; border: 4px solid var(--ink); border-right-color: var(--gold);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.center-block { margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- generic ---------- */
.panel { background: var(--cream); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap { gap: 10px; }
.end { justify-content: flex-end; }
.form-error { color: var(--red-d); min-height: 1.2em; margin: 4px 0; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 3px solid var(--ink); border-radius: 12px; padding: 10px 16px;
  background: var(--paper); font-weight: 800; box-shadow: var(--shadow-sm);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
  user-select: none; text-decoration: none; line-height: 1.2;
}
.btn:hover:not(:disabled) { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.6; }
.btn-primary { background: var(--red); color: #fff; text-shadow: 1px 1px 0 var(--red-d); }
.btn-ghost { background: var(--cream-2); }
.btn-small { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn-big { width: 100%; font-family: var(--pixel); font-size: 14px; padding: 16px; letter-spacing: 0.5px; }
.btn-link { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; padding: 6px; font-weight: 800; }
.btn.loading { position: relative; color: transparent; text-shadow: none; }
.btn.loading::after { content: ''; position: absolute; width: 18px; height: 18px; border: 3px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none;
  border: 3px solid var(--ink); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow-sm);
  font-size: 18px; padding: 0; transition: transform 0.06s, box-shadow 0.06s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }
.icon-btn.auto-read.off { background: var(--cream-2); opacity: 0.75; }
.music-toggle { grid-template-rows: 22px 10px; align-content: center; gap: 0; background: #e7e0ff; }
.music-toggle small { font-family: var(--font); font-size: 9px; font-weight: 900; line-height: 10px; }
.music-toggle.off { background: var(--cream-2); color: var(--muted); }
.menu-music { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; }
.immersive-music { display: none; }
.immersive > .immersive-music { display: inline-grid; position: absolute; top: max(10px, var(--safe-top)); right: 12px; z-index: 22; }
@media (max-width: 600px) {
  .chat-view > .chat-head { flex-wrap: wrap; gap: 6px; }
  .chat-view > .chat-head > :first-child { order: -3; }
  .chat-view > .chat-head .chat-title { order: -2; flex-basis: calc(100% - 108px); }
  .chat-view > .chat-head .music-toggle { order: -1; }
}
.badge {
  position: absolute; top: -8px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--red); color: #fff; border: 2px solid var(--ink);
  font-size: 11px; font-weight: 900; display: grid; place-items: center;
}
.tag { display: inline-block; padding: 2px 8px; border-radius: 8px; border: 2px solid var(--ink); font-size: 12px; font-weight: 800; margin: 2px 4px 0 0; }
.tag-gold { background: var(--gold); }
.tag-red { background: #ffd2cf; }
.tag-blue { background: #d9e8ff; }

/* ---------- toasts ---------- */
#toast-root { position: fixed; top: calc(10px + var(--safe-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  max-width: 520px; background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm);
  padding: 10px 14px; font-weight: 800; transform: translateY(-20px); opacity: 0; transition: all 0.25s; pointer-events: auto;
}
.toast.show { transform: none; opacity: 1; }
.toast-error { background: #ffe5e3; }
.toast-jackpot { background: linear-gradient(180deg, #fff6b8, var(--gold)); text-align: center; padding: 12px 18px; }
.toast-jackpot.show { animation: jackpot-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.toast-jackpot .jp-title { display: block; font-family: var(--pixel); font-size: 15px; letter-spacing: 1px; margin-bottom: 6px; }
.toast-jackpot .jp-sub { display: block; font-size: 14px; }
@keyframes jackpot-pop {
  0% { transform: scale(0.6) translateY(-20px); }
  60% { transform: scale(1.08); }
  100% { transform: none; }
}

/* ---------- modals ---------- */
#modal-root { position: relative; z-index: 50; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(42, 31, 61, 0.55); display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity 0.2s; padding: 0;
}
.modal-backdrop.show { opacity: 1; }
.modal-panel {
  position: relative; width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--cream); border: 3px solid var(--ink); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 22px 18px calc(18px + var(--safe-bottom)); transform: translateY(40px); transition: transform 0.25s;
}
.modal-backdrop.show .modal-panel { transform: none; }
.modal-panel:focus { outline: none; }
.modal-panel.wide { max-width: 680px; }
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal-panel { border-bottom: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); padding: 26px; }
}
.modal-x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--ink); background: var(--paper); font-weight: 900; }
.modal-title { font-family: var(--pixel); font-size: 15px; line-height: 1.5; margin: 4px 36px 10px 0; }
.confirm p { margin: 0 0 16px; }

/* help */
.help-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.help-head p { margin: 0; }
.help-steps { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; gap: 10px; }
.help-step { display: flex; gap: 12px; align-items: flex-start; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; }
.help-step p { margin: 2px 0 0; font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.help-icon { font-size: 22px; width: 32px; text-align: center; flex: none; }
@media (min-width: 700px) { .help-steps { grid-template-columns: 1fr 1fr; } .help-step:last-child { grid-column: span 2; } }

/* report */
.report-sun { font-size: 44px; text-align: center; animation: rise 1s ease-out; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.report .modal-title { text-align: center; margin-right: 0; }
.report-list { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; gap: 8px; }
.report-row { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; animation: pop 0.35s backwards; }
.report-row:nth-child(2) { animation-delay: 0.1s; } .report-row:nth-child(3) { animation-delay: 0.2s; } .report-row:nth-child(4) { animation-delay: 0.3s; }
.report-row.me { background: #fff3c4; }
.report-main { flex: 1; min-width: 0; }
.report-name { font-weight: 900; }
.report-meta { font-size: 12px; color: var(--muted); }
.report-move { font-family: var(--pixel); font-size: 14px; text-align: right; display: flex; flex-direction: column; gap: 4px; }
.report-move small { font-family: var(--font); font-size: 11px; color: var(--muted); }
.report-move.up { color: var(--green-d); } .report-move.down { color: var(--red); }
.big-note { font-weight: 900; font-size: 18px; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }

/* winner */
.winner { text-align: center; position: relative; }
.winner-avatar { display: flex; justify-content: center; margin: 10px 0; animation: bob 1s ease-in-out infinite; }
.winner .modal-title { margin-right: 0; }
.confetti { position: absolute; inset: -20px -20px auto; height: 260px; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -10px; width: 8px; height: 8px; border: 1px solid var(--ink); animation: fall 2.4s linear infinite; }
@keyframes fall { to { transform: translateY(280px) rotate(540deg); } }

.history-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.history-row { width: 100%; display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; align-items: center; text-align: left; padding: 10px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; font-weight: 700; }
.history-row:hover { background: var(--cream-2); }

/* notifications + menu */
.push-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--paper); border: 2px dashed var(--ink-soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.notif-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.notif { background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; }
.notif.unread { background: #fff3c4; }
.notif-title { font-weight: 900; }
.notif-body { font-weight: 600; font-size: 14px; margin-top: 2px; }
.notif-time { font-size: 12px; color: var(--muted); margin-top: 4px; }
.menu-user { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.menu-list { display: grid; gap: 8px; margin-bottom: 12px; }
.menu-item { text-align: left; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); font-weight: 800; }
.menu-item:hover { background: var(--cream-2); }
.menu-item.danger { color: var(--red-d); }
.menu-item.dev { background: #e9e2ff; border-style: dashed; }
.player-card { text-align: center; display: flex; flex-direction: column; align-items: center; }
.player-card .modal-title { margin-right: 0; }
.stat-row { display: flex; gap: 10px; margin: 8px 0; }
.stat { background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; min-width: 84px; }
.stat b { font-family: var(--pixel); font-size: 13px; margin-bottom: 4px; }
.stat span { font-size: 12px; color: var(--muted); }

/* Story picker: every adventure gets the same calm, illustrated card treatment. */
.modal-panel.story-picker-panel { max-width: 800px; background: #fcfaf6; }
.themes > .muted { max-width: 65ch; margin: 0 0 22px; line-height: 1.65; font-size: 14px; }
.themes > .modal-title { margin-bottom: 12px; }
.theme-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 3px 3px 8px; }
@media (min-width: 640px) { .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.theme-card {
  --theme-bg: #f0f3ed; --theme-end: #fafbf7; --theme-glow: #dce8d9; --theme-accent: #40674d;
  --theme-pattern: radial-gradient(circle at 90% 15%, #40674d0c 0 36px, transparent 37px);
  position: relative; isolation: isolate; overflow: hidden; min-width: 0; min-height: 180px;
  display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 14px; align-items: start; text-align: left;
  color: #302f3c; background: radial-gradient(ellipse at 100% 0, var(--theme-glow), transparent 70%), linear-gradient(135deg, var(--theme-bg), var(--theme-end));
  border: 1px solid color-mix(in srgb, var(--theme-accent) 26%, white); border-radius: 18px; padding: 20px;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--theme-accent) 14%, #e8e4de), 0 6px 16px #332d3a05;
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}
.theme-card::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--theme-pattern); pointer-events: none; }
.theme-card:hover { transform: translateY(-2px); border-color: var(--theme-accent); box-shadow: 0 5px 0 color-mix(in srgb, var(--theme-accent) 18%, #e8e4de), 0 10px 24px #332d3a0c; }
.theme-card:active { transform: translateY(1px); box-shadow: 0 1px 0 #e8e4de; }
.theme-card:focus-visible { outline: 3px solid var(--theme-accent); outline-offset: 3px; }
.theme-emoji { display: grid; place-items: center; width: 46px; height: 46px; font-size: 27px; line-height: 1; background: #ffffffa6; border: 1px solid #ffffffcf; border-radius: 14px; box-shadow: 0 2px 6px #302f3c06; }
.theme-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; min-width: 0; }
.theme-title { font-weight: 900; font-size: 16px; line-height: 1.35; text-wrap: balance; }
.theme-hook { font-weight: 600; font-size: 13px; line-height: 1.65; color: #514d5f; }
.theme-meta { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; margin-top: 3px; }
.theme-art { position: absolute; bottom: -14px; right: -9px; z-index: -1; font-size: 92px; line-height: 1.1; opacity: 0.07; transform: rotate(-12deg); pointer-events: none; }
.theme-card[data-theme='krakow-map'] {
  --theme-bg: #faf1df; --theme-end: #fffcf4; --theme-glow: #efe0ba; --theme-accent: #87662e;
  --theme-pattern: repeating-radial-gradient(ellipse at 110% -10%, transparent 0 22px, #87662e0b 23px 24px, transparent 25px 38px);
}
.theme-card[data-theme='dragon'] {
  --theme-bg: #e6f2e8; --theme-end: #f8fcf5; --theme-glow: #cfe7d2; --theme-accent: #42764d;
  --theme-pattern: repeating-radial-gradient(ellipse at 100% 0, transparent 0 25px, #42764d0b 26px 28px, transparent 29px 44px);
}
.theme-card[data-theme='wedding'] {
  --theme-bg: #f9e9ee; --theme-end: #fff9f6; --theme-glow: #f2d4df; --theme-accent: #99516d;
  --theme-pattern: radial-gradient(circle at 92% 18%, #99516d0a 0 25px, transparent 26px), radial-gradient(circle at 80% 6%, #99516d09 0 24px, transparent 25px), radial-gradient(circle at 100% 40%, #99516d09 0 26px, transparent 27px);
}
.theme-card[data-theme='train'] {
  --theme-bg: #e9edf8; --theme-end: #f9faff; --theme-glow: #d3ddf2; --theme-accent: #536d9e;
  --theme-pattern: repeating-linear-gradient(130deg, transparent 0 32px, #536d9e09 33px 34px, transparent 35px 48px);
}
.theme-card[data-theme='pierogi'] {
  --theme-bg: #fff0dd; --theme-end: #fffbf2; --theme-glow: #f6dfbd; --theme-accent: #98612f;
  --theme-pattern: radial-gradient(ellipse at 100% 100%, transparent 0 55px, #98612f08 56px 58px, transparent 59px 76px, #98612f08 77px 79px, transparent 80px);
}
.theme-card[data-theme='krasnale'] {
  --theme-bg: #e5f1ef; --theme-end: #f5fbf7; --theme-glow: #cfe5df; --theme-accent: #477d73;
  --theme-pattern: linear-gradient(145deg, transparent 65%, #477d7309 65% 78%, transparent 78%), linear-gradient(35deg, transparent 75%, #477d7309 75% 85%, transparent 85%);
}
.theme-card[data-theme='comedy-club'] {
  --theme-bg: #f5e9f4; --theme-end: #fef8fb; --theme-glow: #e9d4e8; --theme-accent: #8a5487;
  --theme-pattern: conic-gradient(from 145deg at 80% -20%, transparent 0 8deg, #ffffff40 8deg 26deg, transparent 26deg 360deg);
}
.theme-card[data-theme='chef'] {
  --theme-bg: #f8e9e2; --theme-end: #fffaf3; --theme-glow: #efd5c7; --theme-accent: #97604b;
  --theme-pattern: repeating-linear-gradient(0deg, transparent 0 30px, #97604b06 31px 32px), repeating-linear-gradient(90deg, transparent 0 30px, #97604b06 31px 32px);
}
.theme-card[data-theme='mirror'] {
  --theme-bg: #eeebfa; --theme-end: #fcf9ff; --theme-glow: #dfd6f2; --theme-accent: #77609f;
  --theme-pattern: radial-gradient(circle at 88% 20%, #77609f28 0 2px, transparent 3px), radial-gradient(circle at 70% 8%, #77609f24 0 1px, transparent 2px), radial-gradient(circle at 95% 48%, #77609f20 0 2px, transparent 3px), radial-gradient(circle at 84% 80%, #77609f20 0 1px, transparent 2px);
}
.theme-card[data-theme='silence'] {
  --theme-bg: #ebedf0; --theme-end: #f8f8fa; --theme-glow: #d9dce4; --theme-accent: #636b82;
  --theme-pattern: radial-gradient(ellipse at 100% 0, #b7606c0b, transparent 65%), repeating-linear-gradient(0deg, transparent 0 22px, #636b8207 23px 24px);
}
@media (max-width: 399px) {
  .theme-card { grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 17px 14px; min-height: 0; }
  .theme-emoji { width: 38px; height: 38px; font-size: 23px; border-radius: 12px; }
}
@media (prefers-reduced-motion: reduce) { .theme-card { transition: none; } .theme-card:hover, .theme-card:active { transform: none; } }
/* Premise card above a story's first message */
.story-intro {
  margin: 4px auto 14px; max-width: 560px; padding: 14px 16px; border: 3px solid var(--ink); border-radius: 14px;
  background: var(--paper); box-shadow: var(--shadow-sm); font-size: 14px; line-height: 1.45;
}
.story-intro p { margin: 0 0 8px; }
.story-intro p:last-child { margin-bottom: 0; font-weight: 800; }
.story-intro-title { font-weight: 900; font-size: 16px; margin-bottom: 8px; }
.story-intro.dark { background: #3b3a40; border-color: #18171c; color: #e9e7ee; }
.story-intro.magic { background: linear-gradient(160deg, #1f2452, #3a2463); border-color: #120f2b; color: #f1eadb; }
.story-intro.magic .story-intro-title { color: #f3c94b; }
/* The premise as a modal: read (and dismissed) before the first prompt, and reopened from the map's 📖 */
.story-book .story-intro { margin: 0 0 16px; font-size: 15px; }
.story-book-panel { max-width: 600px; }
.modal-x + .story-book { padding-top: 34px; }
/* The little book on the map, up in the sky (base camp's climbers fill the bottom corners) */
.mountain-center { position: relative; }
.story-book-btn {
  position: absolute; left: 12px; top: 10px; z-index: 6; width: 48px; height: 48px; padding: 0; display: grid; place-items: center;
  border: 3px solid var(--ink); border-radius: 12px; background: #fff3c4; box-shadow: var(--shadow-sm); font-size: 24px; cursor: pointer;
  transform: rotate(-6deg); transition: transform 0.15s;
}
.story-book-btn:hover { transform: rotate(0) scale(1.06); }
.story-book-btn:active { transform: translateY(3px); box-shadow: none; }
/* The game-over banner takes the top of the map: the book steps aside. */
.game-banner:not([hidden]) ~ .story-book-btn { display: none; }
.theme-tag, .theme-badge {
  display: inline-block; max-width: 100%; padding: 5px 9px; border-radius: 9px;
  font-size: 11px; font-weight: 800; line-height: 1.45; text-align: left;
}
.theme-tag { background: #ffffffa6; color: var(--theme-accent); border: 1px solid #ffffffc4; }
.theme-badge { background: #fff3cc; color: #65501f; border: 1px solid #e8d59b; }
.theme-card.here { outline: 3px solid #bf9540; outline-offset: 3px; }
.themes.busy .theme-grid { opacity: 0.4; pointer-events: none; }
.theme-status { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; font-weight: 800; }

/* =========================================================
   Auth
   ========================================================= */
body[data-view='auth'] { overflow: auto; }
.auth-screen { min-height: 100%; max-width: 560px; margin: 0 auto; padding: calc(20px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 18px; }
.auth-hero { text-align: center; padding-top: 8px; }
.logo { display: inline-flex; flex-direction: column; align-items: center; position: relative; }
.logo-top { font-family: var(--pixel); font-size: 16px; color: #fff; text-shadow: 3px 3px 0 var(--ink); letter-spacing: 4px; }
.logo-main {
  font-family: var(--pixel); font-size: clamp(24px, 8vw, 40px); color: var(--gold); margin-top: 16px; line-height: 1.1;
  text-shadow: 3px 3px 0 var(--red), 6px 6px 0 var(--ink); -webkit-text-stroke: 1px var(--ink);
}
.logo-flag { position: absolute; top: -6px; right: -26px; width: 22px; height: 14px; background: linear-gradient(#fff 50%, #dc143c 50%); border: 2px solid var(--ink); }
.logo-flag::before { content: ''; position: absolute; left: -4px; top: -4px; width: 2px; height: 34px; background: var(--ink); }
.tagline { margin: 18px auto 8px; max-width: 420px; font-size: 16px; background: rgba(255, 255, 255, 0.85); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow-sm); }
.parade { position: relative; height: 56px; margin-top: 8px; overflow: hidden; border-bottom: 12px solid #c8743a; box-shadow: 0 3px 0 var(--ink); }
.parade::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--ink); }
.parade-guy { position: absolute; bottom: 2px; left: -40px; animation: walk 10s linear infinite; }
.parade-guy .sprite { animation: bob 0.5s ease-in-out infinite; }
@keyframes walk { to { left: 100%; } }
@keyframes bob { 50% { transform: translateY(-4px); } }

.auth-card { padding: 16px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--cream-2); border: 2px solid var(--ink); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.tab { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 900; color: var(--ink-soft); }
.tab.active { background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 var(--ink); border: 2px solid var(--ink); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 900; }
.field-hint { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .pw-wrap {
  width: 100%; border: 3px solid var(--ink); border-radius: 12px; padding: 12px 14px; background: var(--paper); font-size: 16px; font-weight: 700;
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43, 110, 228, 0.25); }
.pw-wrap { display: flex; padding: 0; overflow: hidden; }
.pw-wrap input { border: 0; border-radius: 0; flex: 1; box-shadow: none !important; }
.pw-toggle { border: 0; background: var(--cream-2); border-left: 3px solid var(--ink); width: 48px; font-size: 18px; }

.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.avatar-choice {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm); transition: transform 0.1s;
}
.avatar-choice:hover:not(:disabled) { transform: translateY(-2px); }
.avatar-choice.selected { background: #fff3c4; border-color: var(--red); box-shadow: 0 3px 0 var(--red-d), 0 0 0 3px var(--gold); }
.avatar-choice.selected .sprite { animation: bob 0.6s ease-in-out infinite; }
.avatar-choice.taken { opacity: 0.45; filter: grayscale(1); box-shadow: none; }
.avatar-pl { font-size: 12px; font-weight: 900; }
.avatar-taken { position: absolute; top: 4px; left: 4px; right: 4px; font-size: 10px; background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--cream-2); border: 2px solid var(--ink); border-radius: 12px; padding: 4px; }
.segmented button { border: 0; background: none; border-radius: 9px; padding: 8px 4px; font-weight: 800; font-size: 14px; color: var(--ink-soft); }
.segmented button.on { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); }
.picked-label { font-size: 14px; color: var(--ink-soft); min-height: 1.3em; }
.auth-foot { text-align: center; color: #fff; text-shadow: 2px 2px 0 var(--ink); font-weight: 900; margin-top: auto; }

/* =========================================================
   Mountain
   ========================================================= */
.mountain-view { height: 100%; display: flex; flex-direction: column; }
.hud { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-top)) 12px 8px; z-index: 5; }
.me-chip {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 12px 4px 6px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow-sm); text-align: left;
}
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.me-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }
.me-text small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.day-pill { font-family: var(--pixel); font-size: 10px; background: var(--gold); border: 3px solid var(--ink); border-radius: 10px; padding: 8px 8px; box-shadow: var(--shadow-sm); white-space: nowrap; }
.hud-actions { margin-left: auto; display: flex; gap: 8px; }

.mountain-main { flex: 1; min-height: 0; display: flex; position: relative; }
.mountain-center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mountain-wrap { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; }
.mountain-stage {
  position: relative; margin: auto auto 0; aspect-ratio: 480 / 720;
  width: min(100%, max(330px, calc((100dvh - 230px) * 0.6667)));
}
.mountain-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mountain-svg .far { fill: #8fb9d9; stroke: var(--ink); stroke-width: 2; opacity: 0.75; }
body[data-sky='night'] .mountain-svg { filter: brightness(0.78) saturate(0.85); }
body[data-sky='sunset'] .mountain-svg .far { fill: #b49ad1; }
.mountain-svg .far-snow { fill: #fff; opacity: 0.85; }
.ms-text { font-family: var(--pixel); font-size: 7px; fill: var(--ink); letter-spacing: -0.5px; }
.sign-text { font-family: var(--pixel); font-size: 6px; fill: #fff; paint-order: stroke; stroke: var(--ink); stroke-width: 1.5px; }
.castle .flag { transform-origin: 1px -104px; animation: wave 1.6s ease-in-out infinite; }
@keyframes wave { 50% { transform: skewY(-6deg) scaleX(0.92); } }

/* The dragon on the far peak: fire = connected and the AI tutor is live (ai-status.js). */
.ai-dragon { cursor: pointer; outline: none; }
.ai-dragon:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }
.ai-dragon .dragon-flame { transform-origin: 0 0; transition: transform 0.35s ease, opacity 0.35s ease; transform: scale(0.15); opacity: 0; }
.ai-dragon .dragon-glow { opacity: 0; transition: opacity 0.4s; }
.ai-dragon .dragon-smoke circle { transform-box: fill-box; transform-origin: center; fill: #c9c4cf; stroke: var(--ink); stroke-width: 0.8; opacity: 0; }
.ai-dragon .dragon-eye-open { display: none; }
.ai-dragon[data-flame='lit'] .dragon-eye-open { display: inline; }
.ai-dragon[data-flame='lit'] .dragon-eye-shut { display: none; }
.ai-dragon[data-flame='lit'] .dragon-flame { opacity: 1; transform: none; animation: flame-flicker 0.32s ease-in-out infinite alternate; }
.ai-dragon[data-flame='lit'] .dragon-glow { opacity: 0.7; animation: flame-glow 1.1s ease-in-out infinite alternate; }
.ai-dragon[data-flame='lit'] .dragon-wing { transform-origin: 6px -19px; animation: wing-flap 2.4s ease-in-out infinite; }
.ai-dragon.ignite[data-flame='lit'] .dragon-flame { animation: flame-burst 0.7s ease-out, flame-flicker 0.32s ease-in-out 0.7s infinite alternate; }
.ai-dragon[data-flame='out'] .dragon-smoke circle { animation: smoke-rise 3s ease-out infinite; }
.ai-dragon[data-flame='out'] .dragon-smoke circle:nth-child(2) { animation-delay: 0.6s; }
.ai-dragon[data-flame='out'] .dragon-smoke circle:nth-child(3) { animation-delay: 1.2s; }
.ai-dragon[data-flame='checking'] .dragon-flame { opacity: 0.5; transform: scale(0.25); animation: flame-try 1.2s ease-in-out infinite; }
@keyframes flame-flicker { from { transform: scale(0.92, 1.08); } to { transform: scale(1.06, 0.9) rotate(-3deg); } }
@keyframes flame-glow { to { opacity: 1; } }
@keyframes flame-burst { 0% { transform: scale(0.2); } 55% { transform: scale(1.5, 1.3); } 100% { transform: none; } }
@keyframes flame-try { 50% { transform: scale(0.45); opacity: 0.8; } }
@keyframes smoke-rise { 0% { opacity: 0; transform: translate(0, 0) scale(0.6); } 25% { opacity: 0.8; } 100% { opacity: 0; transform: translate(-4px, -16px) scale(1.4); } }
@keyframes wing-flap { 0%, 80%, 100% { transform: none; } 88% { transform: rotate(-14deg); } }
@media (prefers-reduced-motion: reduce) {
  .ai-dragon .dragon-flame, .ai-dragon .dragon-glow, .ai-dragon .dragon-wing, .ai-dragon .dragon-smoke circle { animation: none !important; }
}

.game-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 4px 12px 8px; padding: 8px 12px;
  background: var(--gold); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm); font-weight: 900; text-align: center;
}

.climbers { position: absolute; inset: 0; pointer-events: none; }
.climber {
  position: absolute; width: 8.4%; padding: 0; border: 0; background: none; pointer-events: auto;
  transform: translate(-50%, -88%); transition: left 0.14s linear, top 0.14s linear;
  display: flex; flex-direction: column; align-items: center;
}
.climber-sprite { width: 100%; filter: drop-shadow(0 2px 0 rgba(42, 31, 61, 0.35)); }
.climber-sprite .sprite { width: 100%; height: auto; }
.climber-name {
  margin-top: -2px; font-size: 10px; font-weight: 900; background: var(--paper); border: 2px solid var(--ink); border-radius: 6px;
  padding: 0 4px; white-space: nowrap; max-width: 90px; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.climber.grouped:not(.me) .climber-name { display: none; }
.climber:hover .climber-name, .climber:focus-visible .climber-name { display: block; position: relative; z-index: 2; }
.climber.me .climber-name { background: var(--gold); }
.climber.me .climber-sprite { animation: bob 1s ease-in-out infinite; }
.climber.me::before {
  content: '▼'; position: absolute; top: -16px; color: var(--red); font-size: 13px; text-shadow: 0 2px 0 var(--ink); animation: bob 1s ease-in-out infinite;
}
.climber.hop .climber-sprite { animation: hop 0.14s ease-out; }
.climber.slip .climber-sprite { animation: slip 0.3s ease-out; }
.climber.at-summit .climber-sprite { animation: bob 0.6s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-8px); } }
@keyframes slip { 30% { transform: rotate(-12deg); } 70% { transform: rotate(8deg); } }

/* leaderboard */
.board { display: flex; flex-direction: column; }
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.board-head h2 { font-family: var(--pixel); font-size: 13px; margin: 0; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; overflow-y: auto; }
.board-row {
  display: grid; grid-template-columns: 26px 30px 1fr auto auto; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; cursor: pointer;
}
.board-row.me { background: #fff3c4; }
.board-rank { font-family: var(--pixel); font-size: 10px; text-align: center; }
.board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.online-dot { display: inline-block; width: 8px; height: 8px; background: var(--green); border: 1.5px solid var(--ink); border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.board-pos { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.board-pos b { font-family: var(--pixel); font-size: 11px; }
.board-pos small { font-size: 10px; font-weight: 900; }
.up { color: var(--green-d); } .down { color: var(--red); }
.board-today { font-size: 12px; color: var(--ink-soft); }
.board-foot { margin: 10px 0 0; }

/* today + play */
.play-bar { display: flex; gap: 10px; padding: 8px 12px calc(10px + var(--safe-bottom)); align-items: stretch; z-index: 4; }
.today { flex: 1; min-width: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.countdown { font-size: 12px; color: var(--muted); white-space: nowrap; }
.progress { position: relative; height: 22px; background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--green) 0 10px, #6fd24d 10px 20px); transition: width 0.6s; }
.progress-fill.full { background: repeating-linear-gradient(90deg, var(--gold) 0 10px, #ffe066 10px 20px); }
.progress-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 900; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.today-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-soft); }
.projected { color: var(--green-d); font-weight: 900; }
.play-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.play-col .btn-link { font-size: 11px; padding: 2px; text-align: center; max-width: 120px; }
.play-btn {
  width: 112px; flex: 1; min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--red); color: var(--gold); border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 0 5px 0 var(--ink), inset 0 -6px 0 var(--red-d), inset 0 4px 0 #ff6b5f;
  font-family: var(--pixel); font-size: 16px; text-shadow: 2px 2px 0 var(--ink); animation: pulse 2.2s ease-in-out infinite;
  transition: transform 0.06s;
}
.play-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink), inset 0 -6px 0 var(--red-d); }
.play-btn.restart { background: var(--blue); box-shadow: 0 5px 0 var(--ink), inset 0 -6px 0 var(--blue-d), inset 0 4px 0 #5b93f0; font-size: 11px; }
.play-icon { font-size: 22px; }
@keyframes pulse { 50% { filter: brightness(1.12); } }

.only-mobile { display: inline-grid; }
/* mobile: leaderboard is a bottom sheet */
@media (max-width: 899px) {
  .board {
    position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 20; max-height: 70dvh; padding: 14px;
    transform: translateY(115%); transition: transform 0.25s;
  }
  .board.open { transform: none; }
}
@media (max-width: 380px) {
  .play-btn { width: 92px; font-size: 13px; }
}

/* desktop: three columns */
@media (min-width: 900px) {
  .only-mobile { display: none; }
  .mountain-view {
    display: grid; grid-template-columns: minmax(260px, 320px) 1fr minmax(260px, 320px); grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: 'hud hud hud' 'board center chat' 'board center play';
  }
  .hud { grid-area: hud; padding: 14px 20px 6px; }
  .mountain-main { display: contents; }
  .board { grid-area: board; align-self: start; margin: 12px 0 0 20px; padding: 16px; max-height: calc(100dvh - 110px); }
  .mountain-center { grid-area: center; min-height: 0; }
  .mountain-stage { width: min(100%, calc((100dvh - 90px) * 0.6667)); }
  .play-bar { grid-area: play; flex-direction: column; justify-content: flex-end; padding: 14px 20px 24px 0; gap: 14px; }
  .today { flex: none; }
  .play-btn { width: 100%; flex: none; min-height: 110px; font-size: 22px; }
  .play-col .btn-link { max-width: none; font-size: 13px; }
  .day-pill { font-size: 12px; }
  .me-text b { max-width: 220px; }
}

/* group chat: a column beside the mountain on desktop, a bottom sheet on phones */
/* (climbers' z-indexes stay inside the mountain, under the chat and leaderboard sheets) */
.mountain-wrap { isolation: isolate; }
.gchat { display: flex; flex-direction: column; min-height: 0; padding: 12px; }
.gchat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.gchat-head h2 { font-family: var(--pixel); font-size: 12px; margin: 0; }
.gchat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 6px; }
.gchat-more { display: block; margin: 0 auto 6px; font-size: 12px; }
.gchat-empty { text-align: center; margin: 24px 8px; }
.gchat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.gchat-msg { display: flex; align-items: flex-end; gap: 6px; animation: msgIn 0.25s ease-out; }
.gchat-msg.cont { margin-top: -3px; }
.gchat-msg.mine { flex-direction: row-reverse; }
.gchat-avatar { flex: none; width: 28px; height: 28px; display: grid; place-items: center; }
.gchat-bubble { min-width: 0; max-width: 85%; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px 12px 12px 4px; padding: 4px 9px 5px; }
.gchat-msg.mine .gchat-bubble { background: #fff3c4; border-radius: 12px 12px 4px 12px; }
.gchat-who { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
.gchat-who time { font-size: 10px; color: var(--muted); }
.gchat-text { font-size: 14px; font-weight: 600; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.gchat-form { display: flex; gap: 6px; margin-top: 8px; }
.gchat-input {
  flex: 1; min-width: 0; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px; background: var(--paper); font: inherit; font-size: 16px; font-weight: 600;
}
.gchat-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43, 110, 228, 0.25); }
.gchat-fab {
  position: absolute; right: 12px; bottom: 10px; z-index: 6; width: 52px; height: 52px; border-radius: 50%; place-items: center;
  border: 3px solid var(--ink); background: var(--paper); box-shadow: var(--shadow-sm); font-size: 24px; padding: 0;
}
.gchat-fab:active { transform: translateY(3px); box-shadow: none; }
@media (max-width: 899px) {
  .gchat {
    position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 21; height: min(70dvh, 560px);
    transform: translateY(115%); transition: transform 0.25s;
  }
  .gchat.open { transform: none; }
}
@media (min-width: 900px) {
  .gchat { grid-area: chat; margin: 12px 20px 0 0; }
}

/* what a climber just said, over their head on the mountain */
.climber.speaking { z-index: 3000 !important; }
.climber-say {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 170px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; padding: 3px 7px; box-shadow: 0 2px 0 var(--ink);
  font-size: 11px; font-weight: 700; line-height: 1.25; text-align: left; white-space: normal; color: var(--ink); pointer-events: none;
  animation: sayIn 0.25s ease-out;
}
@keyframes sayIn { from { opacity: 0; translate: 0 6px; } }
.climber-say::after {
  content: ''; position: absolute; top: 100%; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--ink);
}
.climber-say.to-left { left: auto; right: 10%; transform: none; }
.climber-say.to-left::after { left: auto; right: 12px; }
.climber-say.to-right { left: 10%; transform: none; }
.climber-say.to-right::after { left: 12px; }

/* @mentions */
.gchat-at { font-weight: 900; color: var(--blue-d); }
.gchat-at.me { background: var(--gold); color: var(--ink); border-radius: 5px; padding: 0 3px; }
.gchat-msg.at-me .gchat-bubble { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(43, 110, 228, 0.25); }
.gchat-name { border: 0; background: none; padding: 0; font: inherit; font-weight: 900; color: inherit; cursor: pointer; }
.gchat-name:hover { text-decoration: underline; }
.gchat-form { position: relative; }
.gchat-suggest {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 3; display: flex; flex-direction: column; padding: 4px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow-sm);
}
.gchat-suggest[hidden] { display: none; }
.gchat-suggest-item { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 5px 8px; border-radius: 7px; font-weight: 800; text-align: left; }
.gchat-suggest-item.active, .gchat-suggest-item:hover { background: var(--cream-2); }
.gchat-fab.at-me .badge { background: var(--blue); }

/* emoji reactions */
.gchat-body { min-width: 0; max-width: 85%; display: flex; flex-direction: column; align-items: flex-start; }
.gchat-msg.mine .gchat-body { align-items: flex-end; }
.gchat-body .gchat-bubble { max-width: 100%; cursor: pointer; }
.gchat-reacts { position: relative; display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.gchat-reacts:not(.has) { margin-top: 0; }
.gchat-react {
  display: inline-flex; align-items: center; gap: 2px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--paper);
  padding: 0 6px; font-size: 13px; line-height: 20px;
}
.gchat-react small { font-size: 11px; font-weight: 900; }
.gchat-react.mine { background: #fff3c4; border-color: var(--gold-d); }
.gchat-react-add { opacity: 0; font-size: 11px; color: var(--ink-soft); transition: opacity 0.15s; }
.gchat-msg:hover .gchat-react-add, .gchat-react-add:focus-visible, .gchat-reacts.has .gchat-react-add { opacity: 1; }
.gchat-reacts:not(.has) .gchat-react-add { position: absolute; top: -2px; }
.gchat-msg:not(.mine) .gchat-reacts:not(.has) .gchat-react-add { left: 0; }
.gchat-msg.mine .gchat-reacts:not(.has) .gchat-react-add { right: 0; }
@media (hover: none) { .gchat-reacts:not(.has) .gchat-react-add { display: none; } }
.gchat-picker {
  position: absolute; bottom: calc(100% + 4px); z-index: 4; display: flex; gap: 2px; padding: 4px; white-space: nowrap;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; box-shadow: var(--shadow-sm); animation: sayIn 0.15s ease-out;
}
.gchat-msg:not(.mine) .gchat-picker { left: 0; }
.gchat-msg.mine .gchat-picker { right: 0; }
.gchat-picker button { border: 0; background: none; font-size: 20px; width: 34px; height: 34px; border-radius: 50%; padding: 0; transition: transform 0.1s; }
.gchat-picker button:hover { transform: scale(1.2); }
.gchat-picker button.mine { background: #fff3c4; }

/* "taunt them in Polish!" after an overtake */
.taunt-card {
  position: fixed; left: 50%; top: calc(64px + var(--safe-top)); z-index: 90; width: min(440px, calc(100% - 24px));
  transform: translate(-50%, -12px); opacity: 0; transition: transform 0.25s, opacity 0.25s;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 12px 12px;
}
.taunt-card.show { transform: translate(-50%, 0); opacity: 1; }
.taunt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 8px; }
.taunt-x { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--ink); background: var(--paper); font-weight: 900; padding: 0; }
.taunt-options { display: grid; gap: 6px; }
.taunt-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 7px 10px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 2px 0 var(--ink); transition: transform 0.06s;
}
.taunt-option:hover { background: #fff3c4; }
.taunt-option:active { transform: translateY(2px); box-shadow: none; }
.taunt-option:disabled { opacity: 0.6; }
.taunt-pl { font-weight: 900; font-size: 15px; }
.taunt-pron { font-size: 12px; color: var(--ink-soft); font-style: italic; }
.taunt-en { font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .taunt-card { transition: none; } }

/* =========================================================
   Chat
   ========================================================= */
.chat-view, .journeys-view {
  height: 100%; max-width: 780px; margin: 0 auto; display: flex; flex-direction: column;
  background: rgba(255, 248, 231, 0.96);
}
@media (min-width: 800px) {
  .chat-view, .journeys-view { height: calc(100% - 32px); margin-top: 16px; border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); overflow: hidden; }
}
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-top)) 12px 8px;
  background: var(--paper); border-bottom: 3px solid var(--ink); z-index: 3;
}
.chat-title { flex: 1; min-width: 0; }
.chat-story { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-scene { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.counter { display: flex; align-items: baseline; gap: 1px; padding: 6px 10px; border: 3px solid var(--ink); border-radius: 12px; background: #ffe9c2; white-space: nowrap; }
.counter b { font-size: 15px; }
.counter small { font-size: 12px; color: var(--ink-soft); }
.counter.done { background: var(--gold); }
.counter.private { background: #e9e2ff; }

.past-banner, .tip-banner { margin: 10px 12px 0; padding: 10px 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff3c4; font-size: 14px; }
.past-banner { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.tip-banner { background: #e6f4ff; position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; font-size: 13px; }
.tip-banner ol { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 6px; counter-reset: tip; flex: 1 1 100%; }
.tip-banner li { counter-increment: tip; background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; padding: 2px 8px; }
.tip-banner li::before { content: counter(tip) '. '; font-weight: 900; color: var(--red); }
.tip-banner p { margin: 0; flex: 1; }
input::-ms-reveal, input::-ms-clear { display: none; }

.chat-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 20px; overscroll-behavior: contain; scroll-padding-top: 8px; }
.load-more { display: block; margin: 0 auto 12px; }
.chat-list { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; animation: msgIn 0.25s ease-out; }
@keyframes msgIn { from { transform: translateY(8px); opacity: 0; } }
.msg-avatar { flex: none; width: 36px; height: 36px; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; display: grid; place-items: center; overflow: hidden; }
.msg.tutor { flex-wrap: wrap; align-items: flex-start; }
.msg.tutor .bubble { flex: 1; min-width: 0; max-width: 620px; background: var(--paper); border: 3px solid var(--ink); border-radius: 4px 16px 16px 16px; box-shadow: var(--shadow-sm); padding: 12px 14px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { max-width: 80%; background: var(--blue); color: #fff; border: 3px solid var(--ink); border-radius: 16px 4px 16px 16px; box-shadow: var(--shadow-sm); padding: 10px 14px; }
.msg.user.pending .bubble { opacity: 0.7; }
.user-text { font-size: 17px; font-weight: 800; word-break: break-word; }
.user-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 12px; }
.rating, .acc { background: rgba(255, 255, 255, 0.95); color: var(--ink); border-radius: 8px; padding: 2px 8px; font-weight: 900; border: 2px solid var(--ink); }
.rating.r-smart { background: var(--gold); animation: pop 0.4s; }
.rating.r-risky { background: #ffd2cf; }
.rating.r-creative { background: #e9e2ff; }
.rating.combo { background: linear-gradient(90deg, #ffb347, var(--gold), #ff7a59); animation: pop 0.4s, pulse 0.9s 3; }

.feedback { border: 2px solid var(--ink); border-left-width: 6px; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 14px; }
.fb-perfect { background: #e8f8e1; border-left-color: var(--green-d); }
.fb-good { background: #e6f0ff; border-left-color: var(--blue); }
.fb-almost { background: #fff1dc; border-left-color: #e08a00; }
.fb-try { background: #ffe5e3; border-left-color: var(--red); }
.fb-badge { font-weight: 900; }
.fb-correction { margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fb-tip { margin-top: 4px; font-weight: 600; color: var(--ink-soft); }

.scene-chip { display: inline-block; font-size: 12px; font-weight: 900; background: var(--cream-2); border: 2px solid var(--ink); border-radius: 8px; padding: 2px 8px; margin-bottom: 8px; }
.line { padding: 6px 0; }
.line + .line { border-top: 2px dashed #e7dfcf; }
.speaker { font-size: 12px; font-weight: 900; color: var(--red-d); text-transform: uppercase; letter-spacing: 0.5px; }
.pl { font-size: 19px; font-weight: 900; line-height: 1.3; display: flex; align-items: flex-start; gap: 6px; }
.pl span { flex: 1; }
.pron { font-size: 13px; font-style: italic; color: #7a5a00; margin-top: 2px; font-weight: 700; }
.en { font-size: 14px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.speak { flex: none; border: 2px solid var(--ink); background: var(--cream-2); border-radius: 8px; width: 30px; height: 28px; font-size: 14px; padding: 0; line-height: 1; }
.speak:active { transform: translateY(2px); }
.vocab { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.vocab-chip { border: 2px dashed var(--ink-soft); background: #fffbe9; border-radius: 10px; padding: 4px 8px; font-size: 13px; text-align: left; }
.vocab-chip::before { content: '📒 '; }
.vocab-chip small { color: var(--muted); font-weight: 600; }

.options-wrap { width: 100%; padding-left: 44px; margin-top: 4px; }
.options-label { font-size: 12px; font-weight: 900; color: var(--ink-soft); margin: 2px 0 6px; }
.options { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 600px) { .options { grid-template-columns: 1fr 1fr; } }
.option {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 10px 12px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow-sm); transition: transform 0.08s, background 0.15s;
}
.option:hover { transform: translateY(-2px); }
.option:active { transform: translateY(2px); box-shadow: none; }
.option.selected { background: #fff3c4; border-color: var(--red); box-shadow: 0 3px 0 var(--red-d); }
.opt-letter { flex: none; width: 26px; height: 26px; display: grid; place-items: center; font-family: var(--pixel); font-size: 10px; background: var(--gold); border: 2px solid var(--ink); border-radius: 8px; }
.option.selected .opt-letter { background: var(--red); color: #fff; }
.opt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-pl { font-weight: 900; font-size: 16px; }
.opt-pron { font-size: 12px; font-style: italic; color: #7a5a00; }
.opt-en { font-size: 13px; color: var(--muted); font-weight: 600; }
.opt-en.opt-hidden { font-style: italic; opacity: 0.7; }
.blind-status { font-size: 12px; font-weight: 800; color: var(--ink-soft); margin: 0 0 6px; }
.blind-status.on { color: #7a5a00; }

.typing .bubble { display: flex; align-items: center; gap: 6px; flex: none !important; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; background: var(--ink); border-radius: 2px; animation: dot 1s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 50% { transform: translateY(-5px); opacity: 0.4; } }

.composer { border-top: 3px solid var(--ink); background: var(--paper); padding: 8px 10px calc(8px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; }
.target { border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; background: #fffbe9; }
.target.done { background: #e8f8e1; }
.target-browse { display: none; }
@media (max-width: 899px) {
  .target { touch-action: pan-y pinch-zoom; }
  .target-browse { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-soft); }
  .target-browse button { border: 0; background: none; color: var(--ink); font-size: 26px; min-width: 44px; min-height: 44px; padding: 0; }
}
.target-head { display: flex; align-items: center; gap: 8px; }
.target-head .muted { flex: 1; }
.target-x { border: 0; background: none; font-weight: 900; padding: 2px 6px; }
.target-text { font-size: 19px; font-weight: 900; letter-spacing: 0.5px; margin-top: 2px; word-break: break-word; }
.target-pron { font-size: 12px; font-style: italic; color: #7a5a00; }
.tc.todo { color: #a49cb3; }
.tc.ok { color: var(--green-d); }
.tc.close { color: #d98200; text-decoration: underline wavy; text-underline-offset: 3px; }
.tc.bad { color: var(--red); background: #ffe0dd; border-radius: 3px; }
/* Word map: the Polish word you're typing and its English match glow together */
.pw, .ew { border-radius: 5px; transition: background-color 0.15s; }
.pw.now, .ew.now { background: #ffe66d; box-shadow: 0 0 0 2px #ffe66d; }
.target-en { font-size: 14px; font-weight: 700; color: #5e5670; margin-top: 3px; line-height: 1.5; }
.target-flag { font-weight: 400; }
.ew.ok { color: var(--green-d); }
.ew.close { color: #d98200; text-decoration: underline wavy; text-underline-offset: 3px; }
.ew.bad { color: var(--red); background: #ffe0dd; }
.ew.bad.now { background: #ffe66d; }
.keys-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.keys-row::-webkit-scrollbar { display: none; }
.pl-keys { display: flex; gap: 6px; }
.pl-key { flex: none; min-width: 36px; height: 36px; border: 2px solid var(--ink); border-radius: 9px; background: var(--cream-2); font-weight: 900; font-size: 17px; box-shadow: 0 2px 0 var(--ink); padding: 0 6px; }
.pl-key:active { transform: translateY(2px); box-shadow: none; }
.pl-key.shift.on { background: var(--gold); }
.composer-form { display: flex; gap: 8px; }
.chat-input { flex: 1; min-width: 0; border: 3px solid var(--ink); border-radius: 14px; padding: 12px 14px; font-size: 17px; font-weight: 800; background: var(--paper); }
.chat-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43, 110, 228, 0.25); }
.send-btn { width: 54px; flex: none; border: 3px solid var(--ink); border-radius: 14px; background: var(--green); color: #fff; font-size: 22px; box-shadow: var(--shadow-sm); text-shadow: 1px 1px 0 var(--ink); }
.send-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.send-btn:disabled { background: #9ccf8a; }

/* =========================================================
   Journeys
   ========================================================= */
.journeys-body { flex: 1; overflow-y: auto; padding: 12px 14px calc(24px + var(--safe-bottom)); }
.section-title { font-family: var(--pixel); font-size: 12px; margin: 18px 0 4px; line-height: 1.6; }
.section-title:first-child { margin-top: 6px; }
.story-card { display: flex; align-items: center; gap: 12px; padding: 12px; margin-top: 10px; background: var(--paper); }
.story-emoji { font-size: 30px; }
.story-info { flex: 1; min-width: 0; }
.story-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-actions { display: flex; gap: 6px; align-items: center; }
.small-icon { width: 36px; height: 36px; font-size: 15px; }
.empty { padding: 14px; text-align: center; margin-top: 10px; }
.empty p { margin: 0 0 10px; }
.new-journey { width: 100%; margin-top: 12px; border-style: dashed; }

/* ---------- the trail ahead: first-person view behind the climb chat ---------- */
.chat-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-stage > .chat-scroll { z-index: 1; transition: opacity 0.35s ease; }
.trail { position: absolute; inset: 0; z-index: 0; overflow: hidden; background: var(--sky-bottom); }
.trail-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; animation: trail-in 0.5s ease-out; }
@keyframes trail-in { from { opacity: 0; } }
/* Loose text sits on the road now: give it a card to stand on */
.trail-on .options-label, .trail-on .blind-status, .trail-on .load-more {
  width: fit-content; background: rgba(255, 255, 255, 0.94); border: 2px solid var(--ink); border-radius: 8px; padding: 2px 8px;
}
.trail-on .blind-status { max-width: 100%; }
.hint { display: flex; align-items: flex-start; gap: 6px; }
.hint-text { flex: 1; min-width: 0; }
.hint-x {
  flex: none; border: 0; background: none; padding: 0 2px; font-size: 16px; line-height: 1; font-weight: 900;
  color: inherit; opacity: 0.55; cursor: pointer;
}
.hint-x:hover, .hint-x:focus-visible { opacity: 1; }
.chat-view.peek .chat-scroll { opacity: 0.18; }
.chat-view.scenic .chat-scroll { opacity: 0; pointer-events: none; }

/* ---------- exploring the trail: drag to look, hold to walk your ghost, pinch to zoom ---------- */
.chat-view.scenic .trail { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.trail.exploring.grabbing { cursor: grabbing; }
/* A soft vignette while exploring, like looking through a lens (here, not on the canvas: it's free) */
.trail::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.65s ease;
  background: radial-gradient(ellipse at 50% 50%, rgba(20, 14, 40, 0) 55%, rgba(20, 14, 40, 0.32) 100%);
}
.trail.exploring::after { opacity: 1; }
.trail-nav { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 0.45s ease; }
.trail-nav.on { opacity: 1; }
.trail-nav [hidden] { display: none !important; }
.trail-nav button { pointer-events: auto; font: inherit; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.trail-nav button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.tn-hint {
  position: absolute; left: 8px; right: 8px; bottom: 64px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.tn-hint.gone { opacity: 0; transform: translateY(8px); }
.tn-tip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px 4px 4px; background: rgba(255, 255, 255, 0.94);
  border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); font-size: 12px; font-weight: 800; white-space: nowrap;
}
.tn-tip-ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--gold); border: 2px solid var(--ink); font-size: 11px; }
.trail-nav.on .tn-tip { animation: tn-drop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) 0.35s both; }
.trail-nav.on .tn-tip:nth-child(2) { animation-delay: 0.47s; }
.trail-nav.on .tn-tip:nth-child(3) { animation-delay: 0.59s; }
.trail-nav.on .tn-tip:nth-child(4) { animation-delay: 0.71s; }
@keyframes tn-drop { from { opacity: 0; transform: translateY(12px) scale(0.85); } }

.tn-top { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; gap: 8px; }
.trail-nav.on .tn-top { animation: tn-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) 0.15s both; }
.tn-compass {
  position: relative; width: 48px; height: 48px; padding: 0; border-radius: 50%; border: 3px solid var(--ink);
  background: radial-gradient(circle at 50% 35%, #ffffff, #dff1ff); box-shadow: 0 3px 0 var(--ink);
}
.tn-compass:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tn-dial { position: absolute; inset: 0; border-radius: 50%; }
.tn-dial::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; border: 2px dotted rgba(42, 31, 61, 0.35); }
.tn-peak { position: absolute; left: 50%; top: -1px; transform: translateX(-50%); font-size: 14px; line-height: 1; filter: drop-shadow(0 1px 0 #fff); }
.tn-you {
  position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--ink); animation: tn-blink 1.6s ease-in-out infinite;
}
.tn-facing {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-50%, -70%);
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 13px solid var(--ink);
}
.tn-zoom {
  height: 30px; padding: 0 11px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); box-shadow: 0 2px 0 var(--ink);
  font-weight: 900; font-size: 13px; font-variant-numeric: tabular-nums; animation: tn-pop 0.3s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes tn-pop { from { opacity: 0; transform: scale(0.6); } }
@keyframes tn-blink { 50% { box-shadow: 0 0 0 4px rgba(255, 204, 0, 0.45); } }

.tn-bar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 16px);
}
.trail-nav.on .tn-bar { animation: tn-rise 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
@keyframes tn-rise { from { opacity: 0; transform: translate(-50%, 18px); } }
.tn-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 15px; border: 3px solid var(--ink); border-radius: 999px;
  background: var(--paper); box-shadow: 0 4px 0 var(--ink); font-weight: 900; font-size: 14px; white-space: nowrap;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.tn-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tn-home { background: var(--gold); animation: tn-pop 0.35s cubic-bezier(0.2, 1.5, 0.4, 1); }
.tn-ghost {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0; height: 36px; padding: 0 13px 0 5px; border-radius: 999px;
  background: rgba(42, 31, 61, 0.7); border: 2px solid rgba(255, 255, 255, 0.4); color: #fff; font-weight: 800; font-size: 13px;
  white-space: nowrap; font-variant-numeric: tabular-nums; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tn-ghost-text { overflow: hidden; text-overflow: ellipsis; }
.tn-ghost-ic { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: rgba(190, 230, 255, 0.28); animation: tn-float 2.4s ease-in-out infinite; }
@keyframes tn-float { 50% { transform: translateY(-3px); } }
@media (max-width: 400px) { .tn-label { display: none; } .tn-btn { padding: 0 12px; } }

/* The ring under your finger: it closes in as you hold, then ripples as you walk. */
.tn-ring { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.tn-ring::before, .tn-ring::after { content: ''; position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; opacity: 0; }
.tn-ring::before {
  border: 3px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 2px rgba(42, 31, 61, 0.3), 0 0 18px rgba(160, 220, 255, 0.85);
  transform: scale(1.7); transition: transform 0.24s ease-out, opacity 0.2s ease-out;
}
.tn-ring.on::before { opacity: 1; transform: scale(1); transition-delay: 0.05s, 0.05s; }
.tn-ring.walk::before { animation: tn-breathe 0.9s ease-in-out infinite; }
.tn-ring.walk::after { border: 2px solid rgba(255, 255, 255, 0.9); animation: tn-ripple 0.9s ease-out infinite; }
.tn-ring.ping::after { border: 3px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 14px rgba(160, 220, 255, 0.9); animation: tn-ripple 0.6s ease-out both; }
@keyframes tn-breathe { 50% { transform: scale(0.86); } }

/* Pulling against the tether */
.tn-ghost.tug { background: rgba(120, 40, 60, 0.78); }
.tn-ghost.tug .tn-ghost-ic { animation: tn-tug 0.35s ease-in-out 2; }
@keyframes tn-tug { 25% { transform: translateX(-4px) rotate(-10deg); } 75% { transform: translateX(4px) rotate(10deg); } }

/* Secrets off the trail: the tally, and the card when you find one */
.tn-eggs {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--paper); box-shadow: 0 2px 0 var(--ink); font-size: 13px; font-variant-numeric: tabular-nums;
}
.egg-card {
  position: absolute; left: 50%; top: 70px; transform: translateX(-50%); width: min(380px, calc(100% - 20px)); display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 34px 12px 10px; background: linear-gradient(180deg, #fffbe6, #fff0b3); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink);
  animation: egg-in 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both; transition: opacity 0.3s ease, transform 0.3s ease;
}
.egg-card.gone { opacity: 0; transform: translate(-50%, -12px); }
.egg-card-ic { flex: none; display: grid; place-items: center; width: 52px; height: 52px; font-size: 34px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; animation: egg-hop 0.5s ease-out 0.4s 2; }
.egg-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.egg-card-kicker { font-family: var(--pixel); font-size: 10px; line-height: 1.5; color: var(--ink-soft); }
.egg-card-word { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.egg-card-word b { font-size: 20px; }
.egg-card-en { color: var(--ink-soft); font-size: 13px; }
.egg-card-fact { font-size: 13px; line-height: 1.35; }
.trail-nav .egg-card-say { width: 28px; height: 28px; padding: 0; border: 2px solid var(--ink); border-radius: 50%; background: var(--gold); font-size: 13px; }
.trail-nav .egg-card-x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0; border: none; background: none; font-size: 14px; color: var(--ink-soft); }
@keyframes egg-in { from { opacity: 0; transform: translate(-50%, -24px) scale(0.7); } }
@keyframes egg-hop { 40% { transform: translateY(-8px) rotate(-8deg); } }
@keyframes tn-ripple { from { opacity: 0.9; transform: scale(0.8); } to { opacity: 0; transform: scale(2.3); } }
@media (prefers-reduced-motion: reduce) {
  .trail-nav *, .trail-nav *::before, .trail-nav *::after { animation: none !important; transition: none !important; }
}

.race-strip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: #fff3c4; border-bottom: 3px solid var(--ink);
  font-size: 13px; z-index: 2; min-height: 40px;
}
.rs-me { display: flex; align-items: center; gap: 6px; flex: none; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; padding: 2px 8px 2px 3px; }
.rs-avatar { display: grid; place-items: center; }
.rs-pos { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rs-pos small { color: var(--muted); }
.rs-chips { flex: 1; min-width: 0; display: flex; gap: 6px; overflow: hidden; }
.rs-chip { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; min-width: 0; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; padding: 3px 7px; font-variant-numeric: tabular-nums; }
.rs-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rs-gap { flex: none; }
.rs-arrow { flex: none; font-size: 10px; color: var(--green-d); }
.rs-chip.behind .rs-arrow { color: var(--red); }
.rs-chip.ahead { flex: 0 1 auto; }
.rs-chip.behind { flex: 0 1 auto; background: #eef3ff; }
.rs-look { flex: none; width: 34px; height: 30px; border: 2px solid var(--ink); border-radius: 9px; background: var(--paper); font-size: 16px; padding: 0; box-shadow: 0 2px 0 var(--ink); }
.rs-look.on { background: var(--gold); }
.rs-look:active { transform: translateY(2px); box-shadow: none; }
.rs-me.dizzy .rs-avatar { animation: dizzy 1.4s ease-in-out; }
.rs-me.dizzy::after { content: '😵'; margin-left: -2px; animation: pop 0.4s; }
.rs-me.cheer .rs-avatar { animation: cheer 0.5s ease-out 3; }
@keyframes dizzy { 0% { transform: rotate(0); } 60% { transform: rotate(720deg) scale(0.85); } 100% { transform: rotate(720deg); } }
@keyframes cheer { 50% { transform: translateY(-8px) scale(1.15); } }

.trail-fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 14%; gap: 8px; }
.trail-banner {
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px); padding: 10px 16px 10px 10px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); animation: banner 2.9s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}
.trail-banner b { display: block; font-family: var(--pixel); font-size: 12px; line-height: 1.5; }
.trail-banner small { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.trail-banner .tb-avatar { flex: none; background: var(--cream-2); border: 2px solid var(--ink); border-radius: 10px; padding: 2px; }
.trail-banner.bad { background: #ffe5e3; }
.trail-banner.bad .tb-avatar { animation: dash-in 0.6s ease-out; }
.trail-banner.good { background: #e8f8e1; }
.trail-banner.gold { background: linear-gradient(180deg, #fff6b8, var(--gold)); }
.trail-banner.small { padding: 6px 12px 6px 6px; box-shadow: 0 3px 0 var(--ink); animation-duration: 2.3s; }
.trail-banner.small b { font-family: var(--font); font-size: 14px; }
@keyframes banner {
  0% { transform: translateY(-30px) scale(0.6); opacity: 0; }
  12% { transform: none; opacity: 1; }
  85% { transform: none; opacity: 1; }
  100% { transform: translateY(-16px); opacity: 0; }
}
@keyframes dash-in { from { transform: translateX(-60px) rotate(-12deg); } }

/* ---------- mountain: live gliding, overtakes, zooming into the trail ---------- */
.climber.glide { transition: left 0.85s ease-in-out, top 0.85s ease-in-out; }
.climber.dash .climber-sprite { animation: map-dash 1.2s ease-out; }
.climber.dash::after { content: '💨'; position: absolute; left: -70%; top: 10%; font-size: 14px; animation: puff 1.2s ease-out forwards; }
.climber.dizzy .climber-sprite { animation: dizzy 1.4s ease-in-out; }
.climber.dizzy::after { content: '💫'; position: absolute; top: -14px; font-size: 13px; animation: puff 1.5s ease-out forwards; }
.climber-crown { position: absolute; top: -26px; font-size: 18px; animation: crown 2.6s ease-out forwards; pointer-events: none; }
@keyframes map-dash { 20% { transform: translateY(-10px) scale(1.25) rotate(-10deg); } 45% { transform: translateY(-4px) scale(1.15) rotate(6deg); } }
@keyframes puff { from { opacity: 1; } to { opacity: 0; transform: translateX(-8px) scale(1.4); } }
@keyframes crown { 0% { transform: translateY(10px) scale(0.3); opacity: 0; } 15% { transform: translateY(-6px) scale(1.3); opacity: 1; } 30% { transform: none; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
.mountain-stage.zoom-in { animation: zoom-in 0.62s cubic-bezier(0.6, 0, 0.9, 0.5) forwards; }
.mountain-stage.zoom-out { animation: zoom-out 0.85s cubic-bezier(0.2, 0.7, 0.3, 1); }
@keyframes zoom-in { to { transform: scale(7); filter: blur(3px) brightness(1.6); opacity: 0; } }
@keyframes zoom-out { from { transform: scale(5); filter: blur(2px) brightness(1.5); opacity: 0.2; } }

/* ---------- secret-answer combos: shake, bounce, burst ---------- */
.chat-view.shake-2 { animation: shake 0.16s linear 5; }
.chat-view.shake-3 { animation: shake-hard 0.13s linear 10; }
@keyframes shake {
  25% { transform: translate(-6px, 2px) rotate(-0.6deg); }
  50% { transform: translate(5px, -3px) rotate(0.5deg); }
  75% { transform: translate(-4px, -1px) rotate(-0.3deg); }
}
@keyframes shake-hard {
  20% { transform: translate(-11px, 4px) rotate(-1.2deg); }
  40% { transform: translate(10px, -5px) rotate(1deg); }
  60% { transform: translate(-8px, -4px) rotate(-0.8deg); }
  80% { transform: translate(9px, 3px) rotate(0.9deg); }
}
.msg-avatar.bounce-2 { animation: combo-bounce 0.45s ease-in-out 4; }
.msg-avatar.bounce-3 { animation: combo-bounce-big 0.4s ease-in-out 7; overflow: visible; box-shadow: 0 0 0 3px var(--gold); }
@keyframes combo-bounce { 50% { transform: translateY(-14px) scale(1.1); } }
@keyframes combo-bounce-big { 50% { transform: translateY(-22px) scale(1.25) rotate(-6deg); } }

.combo-burst { position: fixed; inset: 0; z-index: 90; pointer-events: none; display: grid; place-items: center; align-content: center; gap: 10px; }
.combo-avatar {
  background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; padding: 8px; box-shadow: 0 6px 0 var(--ink), 0 0 0 8px var(--gold);
  animation: combo-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1), avatar-jump 0.42s 0.35s ease-in-out 3, combo-out 0.35s 1.7s forwards;
}
.combo-title {
  font-family: var(--pixel); font-size: 20px; color: var(--ink); background: var(--gold); border: 3px solid var(--ink); border-radius: 12px; padding: 6px 12px;
  box-shadow: var(--shadow-sm); animation: combo-pop 0.4s 0.1s cubic-bezier(0.2, 1.6, 0.4, 1) both, combo-out 0.35s 1.7s forwards;
}
.combo-spark { position: absolute; left: 50%; top: 50%; font-size: 30px; opacity: 0; animation: spark 1.1s var(--d) ease-out forwards; }
.tier-3 .combo-avatar { animation: combo-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1), avatar-jump-big 0.36s 0.35s ease-in-out 6, combo-out 0.4s 2.4s forwards; }
.tier-3 .combo-title { font-size: 24px; background: linear-gradient(90deg, #ffb347, var(--gold), #ff7a59); animation: combo-pop 0.4s 0.1s cubic-bezier(0.2, 1.6, 0.4, 1) both, pulse 0.5s 0.5s 4, combo-out 0.4s 2.4s forwards; }
.tier-3 .combo-spark { font-size: 38px; animation-duration: 1.5s; }
.tier-3::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 214, 10, 0.55), transparent 65%); animation: flash 0.5s ease-out 3; }
@keyframes combo-pop { from { transform: scale(0.2); opacity: 0; } }
@keyframes combo-out { to { transform: scale(0.6) translateY(-40px); opacity: 0; } }
@keyframes avatar-jump { 50% { transform: translateY(-40px); } }
@keyframes avatar-jump-big { 40% { transform: translateY(-64px) rotate(-8deg) scale(1.08); } 80% { transform: translateY(4px) scaleY(0.92); } }
@keyframes spark {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--a)) translateY(0) scale(0.4); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateY(-46vmin) scale(1.2); }
}
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* =========================================================
   Games: picker, create, join, invite
   ========================================================= */
.games-view { height: 100%; max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; background: rgba(255, 248, 231, 0.96); }
@media (min-width: 720px) {
  .games-view { height: calc(100% - 32px); margin-top: 16px; border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); overflow: hidden; }
}
.games-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; }
.chat-story.center { text-align: center; }
.me-chip.compact { padding: 4px 10px 4px 4px; gap: 6px; }
.me-chip.compact b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-card { display: flex; flex-direction: column; gap: 8px; text-align: left; padding: 14px; background: var(--paper); transition: transform 0.1s; }
.game-card:hover { transform: translateY(-2px); }
.game-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.game-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.game-card-name { font-weight: 900; font-size: 18px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.game-card-status { font-family: var(--pixel); font-size: 10px; background: var(--gold); border: 2px solid var(--ink); border-radius: 8px; padding: 5px 7px; white-space: nowrap; }
.game-card-avatars { display: flex; gap: 2px; align-items: center; min-height: 26px; }
.game-card-me { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.mini-progress { height: 10px; border: 2px solid var(--ink); border-radius: 6px; background: var(--cream-2); overflow: hidden; }
.mini-progress i { display: block; height: 100%; background: var(--green); }
.games-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
/* Saved solo races: a quieter card you rejoin from, not a button. */
.saved-card { border-style: dashed; }
.saved-card:hover, .saved-card:active { transform: none; }
.saved-card .game-card-status { background: var(--paper); }
.saved-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wide-btn { width: 100%; padding: 14px; }
.games-empty { padding: 22px 18px; text-align: center; background: var(--paper); }
.games-empty-art { font-size: 54px; animation: bob 1.4s ease-in-out infinite; }
.games-empty p { color: var(--ink-soft); }

.length-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.length-grid.two { grid-template-columns: repeat(2, 1fr); }
.length-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); font-size: 13px; }
.length-card b { font-size: 14px; }
.length-card small { color: var(--muted); }
.length-card.on { background: #fff3c4; border-color: var(--red); box-shadow: 0 3px 0 var(--red-d); }

.invite { display: flex; flex-direction: column; gap: 12px; }
.invite > .btn-link { align-self: center; }
.invite p { margin: 0; }
.invite-code {
  font-family: var(--pixel); font-size: clamp(24px, 8vw, 34px); letter-spacing: 6px; text-align: center; padding: 18px 8px 16px;
  background: var(--paper); border: 3px dashed var(--ink); border-radius: 14px; user-select: all; color: var(--red-d);
}
.invite-buttons { flex-wrap: wrap; justify-content: center; }
.invite-link { width: 100%; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px; font-size: 13px; background: var(--cream-2); color: var(--ink-soft); }
.owner-tools { border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); padding: 8px 12px; }
.owner-tools summary { cursor: pointer; font-weight: 900; }
.owner-tools[open] summary { margin-bottom: 10px; }
.owner-tools .row input { flex: 1; min-width: 0; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px; font-weight: 700; }
.danger-link { color: var(--red-d); align-self: center; }

.code-input { text-transform: uppercase; letter-spacing: 3px; font-family: var(--pixel) !important; font-size: 14px !important; }
.code-input::placeholder { letter-spacing: 1px; font-family: var(--font); text-transform: none; }
.join-card { display: flex; flex-direction: column; gap: 2px; background: #e8f8e1; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; }
.join-card b { font-size: 18px; }
.join-info { display: flex; flex-direction: column; gap: 12px; }
.join-info:empty { display: none; }
.join-banner { background: #e8f8e1; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 15px; }
.ok-note { color: var(--green-d); font-weight: 900; }

/* HUD game pill */
button.day-pill { font-family: var(--pixel); display: flex; align-items: center; min-width: 0; flex: 1 1 auto; max-width: 280px; color: var(--ink); text-align: left; }
.pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pill-day, .pill-day-short { white-space: nowrap; flex: none; }
.pill-day-short { display: none; }
@media (max-width: 899px) {
  .hud .me-text { display: none; }
  .hud .me-chip { padding: 4px; }
  .hud-actions { gap: 6px; }
}
@media (max-width: 430px) {
  .pill-day { display: none; }
  .pill-day-short { display: inline; }
  .hud .hud-actions .icon-btn[aria-label='How to play'] { display: none; }
}

/* ---------- loot: coins, diamonds, sacks, the catch game, flag capture, game over ---------- */
/* Falling coins and diamonds (see .loot-catch below) */
.lr-coin {
  display: block; width: var(--c); height: var(--c); margin: calc(var(--c) / -2); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffbe0 0 14%, #ffe066 30%, #ffcc00 55%, #d9a400 100%);
  border: 2px solid var(--ink); box-shadow: inset 0 0 0 3px rgba(217, 164, 0, 0.55); animation: coin-spin var(--spin) linear infinite;
}
@keyframes coin-spin { 50% { transform: scaleX(0.15); } }
.lr-gem { display: block; margin: -12px; animation: gem-glint 0.6s ease-in-out infinite; }
@keyframes gem-glint { 50% { filter: brightness(1.35) drop-shadow(0 0 4px #fff); transform: rotate(8deg); } }
.lr-sack-wrap { position: relative; }
.lr-sack { display: block; width: 80px; height: 87px; }
.lr-sack-inner { display: block; height: 100%; transform: scale(var(--s)); transform-origin: 50% 100%; transition: transform 0.25s cubic-bezier(0.2, 1.6, 0.4, 1); }
.lr-sack-inner .sack { width: 100%; height: 100%; filter: drop-shadow(0 3px 0 rgba(42, 31, 61, 0.35)); }
.lr-sack.gulp .lr-sack-inner .sack { animation: gulp 0.2s ease-out; }
@keyframes gulp { 40% { transform: scale(1.08, 0.9); } }
.lr-rope { width: 26px; height: 3px; background: var(--ink); border-radius: 2px; margin: 0 -4px 22px; transform: rotate(-12deg); }
.lr-avatar { animation: hop 0.3s ease-in-out infinite; filter: drop-shadow(0 3px 0 rgba(42, 31, 61, 0.35)); }
.lr-tag {
  position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); white-space: nowrap; font-family: var(--pixel); font-size: 12px;
  background: var(--gold); border: 2px solid var(--ink); border-radius: 8px; padding: 4px 7px; box-shadow: var(--shadow-sm);
  animation: combo-pop 0.4s 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

/* The catch game: drag (or ← →) your avatar along the bottom to catch the loot in its sack */
.loot-catch {
  position: fixed; inset: 0; z-index: 95; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
  background: linear-gradient(180deg, rgba(42, 31, 61, 0.42), rgba(42, 31, 61, 0.12) 40%, rgba(42, 31, 61, 0.12) 65%, rgba(42, 31, 61, 0.4));
  animation: lc-fade 0.25s ease-out both;
}
.loot-catch:active { cursor: grabbing; }
.loot-catch.out { animation: lc-fade 0.45s ease-in reverse forwards; }
@keyframes lc-fade { from { opacity: 0; } }
.lc-drop { position: absolute; left: 0; top: 0; will-change: transform; pointer-events: none; }
.lc-head {
  /* Below the toasts at the top of the screen (a jackpot toast often comes with the coins) */
  position: absolute; left: 50%; top: 36%; transform: translateX(-50%); max-width: calc(100% - 24px); opacity: 0.94;
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; pointer-events: none;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 8px 14px; box-shadow: var(--shadow-sm);
  animation: combo-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.lc-head b { font-family: var(--pixel); font-size: 12px; line-height: 1.4; }
.lc-head span { font-size: 13px; }
.lc-keys { font-size: 11px; opacity: 0.7; transition: opacity 0.3s; }
.loot-catch.moved .lc-keys { opacity: 0; }
.lc-head.done { background: var(--gold); animation: combo-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.lc-hauler {
  position: absolute; left: 0; bottom: calc(7% + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; pointer-events: none;
  will-change: transform;
}
.lc-hauler .lr-sack-wrap { margin-bottom: -16px; z-index: 1; }
.lc-hauler .lr-avatar { animation-duration: 0.45s; }
.lc-hauler.in { animation: lc-in 0.5s ease-out both; }
.lc-hauler.out { animation: lc-out 0.5s ease-in forwards; }
@keyframes lc-in { from { translate: -70vw 0; } }
@keyframes lc-out { to { translate: 70vw 0; opacity: 0; } }
.lc-hauler .lr-tag { animation: none; bottom: calc(100% + 4px); }
.lc-victim { position: absolute; bottom: calc(30% + var(--safe-bottom)); display: flex; align-items: flex-end; pointer-events: none; }
.lc-victim.left { left: 6px; }
.lc-victim.right { right: 6px; flex-direction: row-reverse; }
.lc-victim.right .lc-victim-sack { transform: scaleX(-1); }
.lc-victim.burst { animation: lc-bump 0.5s ease-out; }
.lc-victim.burst .lc-victim-sack { animation: gulp 0.2s ease-out 3; }
@keyframes lc-bump { 25% { transform: translateY(-14px) rotate(-8deg); } 60% { transform: translateY(2px) rotate(4deg); } }
.loot-catch.lc-desktop { cursor: default; }
.lc-desktop .lc-head { top: max(86px, 10%); gap: 7px; padding: 16px 24px; border-radius: 20px; box-shadow: 0 6px 0 rgba(42, 31, 61, 0.18), 0 16px 40px rgba(42, 31, 61, 0.18); }
.lc-desktop .lc-head b { font-size: 14px; }
.lc-desktop .lc-keys, .lc-desktop .lc-bonus, .lc-score { font-size: 14px; }
.lc-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lc-progress { width: 100%; height: 8px; overflow: hidden; border-radius: 10px; background: rgba(42, 31, 61, 0.12); }
.lc-progress i { display: block; height: 100%; background: linear-gradient(90deg, #ffcc00, #ffa83e); transform: scaleX(0); transform-origin: left; transition: transform 0.2s ease-out; }
.lc-catch-zone { position: absolute; height: 12px; translate: -50% -50%; border: 2px solid #ffe066; border-radius: 50%; background: rgba(255, 224, 102, 0.18); box-shadow: 0 0 16px rgba(255, 204, 0, 0.6); opacity: 0.7; pointer-events: none; }
.lc-catch-pop { position: absolute; pointer-events: none; color: #fff3a6; font-size: 18px; font-weight: 900; text-shadow: 0 2px 3px var(--ink); animation: lc-pop 0.65s ease-out both; }
@keyframes lc-pop { from { transform: translate(-50%, -16px) scale(0.85); opacity: 1; } 25% { transform: translate(-50%, -30px) scale(1.15); opacity: 1; } to { transform: translate(-50%, -65px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .loot-catch .lr-coin, .loot-catch .lr-gem, .loot-catch .lr-avatar { animation: none; }
  .lc-catch-pop { animation: none; transform: translate(-50%, -32px); }
  .lc-progress i { transition: none; }
}

/* Race strip: your sack and its counters */
.rs-loot { display: flex; align-items: center; gap: 3px; flex: none; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; padding: 1px 6px 1px 2px; }
.rs-sack { display: grid; place-items: center; }
.rs-counts { display: flex; flex-direction: column; line-height: 1.1; font-size: 11px; font-variant-numeric: tabular-nums; }
.rs-count { white-space: nowrap; }
.rs-count b { margin-left: 2px; }
.rs-loot.bump { animation: loot-bump 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.rs-loot.bump .rs-sack { animation: gulp 0.25s ease-out 2; }
@keyframes loot-bump { 30% { transform: scale(1.18); background: #fff3c4; } }
.trail-banner.gem { background: linear-gradient(180deg, #eafcff, #9fe9ff); }

/* Mountain: your loot by your name, sacks behind the climbers, diamonds on the trail */
.me-loot { display: flex; align-items: center; gap: 3px; padding-left: 6px; border-left: 2px dashed rgba(42, 31, 61, 0.25); }
.me-loot > span { display: flex; flex-direction: column; line-height: 1.15; }
.me-loot small { font-size: 11px; font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; }
.board-loot { display: block; font-size: 10px; font-weight: 800; color: var(--ink-soft); line-height: 1.1; }
.climber-sack {
  position: absolute; right: 70%; top: 30%; width: calc(58% * var(--s, 1)); pointer-events: none; transform-origin: 100% 100%;
  filter: drop-shadow(0 2px 0 rgba(42, 31, 61, 0.3));
}
.climber-sack .sack { width: 100%; height: auto; display: block; }
.climber-sack::after { content: ''; position: absolute; right: -14%; top: 30%; width: 30%; height: 2px; background: var(--ink); transform: rotate(-20deg); }
.climber.glide .climber-sack { transition: width 0.6s ease; }
.gem-layer { position: absolute; inset: 0; pointer-events: none; }
.trail-gem {
  position: absolute; display: flex; align-items: center; transform: translate(-50%, -85%); filter: drop-shadow(0 2px 0 rgba(42, 31, 61, 0.35));
  animation: gem-float 1.4s ease-in-out infinite;
}
.trail-gem .gem { width: 3.4vmin; min-width: 12px; max-width: 18px; height: auto; }
.trail-gem small { font-size: 9px; font-weight: 900; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 5px; padding: 0 2px; margin-left: -2px; }
.trail-gem.taken { animation: gem-taken 0.7s ease-out forwards; }
@keyframes gem-float { 50% { transform: translate(-50%, -110%); filter: drop-shadow(0 2px 0 rgba(42, 31, 61, 0.35)) brightness(1.25); } }
@keyframes gem-taken { to { transform: translate(-50%, -260%) scale(1.8); opacity: 0; } }

/* The flag capture */
.capture {
  position: fixed; inset: 0; z-index: 110; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 214, 10, 0.35), rgba(20, 16, 40, 0.78) 70%); cursor: pointer;
  animation: trail-in 0.3s ease-out; padding: 16px;
}
.capture.out { opacity: 0; transition: opacity 0.3s; }
.cap-confetti { position: fixed; inset: 0; height: auto; }
.cap-stage { position: relative; width: min(86vw, 360px, 58vh); aspect-ratio: 3 / 4; }
.cap-castle { position: absolute; left: 10%; bottom: 3%; width: 80%; height: auto; overflow: visible; }
.cap-castle .cap-old { animation: flag-down 0.7s 2s ease-in forwards; }
.cap-castle .cap-new { transform: translateY(58px); opacity: 0; animation: flag-up 0.9s 2.5s cubic-bezier(0.3, 1.3, 0.5, 1) forwards; }
.cap-castle .cap-wave { transform-origin: 1px -138px; animation: wave 0.9s 3.4s ease-in-out infinite; }
@keyframes flag-down { to { transform: translateY(58px); opacity: 0; } }
@keyframes flag-up { 0% { opacity: 1; } 100% { transform: none; opacity: 1; } }
.cap-runner { position: absolute; width: 15%; left: -15%; bottom: 3%; transform: translateX(-50%); animation: cap-run 2s linear forwards; }
.cap-runner .sprite { width: 100%; height: auto; display: block; }
.cap-hop { position: relative; animation: hop 0.3s ease-in-out 5, cheer 0.45s 2.1s ease-out infinite; }
.cap-sack { position: absolute; right: 85%; bottom: 0; width: 55%; animation: cap-sack-off 0.4s 1.1s ease-in forwards; }
.cap-sack .sack { width: 100%; height: auto; display: block; }
@keyframes cap-sack-off { to { opacity: 0; transform: translateY(10px); } }
@keyframes cap-run {
  0% { left: -12%; bottom: 3%; }
  55% { left: 50%; bottom: 3%; }
  68% { left: 46%; bottom: 62%; }
  80%, 100% { left: 41%; bottom: 40.5%; }
}
.cap-fw { position: absolute; width: 0; height: 0; }
.cap-fw i {
  position: absolute; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: var(--c); opacity: 0;
  box-shadow: 0 0 6px var(--c); animation: fw 1.1s var(--fd) ease-out both;
}
@keyframes fw {
  0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(0.6); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(-70px) scale(1); }
}
.cap-title {
  text-align: center; background: linear-gradient(180deg, #fff6b8, var(--gold)); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 16px;
  box-shadow: 0 5px 0 var(--ink); animation: combo-pop 0.45s 2.9s cubic-bezier(0.2, 1.6, 0.4, 1) both; max-width: 92vw;
}
.cap-title b { display: block; font-family: var(--pixel); font-size: clamp(13px, 4vw, 20px); line-height: 1.5; }
.cap-title span { display: block; font-weight: 800; margin-top: 4px; }
.cap-skip { color: #fff; font-size: 12px; opacity: 0.75; animation: trail-in 0.4s 3.5s both; }
.capture.still *, .capture.still { animation-duration: 0.01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }

/* Game over */
.gameover { text-align: center; }
.go-title {
  font-family: var(--pixel); font-size: clamp(22px, 7vw, 34px); color: var(--red); letter-spacing: 2px; margin: 4px 0 8px;
  text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 #fff; animation: combo-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1), pulse 0.8s 0.5s 3;
}
.go-head { display: flex; justify-content: space-between; font-size: 11px; font-weight: 900; color: var(--muted); text-transform: uppercase; padding: 0 10px; margin-top: 10px; }
.go-board { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 44vh; overflow-y: auto; text-align: left; }
.go-row {
  display: grid; grid-template-columns: 30px 34px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; animation: rise 0.35s ease-out both;
}
.go-row:nth-child(2) { animation-delay: 0.08s; } .go-row:nth-child(3) { animation-delay: 0.16s; } .go-row:nth-child(n + 4) { animation-delay: 0.24s; }
.go-row.winner { background: linear-gradient(180deg, #fff6b8, var(--gold)); box-shadow: var(--shadow-sm); }
.go-row.me:not(.winner) { background: #fff3c4; }
.go-rank { font-size: 20px; text-align: center; font-family: var(--pixel); }
.go-row:nth-child(n + 4) .go-rank { font-size: 11px; }
.go-avatar { display: grid; place-items: center; }
.go-name { min-width: 0; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.go-name small { display: block; font-weight: 700; color: var(--ink-soft); font-size: 12px; }
.go-loot { display: flex; flex-direction: column; align-items: flex-end; font-weight: 900; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.go-again { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; align-items: stretch; }
.go-reminder { margin: 0; font-weight: 800; background: #e8f8e1; border: 2px dashed var(--green-d); border-radius: 10px; padding: 8px 10px; }
/* (loot, continued) On phones the sack moves to today's panel */
.today-loot { display: none; font-weight: 900; color: var(--ink); }
@media (max-width: 430px) {
  .me-loot { display: none; }
  .today-loot { display: inline; }
}

/* =========================================================
   Accounts: email nudges
   ========================================================= */
.menu-item.attention { background: #fff3c4; border-style: dashed; }
.admin-pending { background: #e9e2ff; border: 2px dashed var(--ink); border-radius: 12px; padding: 8px 10px; }
.tag-ok { background: #c9f2c0; }
.btn-danger { color: var(--red-d); }

/* =========================================================
   Host dashboards (#/admin, #/admin/usage)
   Chart chrome follows one spec: white chart surface, hairline solid grid,
   text in ink tokens, colour only on marks.
   ========================================================= */
.dash-view {
  height: 100%; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column;
  background: rgba(255, 248, 231, 0.97);
}
@media (min-width: 800px) {
  .dash-view { height: calc(100% - 32px); margin-top: 16px; border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); overflow: hidden; }
}
.dash-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.dash-inner { padding: 14px 14px calc(28px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.dash-body { display: flex; flex-direction: column; gap: 14px; transition: opacity 0.2s; }
.dash-body.refreshing { opacity: 0.5; pointer-events: none; }
.dash-tabs { margin: 0; max-width: 420px; }
.dash-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  border: 2px solid var(--ink); background: var(--paper); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 14px;
}
.chip.on { background: var(--ink); color: #fff; }
.dash-search, .dash-select {
  border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; background: var(--paper); font-weight: 700; min-width: 0;
}
.dash-search { flex: 1 1 220px; max-width: 360px; }
.dash-search:focus, .dash-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43, 110, 228, 0.25); }

/* hero figure: the one number the usage page leads with */
.dash-hero { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; padding: 18px 20px; background: var(--paper); }
.dash-hero-label { margin: 0; color: var(--muted); font-weight: 800; }
.dash-hero-value { margin: 2px 0 4px; font-size: 56px; line-height: 1.05; font-weight: 900; letter-spacing: -1px; }
.dash-hero-side { display: grid; gap: 10px; align-content: center; min-width: 220px; }
.dash-hero-side > div { display: flex; flex-direction: column; }
.dash-hero-side span { font-size: 13px; }
.delta { font-size: 14px; font-weight: 800; }
.delta.good { color: #006c10; }
.delta.bad { color: var(--red-d); }
.delta.flat { color: var(--muted); }
.status.ok { color: #006c10; }
.status.warn { color: #8a5a00; }
.status.bad { color: var(--red-d); }

/* stat tiles */
.dash-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.dash-tiles.tight { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); margin: 10px 0; }
.dash-tile { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; background: var(--paper); box-shadow: var(--shadow-sm); }
.dash-tile-label { font-size: 13px; color: var(--muted); font-weight: 800; }
.dash-tile-value { font-size: 24px; font-weight: 900; line-height: 1.2; }
.dash-tile-note { font-size: 12px; color: var(--muted); font-weight: 600; }

.dash-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 860px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid.three { grid-template-columns: 1fr 1fr 1fr; }
}
.dash-stack h4 { margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
.dash-stack h4 + .viz-seg-wrap { margin-bottom: 14px; }
.dash-foot { font-size: 12px; color: var(--muted); font-weight: 600; margin: 10px 0 0; }
.dash-empty { padding: 8px 0; margin: 0; }
.dash-note { padding: 12px 14px; margin: 0; background: #fff3c4; }
.dash-wins { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; }
.dash-wins li { display: flex; gap: 8px; align-items: center; }
.dash-checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 14px; }
.dash-checks a { color: var(--blue-d); }

/* players */
.player-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.player-cell .sprite, .player-cell svg { flex: none; }
.player-cell .tag, .admin-player-name .tag { margin: 0 0 0 4px; }
.email-cell { display: inline-flex; align-items: center; gap: 6px; }
.email-cell .tag { margin: 0; padding: 0 6px; }
.modal-panel.admin-modal { max-width: 760px; }
.admin-player .menu-user { padding-right: 36px; }
.admin-player-name { font-size: 18px; }
.admin-h { margin: 16px 0 6px; font-size: 14px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-stories { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 3px; }
.bl-emoji { width: 22px; text-align: center; }

/* ---------- charts ---------- */
.viz-card {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px 16px 16px; min-width: 0;
}
.viz-head { display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.viz-head h3 { margin: 0; font-size: 16px; font-weight: 900; }
.viz-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.viz-head > div:first-child { flex: 1 1 240px; }
.viz-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.viz-toggle {
  border: 2px solid var(--ink); border-radius: 10px; background: var(--cream); padding: 4px 10px; font-size: 13px; font-weight: 800;
}
.viz-toggle[aria-pressed='true'] { background: var(--ink); color: #fff; }
.viz-modes { display: inline-flex; background: var(--cream-2); border: 2px solid var(--ink); border-radius: 10px; padding: 2px; gap: 2px; }
.viz-modes button { border: 0; background: none; border-radius: 7px; padding: 4px 10px; font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.viz-modes button.on { background: #fff; color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.viz-body { min-width: 0; }
.viz-svg { width: 100%; border-radius: 8px; }
.viz-svg:focus-visible { outline-offset: 4px; }
svg.viz { display: block; overflow: visible; font-family: var(--font); }
.viz-grid { stroke: #e7e7e7; stroke-width: 1; shape-rendering: crispEdges; }
.viz-base { stroke: #c2c2c2; stroke-width: 1; shape-rendering: crispEdges; }
.viz-tick { fill: #666; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.viz-hover { fill: rgba(42, 31, 61, 0.06); }

.viz-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 10px 0 0; font-size: 13px; color: #444; font-weight: 700; }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.viz-swatch.line { width: 14px; height: 2px; border-radius: 1px; }

.viz-tip {
  position: fixed; z-index: 80; pointer-events: none; opacity: 0; transition: opacity 0.1s;
  background: #fff; color: #191919; border: 2px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow-sm);
  padding: 8px 10px; font-size: 13px; min-width: 140px; max-width: 280px;
}
.viz-tip.show { opacity: 1; }
.viz-tip-title { color: #666; font-weight: 800; margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.viz-tip-row b { font-variant-numeric: tabular-nums; font-weight: 900; }
.viz-tip-row span:last-child { color: #666; font-weight: 600; }
.viz-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.viz-key.none { background: transparent; }

/* tall segmented bar: one whole split into parts */
.viz-seg { display: flex; gap: 2px; height: 28px; }
.viz-seg-part {
  min-width: 2px; border-radius: 4px; display: flex; align-items: center; padding: 0 8px; overflow: hidden; white-space: nowrap;
  font-size: 12px; font-weight: 800; flex-basis: 0;
}
.viz-seg-part:hover, .viz-seg-part:focus-visible { filter: brightness(1.08); }
.viz-seg-empty { flex: 1; border-radius: 4px; background: #efefef; color: #666; font-size: 12px; display: flex; align-items: center; padding: 0 10px; }

/* ranked bars */
.viz-barlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.viz-barlist li { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.viz-bl-label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.viz-bl-label > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-bl-track { height: 12px; }
.viz-bl-bar { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.viz-bl-value { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; font-variant-numeric: tabular-nums; }
.viz-bl-value span { font-size: 11px; color: var(--muted); font-weight: 600; }

/* table view */
.viz-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-height: 420px; overflow-y: auto; }
.viz-table-wrap.players { max-height: none; background: #fff; border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.viz-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.viz-table th, .viz-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid #e7e7e7; white-space: nowrap; }
.viz-table th { position: sticky; top: 0; background: #fff; color: #666; font-weight: 800; z-index: 1; }
.viz-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.viz-table.clickable tbody tr { cursor: pointer; }
.viz-table.clickable tbody tr:hover, .viz-table.clickable tbody tr:focus-visible { background: var(--cream); outline: none; }
@media (max-width: 520px) {
  .dash-hero-value { font-size: 48px; }
  .viz-card { padding: 12px; }
}

/* One-turn trail encounters, using the regular chat reply cards. */
.quest-card { display: grid; gap: 12px; font-size: 16px; }
.quest-card p { margin: 0; }
.quest-card .options { display: grid; gap: 8px; }
.quest-card .opt-body { display: grid; gap: 4px; }
.quest-card small { font-size: 14px; }
.quest-prize { color: var(--purple, #6135a2); font-weight: 700; }
.quest-form { display: grid; gap: 10px; }
.quest-form .chat-input { width: 100%; box-sizing: border-box; }
.quest-feedback { min-height: 24px; font-weight: 600; }
/* Live comments fall over the world without intercepting game gestures. */
.gchat-controls { position: absolute; right: 12px; bottom: calc(12px + var(--safe-bottom)); z-index: 8; display: flex; gap: 8px; align-items: center; }
.gchat-controls .icon-btn, .gchat-controls .gchat-fab { position: relative; inset: auto; width: 44px; height: 44px; border: 2px solid var(--ink); background: var(--paper); border-radius: 50%; box-shadow: var(--shadow-sm); display: grid; place-items: center; }
.gchat-controls button[aria-pressed='false'] { background: var(--cream-2); }
.gchat-quick-picker { position: absolute; right: 0; bottom: 56px; display: flex; gap: 3px; padding: 8px; background: var(--paper); border: 2px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-sm); }
.gchat-quick-picker button { background: none; border: none; font-size: 24px; min-width: 38px; min-height: 44px; padding: 0; }
.gchat-effects { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; container-type: size; }
.gchat-drop { position: absolute; top: -110px; left: var(--lane); animation: live-chat-fall 6s linear forwards; will-change: transform, opacity; }
.gchat-drop.comment { max-width: min(250px, 70%); padding: 7px 12px; background: rgba(255,255,255,.92); color: var(--ink); border: 2px solid var(--ink); border-radius: 16px 16px 16px 4px; font-size: 13px; overflow-wrap: anywhere; box-shadow: 0 3px 12px #0002; }
.gchat-drop.emoji { font-size: 38px; filter: drop-shadow(0 3px 3px #0003); }
@keyframes live-chat-fall { 0% { transform: translateY(0); opacity: 0; } 8%, 80% { opacity: 1; } 100% { transform: translate(var(--sway), calc(100dvh + 160px)); transform: translate(var(--sway), calc(100cqh + 160px)); opacity: 0; } }
.live-game-shell { position: relative; height: 100%; min-height: 0; }
.live-game-shell .chat-view { width: 100%; }
@media (min-width: 900px) {
  .gchat-controls .gchat-fab { display: none; }
  .live-game-shell { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; max-width: 1440px; margin: auto; padding: 16px; }
  .live-game-shell .chat-view { height: 100%; margin: 0; max-width: none; }
  .live-game-shell > .gchat { grid-area: auto; margin: 0; }
}
@media (max-width: 899px) {
  .gchat:not(.open) { visibility: hidden; }
  .gchat.open { bottom: max(8px, var(--safe-bottom)); }
  .gchat-controls { gap: 6px; }
}
/* Immersive mode keeps live chat and its controls over the game. */
body.game-immersive #sky { display: none; }
.immersive { position: fixed !important; inset: 0; width: 100% !important; height: 100dvh !important; max-width: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; background: var(--sky-bottom); z-index: 30; }
.mountain-view.immersive { display: flex; }
.mountain-view.immersive > .hud, .mountain-view.immersive > .play-bar, .immersive .board, .immersive .story-book-btn, .immersive .game-banner { display: none; }
.mountain-view.immersive .mountain-main { display: flex; flex: 1; min-height: 0; }
.mountain-view.immersive .mountain-center { flex: 1; }
.mountain-view.immersive .mountain-stage { width: min(100%, calc(100dvh * .6667)); }
.live-game-shell.immersive { display: block; }
.live-game-shell.immersive .chat-view { height: 100%; max-width: none; margin: 0; border: 0; border-radius: 0; }
.live-game-shell.immersive .chat-head, .live-game-shell.immersive .chat-composer, .live-game-shell.immersive .tip-banner, .live-game-shell.immersive .past-banner, .live-game-shell.immersive .trail-hud { display: none; }
.immersive .gchat { position: absolute; left: auto; right: 8px; bottom: max(8px, var(--safe-bottom)); width: min(360px, calc(100% - 16px)); height: min(70dvh, 560px); margin: 0; z-index: 21; visibility: hidden; transform: translateY(115%); }
.immersive .gchat.open { visibility: visible; transform: none; }
.immersive .gchat-controls .gchat-fab { display: grid; }
.immersive .gchat-head .only-mobile { display: inline-flex; }
@media (prefers-reduced-motion: reduce) {
  .gchat-drop { top: 16px; animation: live-chat-fade 4s linear forwards; will-change: opacity; }
  @keyframes live-chat-fade { 0%, 100% { opacity: 0; } 15%, 85% { opacity: 1; } }
}
.live-game-shell.immersive .composer, .live-game-shell.immersive .race-strip { display: none; }
.chat-stage > .gchat-controls { top: 10px; left: 10px; right: auto; bottom: auto; }
.chat-stage .gchat-quick-picker { top: 56px; left: 0; right: auto; bottom: auto; }
.chat-view.scenic .tn-top { top: 64px; }
.tn-play .tn-label { display: inline; }
.tn-play { flex-shrink: 0; }
.mountain-center { position: relative; }

/* Foreground players stand in a warm spotlight, with a matching chat halo. */
.avatar-online { border-radius: 50%; background: #fff3bb; box-shadow: 0 0 0 2px #f4ca59, 0 0 16px #f4ca59b3; }
.climber.online::before { content: ''; position: absolute; pointer-events: none; width: 90px; height: 150px; bottom: 12px; left: 50%; transform: translateX(-50%); clip-path: polygon(42% 0,58% 0,100% 100%,0 100%); background: linear-gradient(transparent, #ffe58d88); }
.climber.online .climber-sprite { filter: drop-shadow(0 0 7px #ffe58d); }
.gchat-typing { min-height: 28px; padding: 4px 12px; font-style: italic; }
.go-loot { flex-wrap: wrap; }
/* A pursuer stays in peripheral view so turning the FPV camera never hides the chase. */
.yeti-chase { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.yeti-chase[hidden] { display: none; }
.yeti-status { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); width: min(440px, 85%); padding: 12px 16px; border: 2px solid #b8e4ff; border-radius: 16px; background: #19304fee; color: white; text-align: center; font-weight: 700; box-shadow: 0 4px 24px #17233b55; }
.yeti-beast { position: absolute; bottom: 8%; right: 3%; width: clamp(95px, 20vw, 190px); transform-origin: bottom right; filter: drop-shadow(0 6px 6px #19304f66); transition: transform 100ms linear; }
.yeti-beast svg { display: block; width: 100%; animation: yeti-run 240ms steps(2) infinite; }
@keyframes yeti-run { 50% { transform: translateY(-7px) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .yeti-beast { transition: none; } .yeti-beast svg { animation: none; } }
/* The Department of Necessary Inconvenience. */
.zus-panel { max-width: 560px; overflow-x: hidden; background: #f4eddd; color: #30283b; }
.zus-card { text-align: center; }
.zus-kicker { display: block; font-size: .64rem; letter-spacing: .14em; color: #8d3744; font-weight: 800; margin-bottom: 12px; }
.zus-card .modal-title { color: #792d3c; }
.zus-stage { height: 205px; position: relative; overflow: hidden; border-radius: 12px; background: linear-gradient(#dad5cf, #f8f2e7 65%); margin: 12px 0; isolation: isolate; }
.zus-cloud { position: absolute; width: 90%; height: 90px; border-radius: 50%; left: 5%; top: -30px; background: #aaa5a2; box-shadow: -40px 10px 0 #c0bab4, 45px 20px 0 #c0bab4; animation: zus-cloud 2s both; }
.zus-man { position: absolute; bottom: 0; left: calc(50% - 85px); width: 170px; height: 205px; animation: zus-arrive 1.8s both; z-index: 1; }
.zus-man svg { width: 100%; height: 100%; }
.zus-paper { position: absolute; top: -50px; width: 23px; height: 32px; border: 1px solid #b5a99b; background: #fffdf6; color: #a38e80; box-shadow: 1px 3px 4px #30283b33; font-size: 9px; line-height: 28px; animation: zus-paper 2.8s var(--delay) both; z-index: 2; }
.zus-body p { margin: 12px 0; }
.zus-quote { font-style: italic; color: #7d5963; }
.zus-body > small, .zus-bracket small { display: block; color: #6d6271; }
.zus-vibration { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 14px 0 0; font-size: .8rem; }
.zus-counter { font-variant-numeric: tabular-nums; font-weight: 800; }
.zus-body progress { width: 100%; height: 18px; accent-color: #9c384c; }
.zus-tap { display: flex; align-items: center; justify-content: center; flex-direction: column; width: 100%; min-height: 125px; margin-top: 12px; border: 4px solid #562332; border-radius: 18px; color: #fff7da; background: #a33e52; box-shadow: 0 7px 0 #562332; font: inherit; font-size: 2.7rem; font-weight: 900; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.zus-tap small { font-size: .8rem; }
.zus-tap:active { transform: translateY(5px); box-shadow: 0 2px 0 #562332; }
.zus-tap:disabled { opacity: .6; }
.duelling .zus-walk { animation: zus-shuffle .13s infinite alternate; transform-origin: 50% 90%; }
.zus-brackets { display: grid; gap: 10px; text-align: left; margin: 16px 0; }
.zus-bracket { display: grid; gap: 5px; padding: 14px; text-align: left; font: inherit; background: #fffaf0; color: #30283b; border: 2px dashed #b49b89; border-radius: 8px; cursor: pointer; }
.zus-bracket:hover, .zus-bracket:focus-visible { background: #ffe5ad; border-color: #792d3c; }
.zus-bracket span { font-size: .8rem; font-weight: 700; }
.zus-feedback { color: #96263f; }
.zus-feedback button { margin: 8px; }
.departing .zus-man { animation: zus-depart 4.7s linear both; }
.departing .zus-walk { animation: zus-shuffle .5s infinite alternate; transform-origin: 50% 90%; }
@keyframes zus-paper { 0% { transform: translateY(-30px) rotate(0deg); } 100% { transform: translate(var(--drift), 300px) rotate(var(--spin)); } }
@keyframes zus-cloud { 0% { opacity: 0; transform: scale(.2); } 35% { opacity: 1; } 100% { opacity: 0; transform: scale(1.7); } }
@keyframes zus-arrive { 0% { transform: translateY(-200px) rotate(-12deg); opacity: 0; } 60% { transform: translateY(5px) rotate(3deg); opacity: 1; } 80% { transform: translateY(-8px); } 100% { transform: translateY(0); } }
@keyframes zus-shuffle { from { transform: rotate(-2deg) translateY(0); } to { transform: rotate(2deg) translateY(-3px); } }
@keyframes zus-depart { from { transform: translateX(0); } to { transform: translateX(440px); } }
@media (prefers-reduced-motion: reduce) {
  .zus-man, .zus-walk, .zus-paper, .zus-cloud, .departing .zus-man, .departing .zus-walk { animation: none; }
  .zus-paper, .zus-cloud { display: none; }
  .departing .zus-man { opacity: 0; }
}

/* =========================================================
   Mail (#/admin/mail): Gmail-style inbox, automations, editor
   ========================================================= */
.toast.has-action { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.toast-action { flex: none; border: 2px solid var(--ink); border-radius: 9px; background: var(--ink); color: #fff; font-weight: 900; padding: 5px 12px; }
.notif-link { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.notif-link:hover { filter: brightness(0.98); }
.notif-open { float: right; font-weight: 800; color: var(--blue-d); }
.mail-btn.has-mail { animation: mail-wiggle 2.4s ease-in-out infinite; }
@keyframes mail-wiggle { 0%, 88%, 100% { transform: none; } 91% { transform: rotate(-10deg); } 94% { transform: rotate(9deg); } 97% { transform: rotate(-5deg); } }
@media (prefers-reduced-motion: reduce) { .mail-btn.has-mail { animation: none; } }

.mail-view { max-width: 1400px; }
.mail-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.mail-rail { display: flex; flex-direction: column; gap: 10px; padding: 14px 10px 14px 12px; overflow-y: auto; border-right: 1px solid #e6dcc6; }
.rail-compose { justify-content: flex-start; padding: 12px 16px; border-radius: 16px; }
.rail-list { display: flex; flex-direction: column; gap: 2px; }
.rail-item { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 8px 14px; border-radius: 999px; font: inherit; font-weight: 700; color: var(--ink-soft); text-align: left; cursor: pointer; }
.rail-item:hover { background: #f4ead3; }
.rail-item.on { background: #ffe0d6; color: var(--ink); font-weight: 900; }
.rail-item.bold .rail-label, .rail-item.bold .rail-count { font-weight: 900; color: var(--ink); }
.rail-icon { width: 22px; text-align: center; }
.rail-label { flex: 1; }
.rail-count { font-size: 12px; font-weight: 800; }
.rail-status { margin-top: auto; display: grid; gap: 6px; text-align: left; font: inherit; font-size: 12px; font-weight: 700; color: var(--ink-soft); background: #fffdf6; border: 1px solid #e6dcc6; border-radius: 12px; padding: 10px; cursor: pointer; }
.rail-status:hover { border-color: var(--ink-soft); }
.rail-status span { display: flex; align-items: center; gap: 8px; line-height: 1.3; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #b9b2c4; display: inline-block; }
.dot.on { background: #26a65b; }
.dot.warn { background: #f2a600; }

.mail-main { min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px calc(28px + var(--safe-bottom)); background: #fffdf8; display: flex; flex-direction: column; gap: 12px; }
.mail-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.mail-toolbar.tight { margin-bottom: 8px; }
.mail-title { margin: 0 auto 0 0; font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.mail-title-count { font-size: 13px; font-weight: 800; color: var(--red-d); }
.mail-search { max-width: 340px; }
.mail-lead { margin: -4px 0 0; color: var(--ink-soft); max-width: 70ch; }
.mail-note { margin: 0; padding: 10px 14px; border-radius: 12px; background: #eef4ff; border: 1px solid #cdddf8; font-size: 14px; line-height: 1.45; }
.mail-note.warn { background: #fff3c4; border-color: #f0d77d; }
.mail-note.bad { background: #ffe5e3; border-color: #f4b8b3; }
.icon-btn.small { width: 36px; height: 36px; font-size: 16px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
.btn-go { background: var(--green); color: #fff; text-shadow: 1px 1px 0 var(--green-d); }

/* message list */
.mail-list { background: #fff; border: 1px solid #e6dcc6; border-radius: 14px; overflow: hidden; }
.mail-row { display: flex; align-items: stretch; border-bottom: 1px solid #f0e9da; background: #f8f6f1; }
.mail-row:last-child { border-bottom: 0; }
.mail-row.unread { background: #fff; }
.mail-row:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60, 64, 67, 0.25); position: relative; z-index: 1; }
.mr-star { flex: none; width: 40px; border: 0; background: none; font-size: 18px; color: #b9b2c4; cursor: pointer; }
.mr-star.on { color: #f2a600; }
.mr-main { flex: 1; min-width: 0; display: grid; grid-template-columns: 32px minmax(90px, 190px) minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 9px 14px 9px 2px; border: 0; background: none; font: inherit; text-align: left; color: var(--ink-soft); cursor: pointer; }
.mr-main.sent { padding-left: 14px; }
.mail-row.unread .mr-from, .mail-row.unread .mr-subject { color: var(--ink); font-weight: 900; }
.mr-from { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-from small { color: var(--muted); font-weight: 700; }
.mr-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-subject { font-weight: 700; color: var(--ink-soft); }
.mr-snippet { color: var(--muted); font-weight: 600; }
.mr-flags { margin-left: 8px; }
.mr-time { font-size: 13px; font-weight: 700; white-space: nowrap; text-align: right; min-width: 52px; }
.mail-row.unread .mr-time { color: var(--ink); font-weight: 900; }
.mr-chip { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 6px; background: #f1ecff; color: #4b3a99; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.mr-chip.reply { background: #e5f6ea; color: #1f6b3a; }
.mr-chip.test { background: #fff3c4; color: #7a5a00; }
.mr-chip.system { background: #eceaf0; color: var(--ink-soft); }
.mc-avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; }
.mc-initial { display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 900; line-height: 1; }
.flag { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 800; padding: 1px 6px; border-radius: 6px; margin-right: 4px; background: #eef4ff; color: var(--blue-d); white-space: nowrap; }
.flag.ok { background: #e5f6ea; color: #1f6b3a; }
.flag.good { background: #ffe9c2; color: #7a4a00; }
.flag.bad { background: #ffe5e3; color: var(--red-d); }
.flag.muted { background: #eceaf0; color: var(--ink-soft); }
.mail-empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 56px 20px; color: var(--ink-soft); max-width: 46ch; margin: 0 auto; }
.mail-empty-art { font-size: 52px; }
.center-block { margin-left: auto; margin-right: auto; display: block; }

/* one conversation */
.mt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.mt-subject { margin: 0; font-size: 22px; font-weight: 800; }
.mt-grid { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.mt-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mt-messages { display: flex; flex-direction: column; gap: 10px; }
.mt-msg { background: #fff; border: 1px solid #e6dcc6; border-radius: 14px; overflow: hidden; }
.mt-msg-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border: 0; background: none; font: inherit; color: inherit; text-align: left; }
button.mt-msg-head { cursor: pointer; }
button.mt-msg-head:hover { background: #fbf7ee; }
.mt-who { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.mt-flags { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.mt-time { font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.mt-sent.collapsed .mt-body { display: none; }
.mt-body { padding: 0 16px 16px; }
.mt-text { padding: 0 16px 16px 64px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: 15px; }
.mt-dots { margin: -8px 0 12px 64px; border: 1px solid #d9d2c2; background: #f4f0e6; border-radius: 6px; padding: 0 8px; font-weight: 900; letter-spacing: 1px; color: var(--muted); cursor: pointer; }
.mt-quoted { padding: 0 16px 14px 64px; white-space: pre-wrap; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.mt-missing { margin: 0 16px 16px 64px; padding: 10px 12px; border-radius: 10px; background: #fff3c4; font-size: 14px; }
.mt-files { margin: 0 16px 12px 64px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.mt-files li { background: #f4f0e6; border-radius: 8px; padding: 4px 8px; }
.mt-in > .btn-link { margin: 0 0 8px 58px; }
.mt-html { padding: 0 16px 16px; }
.mt-reply { background: #fbfdff; border-color: #d6e4ff; }
.mt-compose { background: #fff; border: 1px solid #d6cdb8; border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; box-shadow: 0 1px 3px rgba(42, 31, 61, 0.08); }
.mt-compose:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43, 110, 228, 0.15); }
.mt-compose-head { font-size: 14px; }
.mt-textarea { width: 100%; min-height: 96px; resize: none; border: 0; outline: none; font: inherit; font-size: 15px; line-height: 1.55; background: transparent; }
.mt-compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt-person { position: sticky; top: 0; background: #fff; border: 1px solid #e6dcc6; border-radius: 14px; padding: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 14px; }
.mt-person h3 { margin: 0 0 6px; font-size: 15px; }
.mt-person-name { font-size: 17px; margin-top: 6px; }
.mt-person-mail { color: var(--muted); overflow-wrap: anywhere; }
.mt-person dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 6px; }
.mt-person dt { color: var(--muted); font-weight: 700; }
.mt-person dd { margin: 0; font-weight: 800; overflow-wrap: anywhere; }
.mt-device { overflow-x: auto; }
.send-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.mail-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; width: 100%; }
.mail-timeline li { display: grid; grid-template-columns: 22px 1fr; gap: 2px 8px; font-weight: 700; }
.mail-timeline time, .mail-timeline code { grid-column: 2; font-size: 12px; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.mail-activity { list-style: none; margin: 0; padding: 0; display: grid; }
.mail-activity button { display: flex; align-items: baseline; gap: 8px; width: 100%; border: 0; border-bottom: 1px solid #f0e9da; background: none; padding: 7px 2px; font: inherit; font-size: 14px; text-align: left; color: inherit; cursor: pointer; }
.mail-activity button:hover { background: #fbf7ee; }
.mail-activity span:nth-child(2) { flex: 1; min-width: 0; }
.mail-activity time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* switches and segmented controls */
.switch { position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px; border: 2px solid var(--ink); background: #d9d3e2; padding: 0; cursor: pointer; transition: background 0.15s; }
.switch[aria-checked='true'] { background: var(--green); }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: transform 0.15s; }
.switch[aria-checked='true'] .switch-knob { transform: translateX(20px); }
.seg { display: inline-flex; background: #efe7d4; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 800; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(42, 31, 61, 0.2); }

/* automations list */
.au-list { display: grid; gap: 10px; }
.au-card { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 12px; background: #fff; border: 1px solid #e6dcc6; border-radius: 14px; padding: 12px 16px; }
.au-card.active { border-left: 5px solid var(--green); }
.au-card.paused { border-left: 5px solid #b9b2c4; }
.au-card.draft { border-left: 5px dashed #d9c9a3; }
.au-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.au-status { font-size: 12px; font-weight: 900; color: var(--muted); }
.au-status.active { color: var(--green-d); }
.au-main { border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 4px 0; min-width: 0; }
.au-main h3 { margin: 0 0 2px; font-size: 17px; }
.au-main:hover h3 { text-decoration: underline; }
.au-sentence { margin: 0; color: var(--ink-soft); font-size: 14px; }
.au-subject { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-stats { display: grid; grid-template-columns: repeat(4, 64px); gap: 4px; text-align: center; }
.au-stats b { display: block; font-size: 18px; }
.au-stats span { font-size: 12px; color: var(--muted); font-weight: 700; }
.au-new p { margin: 0 0 10px; }
.au-triggers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.au-trigger { display: grid; gap: 4px; text-align: left; font: inherit; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); padding: 12px; cursor: pointer; box-shadow: var(--shadow-sm); }
.au-trigger:hover { background: #fff8e7; }
.au-trigger span { font-size: 13px; color: var(--ink-soft); }
.modal-panel.wide { max-width: 720px; }

/* the editor */
.me-host { min-width: 0; }
.me { display: flex; flex-direction: column; gap: 12px; }
.me-top { position: sticky; top: -14px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; background: #fffdf8; border-bottom: 1px solid #efe7d4; }
.me-title { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
.me-name { font: inherit; font-size: 20px; font-weight: 900; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; margin-left: -6px; background: transparent; color: var(--ink); min-width: 0; }
.me-name:hover { border-color: #e6dcc6; }
.me-name:focus { outline: none; border-color: var(--blue); background: #fff; }
.me-saved { font-size: 12px; font-weight: 800; color: var(--green-d); padding-left: 1px; }
.me-saved.dirty { color: #a26b00; }
.me-status { display: flex; align-items: center; }
.me-live { display: flex; align-items: center; gap: 8px; font-weight: 900; color: var(--muted); }
.me-live .live { color: var(--green-d); }
.me-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.me-canvas { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.me-canvasbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.me-as { max-width: 280px; }
.me-toolbar { position: sticky; top: 50px; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px; background: #fff; border: 1px solid #e6dcc6; border-radius: 12px; box-shadow: 0 2px 6px rgba(42, 31, 61, 0.08); }
.tb { min-width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 15px; font-weight: 800; color: var(--ink); cursor: pointer; padding: 0 8px; }
.tb:hover { background: #f4ead3; }
.tb.on { background: #ffe0d6; }
.tb-wide { font-size: 13px; }
.tb-sep { width: 1px; height: 22px; background: #e6dcc6; margin: 0 4px; }
.tb-btnicon { display: inline-block; font-size: 11px; padding: 2px 6px; border-radius: 5px; background: var(--red); color: #fff; border: 1.5px solid var(--ink); }
.tb-field { position: relative; }
.tb-menu { position: absolute; top: 38px; left: 0; z-index: 10; display: grid; min-width: 220px; background: #fff; border: 1px solid #d6cdb8; border-radius: 12px; box-shadow: 0 8px 24px rgba(42, 31, 61, 0.18); padding: 6px; }
.tb-menu button { display: flex; justify-content: space-between; gap: 12px; border: 0; background: none; font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.tb-menu button:hover { background: #f4ead3; }
.tb-menu code { color: var(--blue-d); font-size: 12px; }
.me-hold { padding: 10px 14px; border-radius: 12px; background: #fff3c4; border: 1px solid #f0d77d; font-size: 14px; font-weight: 700; }
.me-restore { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #eef4ff; border: 1px solid #cdddf8; font-weight: 700; font-size: 14px; }
.me-restore span { flex: 1; }
.me-stage { min-width: 0; }
.me-side { display: flex; flex-direction: column; gap: 12px; }
.me-card { background: #fff; border: 1px solid #e6dcc6; border-radius: 14px; padding: 14px; display: grid; gap: 10px; }
.me-card h3 { margin: 0; font-size: 15px; }
.me-card-head { display: flex; align-items: center; justify-content: space-between; }
.me-field { display: grid; gap: 4px; font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.me-field .dash-search, .me-field .dash-select { width: 100%; max-width: none; }
.me-num { width: 90px !important; flex: none; }
.me-check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; font-weight: 700; cursor: pointer; }
.me-check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--blue); }
.me-hint { margin: -4px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 600; line-height: 1.45; }
.me-hint.warn { color: #8a5a00; }
.me-hint code, .setup-body code { font-size: 12px; background: #f4f0e6; border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
.me-sentence { margin: 0; padding: 10px 12px; border-radius: 10px; background: #f1ecff; color: #3b2f7a; font-weight: 800; font-size: 14px; line-height: 1.4; }
.me-funnel { display: grid; gap: 6px; }
.me-funnel-row { display: grid; grid-template-columns: 62px 1fr 42px 30px; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.me-funnel-row small { color: var(--muted); text-align: right; }
.me-funnel-row b { text-align: right; }
.me-bar { height: 10px; background: #f1ecdf; border-radius: 5px; overflow: hidden; }
.me-bar i { display: block; height: 100%; background: #257de0; border-radius: 5px; }
.me-failed { font-size: 13px; font-weight: 700; color: var(--red-d); }
.me-recent { list-style: none; margin: 0; padding: 0; display: grid; }
.me-recent-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; width: 100%; border: 0; border-bottom: 1px solid #f0e9da; background: none; padding: 6px 2px; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.me-recent-row:hover { background: #fbf7ee; }
.me-recent-to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.me-recent-time { color: var(--muted); }
.me-danger { grid-template-columns: 1fr 1fr; }
.me-linkform { display: grid; gap: 10px; min-width: min(420px, 80vw); }
.me-linkform .btn-link { justify-self: start; padding-left: 0; }

/* the inbox chrome around an email (desktop window / phone) */
.mc { display: grid; gap: 6px; }
.mc-preview-label { font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.mc-inbox-card { background: #fff; border: 1px solid #e3e3e3; border-radius: 10px; overflow: hidden; font-family: Roboto, -apple-system, 'Segoe UI', Arial, sans-serif; }
.mc-inboxrow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; font-size: 14px; color: #202124; }
.mc-ir-dot { width: 8px; height: 8px; border-radius: 50%; background: #1a73e8; flex: none; }
.mc-ir-from { flex: none; width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.mc-ir-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-ir-subject { font-weight: 700; }
.mc-ir-pre { color: #5f6368; }
.mc-ir-time { flex: none; font-size: 12px; font-weight: 700; }
.mc-window { background: #fff; border: 1px solid #dadce0; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15), 0 4px 14px rgba(60, 64, 67, 0.08); font-family: Roboto, -apple-system, 'Segoe UI', Arial, sans-serif; color: #202124; }
.mc-windowbar { display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: #f6f8fc; border-bottom: 1px solid #e8eaed; }
.mc-dots { display: flex; gap: 6px; }
.mc-dots i { width: 11px; height: 11px; border-radius: 50%; background: #e0e0e0; }
.mc-dots i:nth-child(1) { background: #ff5f57; }
.mc-dots i:nth-child(2) { background: #febc2e; }
.mc-dots i:nth-child(3) { background: #28c840; }
.mc-search { flex: 1; max-width: 420px; background: #eaf1fb; border-radius: 999px; padding: 6px 14px; font-size: 13px; color: #5f6368; }
.mc-open { padding: 16px 20px 12px; }
.mc-subjectrow { display: flex; align-items: center; gap: 10px; margin: 0 0 14px 52px; }
.mc-subject-text, .mc-subject-input { font-size: 22px; font-weight: 400; color: #1f1f1f; }
.mc-subject-input, .mc-pre-input { flex: 1; min-width: 0; font-family: inherit; border: 1px dashed transparent; border-radius: 6px; padding: 2px 6px; margin-left: -7px; background: transparent; }
.mc-subject-input:hover, .mc-pre-input:hover { border-color: #c7d6f5; }
.mc-subject-input:focus, .mc-pre-input:focus { outline: none; border: 1px solid #1a73e8; background: #fff; box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15); }
.mc-label { flex: none; font-size: 12px; background: #ddd; color: #444; border-radius: 4px; padding: 1px 6px; }
.mc-fromrow { display: flex; align-items: flex-start; gap: 12px; }
.mc-fromtext { flex: 1; min-width: 0; font-size: 14px; }
.mc-fromtext b { font-weight: 700; }
.mc-addr { color: #5f6368; font-size: 12px; }
.mc-to { color: #5f6368; font-size: 12px; margin-top: 2px; }
.mc-time { flex: none; color: #5f6368; font-size: 12px; }
.mc-pre-edit { display: flex; align-items: center; gap: 8px; margin: 10px 0 0 52px; padding: 6px 8px; background: #f6f8fc; border-radius: 8px; font-size: 13px; }
.mc-pre-edit > span { flex: none; font-weight: 700; color: #5f6368; }
.mc-pre-input { font-size: 13px; color: #3c4043; }
.mc-body { margin: 14px -20px -12px; }
.email-frame { display: block; width: 100%; height: 420px; border: 0; background: #f3efe6; }
.email-frame.untrusted { height: 480px; background: #fff; border: 1px solid #e6dcc6; border-radius: 10px; }
.mc-phone { justify-items: center; }
.mc-phone .mc-preview-label, .mc-phone .mc-inbox-card { width: 100%; max-width: 405px; }
.mc-phone .mc-inboxrow { flex-wrap: wrap; row-gap: 2px; }
.mc-phone .mc-ir-from { width: auto; flex: 1; }
.mc-phone .mc-ir-text { flex-basis: 100%; order: 3; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mc-device { width: 405px; max-width: 100%; border: 12px solid #1d1b22; border-radius: 46px; background: #fff; overflow: hidden; box-shadow: 0 14px 40px rgba(29, 27, 34, 0.25); font-family: -apple-system, 'SF Pro Text', Roboto, sans-serif; color: #111; }
.mc-status { display: flex; justify-content: space-between; padding: 12px 26px 4px; font-size: 13px; }
.mc-appbar { display: flex; justify-content: space-between; padding: 6px 14px 8px; color: #0a7aff; font-size: 16px; border-bottom: 1px solid #eee; }
.mc-scroll { max-height: 720px; overflow-y: auto; }
.mc-m-subject { padding: 14px 16px 10px; }
.mc-phone .mc-subject-text, .mc-phone .mc-subject-input { font-size: 20px; font-weight: 700; }
.mc-phone .mc-subject-input { width: 100%; margin-left: -7px; }
.mc-phone .mc-fromrow { padding: 0 16px 10px; border-bottom: 1px solid #f0f0f0; }
.mc-phone .mc-pre-edit { margin: 10px 16px 0; }
.mc-phone .mc-body { margin: 0; }

/* setup */
.setup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.setup-step { display: flex; gap: 12px; background: #fff; border: 1px solid #e6dcc6; border-radius: 14px; padding: 14px 16px; }
.setup-step b { display: block; margin-bottom: 4px; }
.setup-mark { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 900; color: #fff; background: #f2a600; }
.setup-step.ok .setup-mark { background: #26a65b; }
.setup-step.opt .setup-mark { background: #b9b2c4; }
.setup-body { font-size: 14px; line-height: 1.5; color: var(--ink-soft); }

@media (max-width: 1100px) {
  .me-grid { grid-template-columns: 1fr; }
  .me-side { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .mt-grid, .send-grid { grid-template-columns: 1fr; }
  .mt-person { position: static; }
}
@media (max-width: 820px) {
  .mail-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .mail-rail { flex-direction: row; align-items: center; overflow-x: auto; border-right: 0; border-bottom: 1px solid #e6dcc6; padding: 8px 10px; gap: 6px; }
  .rail-compose { flex: none; padding: 8px 12px; font-size: 14px; }
  .rail-list { flex-direction: row; }
  .rail-item { flex: none; padding: 7px 12px; }
  .rail-status { display: none; }
  .mail-main { padding: 12px 12px calc(24px + var(--safe-bottom)); }
  .mr-main { grid-template-columns: 32px minmax(0, 1fr) auto; grid-template-areas: 'av from time' 'av text text'; row-gap: 2px; padding-right: 10px; }
  .mr-main > :first-child { grid-area: av; align-self: start; }
  .mr-from { grid-area: from; }
  .mr-text { grid-area: text; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .mr-time { grid-area: time; }
  .mr-chip { display: none; }
  .mt-text, .mt-quoted { padding-left: 16px; }
  .mt-dots, .mt-missing, .mt-files { margin-left: 16px; }
  .mt-in > .btn-link { margin-left: 10px; }
  .au-card { grid-template-columns: 56px minmax(0, 1fr); }
  .au-stats { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); }
  .mc-subjectrow, .mc-pre-edit { margin-left: 0; }
  .mc-open { padding: 12px 12px 10px; }
  .mc-body { margin: 12px -12px -10px; }
  .mc-ir-from { width: 110px; }
  .me-top { top: -12px; }
}
