:root {
  --bg: #ffffff;
  --bg-soft: #f6f5fb;
  --card: #ffffff;
  --border: #e6e4ef;
  --border-strong: #d4d1e0;
  --text: #2b2a35;
  --muted: #7d7a8c;
  --primary: #7c5cff;
  --primary-dark: #5e3fe0;
  --primary-soft: #efeaff;
  --success: #22b35e;
  --success-dark: #178a46;
  --success-soft: #e3f8ea;
  --danger: #f0435a;
  --danger-dark: #c42a3f;
  --danger-soft: #ffe5e9;
  --gold: #ffb020;
  --gold-dark: #e08e00;
  --blue: #2ea8ff;
  --blue-dark: #1488d8;
  --locked: #e3e2ea;
  --locked-dark: #c9c7d3;
  --shadow: 0 2px 0 var(--border);
  --radius: 16px;
  --scrollbar-track: #f2eff9;
  --scrollbar-thumb: #8f74d4;
  --scrollbar-thumb-end: #7051b8;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15141c;
    --bg-soft: #1d1c27;
    --card: #1d1c27;
    --border: #2f2d3d;
    --border-strong: #3c3a4d;
    --text: #eceaf5;
    --muted: #9b98ad;
    --primary: #8f74ff;
    --primary-dark: #6a4ff0;
    --primary-soft: #2a2545;
    --success-soft: #16301f;
    --danger-soft: #3a1820;
    --locked: #2c2b38;
    --locked-dark: #222130;
    --scrollbar-track: #1a1724;
    --scrollbar-thumb: #a18ae8;
    --scrollbar-thumb-end: #7956cc;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Native scrolling with a shared palette for the page, panels and dialogs. */
* { scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); }
html { scrollbar-gutter: stable; }

/* Detailed styling for mouse-driven Chromium/WebKit browsers. Keep native
   overlay sizing on touch screens and system colors in high-contrast mode. */
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
  @supports selector(::-webkit-scrollbar) {
    /* Non-auto standard colors override these pseudo-elements in Chromium. */
    * { scrollbar-color: auto; }
    *::-webkit-scrollbar { width: 12px; height: 12px; }
    *::-webkit-scrollbar-track {
      background: var(--scrollbar-track);
      border-radius: 999px;
      box-shadow: inset 1px 0 0 color-mix(in srgb, var(--border) 65%, transparent);
    }
    *::-webkit-scrollbar-thumb {
      min-height: 48px;
      min-width: 48px;
      border: 2px solid var(--scrollbar-track);
      border-radius: 999px;
      background: linear-gradient(180deg, var(--scrollbar-thumb), var(--scrollbar-thumb-end));
      background-clip: padding-box;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
    }
    *::-webkit-scrollbar-thumb:horizontal {
      background-image: linear-gradient(90deg, var(--scrollbar-thumb), var(--scrollbar-thumb-end));
    }
    *::-webkit-scrollbar-thumb:hover {
      background-image: linear-gradient(180deg, var(--primary), var(--primary-dark));
    }
    *::-webkit-scrollbar-thumb:active { background: var(--primary-dark); background-clip: padding-box; }
    *::-webkit-scrollbar-button { display: none; }
    *::-webkit-scrollbar-corner { background: var(--scrollbar-track); }
    .right-panel::-webkit-scrollbar, .modal::-webkit-scrollbar, textarea::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }
  }
}
@media (forced-colors: active) {
  * { scrollbar-color: auto; }
}

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", "Noto Sans JP", system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1 { font-size: 1.6rem; font-weight: 900; margin: 0.4em 0; }
h2 { font-size: 1.25rem; font-weight: 900; margin: 0.6em 0 0.4em; }
h3 { font-size: 1.05rem; font-weight: 800; margin: 0 0 0.3em; }
p { line-height: 1.45; }
ruby rt { font-size: 0.5em; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.error-text { color: var(--danger); font-weight: 700; }
.danger-text { color: var(--danger) !important; }
.spacer { flex: 1; }
.big-emoji { font-size: 4.5rem; line-height: 1; }
.bounce { animation: bounce 0.9s ease; }
@keyframes bounce {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 22px;
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 0.05s, filter 0.15s;
  position: relative;
}
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.small { padding: 9px 14px; font-size: 0.8rem; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--primary-dark); }
.btn.success { background: var(--success); color: #fff; box-shadow: 0 4px 0 var(--success-dark); }
.btn.danger { background: var(--danger); color: #fff; box-shadow: 0 4px 0 var(--danger-dark); }
.btn.gold { background: var(--gold); color: #fff; box-shadow: 0 4px 0 var(--gold-dark); }
.btn.secondary { background: var(--card); color: var(--primary); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); }
.btn.light { background: #fff; color: var(--c, var(--primary)); box-shadow: 0 4px 0 rgba(0,0,0,0.15); }
.btn.ghost { background: transparent; color: var(--muted); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); }
.btn.price { background: var(--card); color: var(--blue); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); min-width: 96px; }
.btn:disabled { background: var(--locked) !important; color: var(--muted) !important; box-shadow: 0 4px 0 var(--locked-dark) !important; border-color: transparent !important; }
.link { background: none; border: none; color: var(--primary); font-weight: 800; padding: 0; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.04em; }
.link.back { margin: 8px 0; }
.icon-btn { background: none; border: none; font-size: 1.4rem; color: var(--muted); padding: 6px 10px; border-radius: 10px; }
.icon-btn:hover { background: var(--bg-soft); }

/* ---------- splash / auth ---------- */
.splash, .auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.logo-mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 900; font-size: 1.3rem; font-family: "Noto Sans JP", sans-serif;
  box-shadow: 0 3px 0 var(--primary-dark);
}
.logo-mark.big { width: 88px; height: 88px; border-radius: 26px; font-size: 3rem; margin: 0 auto; box-shadow: 0 6px 0 var(--primary-dark); }
.splash .logo-mark { animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-title { font-size: 2.2rem; color: var(--primary); margin: 12px 0 0; letter-spacing: -0.02em; }
.auth form { margin-top: 14px; }
.field {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--border);
  background: var(--bg-soft); color: var(--text); font: inherit; font-weight: 700; margin-bottom: 10px; outline: none;
}
.field:focus { border-color: var(--primary); }
.field.invalid, .field.invalid:focus { border-color: var(--danger); }
.field-hint { margin: -4px 0 10px 4px; font-size: 0.85rem; }
.pw-wrap { position: relative; margin-bottom: 10px; }
.pw-wrap .field { margin-bottom: 0; padding-right: 54px; }
.pw-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 42px; height: 42px; display: grid; place-items: center;
  border: none; background: none; border-radius: 10px; color: var(--muted); cursor: pointer;
}
.pw-eye:hover, .pw-eye:focus-visible { color: var(--primary); }
.pw-eye:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pw-wrap .field::-ms-reveal { display: none; }
.field-label { display: block; font-weight: 800; color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.inline { display: flex; gap: 10px; align-items: flex-start; }
.inline .field { margin: 0; }
.seg { display: flex; background: var(--bg-soft); border: 2px solid var(--border); border-radius: 14px; padding: 4px; margin: 16px 0; }
.seg-btn { flex: 1; border: none; background: none; padding: 10px; border-radius: 10px; font-weight: 900; color: var(--muted); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.04em; }
.seg-btn.active { background: var(--card); color: var(--primary); box-shadow: 0 2px 0 var(--border); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.sidebar { display: none; }
.right-panel { display: none; }
.content { min-width: 0; padding-bottom: 90px; }
.page { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; gap: 6px;
  padding: 10px 16px; background: var(--bg); border-bottom: 2px solid var(--border); max-width: 100%;
}
.stat { background: none; border: none; font-weight: 900; font-size: 1.05rem; padding: 6px 10px; border-radius: 12px; color: var(--muted); white-space: nowrap; }
.stat:hover { background: var(--bg-soft); }
.stat.flag { font-size: 1.5rem; padding: 2px 8px; }
.stat.streak { filter: grayscale(1); }
.stat.streak.lit { filter: none; color: #ff8a00; }
.stat.gems { color: var(--blue); }
.stat.hearts { color: var(--danger); }
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--bg); border-top: 2px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab { background: none; border: 2px solid transparent; border-radius: 14px; padding: 6px 12px; font-size: 1.5rem; }
.tab.active { background: var(--primary-soft); border-color: var(--primary); }
.nav-icon { display: inline-grid; place-items: center; width: 34px; font-family: "Noto Sans JP", sans-serif; font-weight: 700; }

@media (min-width: 760px) {
  .shell { grid-template-columns: 230px minmax(0, 1fr); }
  .bottom-nav { display: none; }
  .content { padding-bottom: 32px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
    padding: 20px 14px; border-right: 2px solid var(--border);
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 22px; cursor: pointer; }
  .brand-name { font-size: 1.7rem; font-weight: 900; color: var(--primary); letter-spacing: -0.03em; }
  .nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px;
    border: 2px solid transparent; background: none; font-weight: 900; text-transform: uppercase;
    font-size: 0.85rem; letter-spacing: 0.05em; color: var(--muted); text-align: left;
  }
  .nav-item .nav-icon { font-size: 1.4rem; }
  .nav-item:hover { background: var(--bg-soft); }
  .nav-item.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
  .topbar { border-bottom: none; justify-content: flex-end; gap: 14px; }
}
@media (min-width: 1150px) {
  .shell { grid-template-columns: 250px minmax(0, 1fr) 360px; }
  .shell:not(:has(.right-panel)) { grid-template-columns: 250px minmax(0, 1fr); }
  .right-panel { display: flex; flex-direction: column; gap: 16px; padding: 24px 24px 24px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}

/* ---------- cards ---------- */
.card { background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.card-head h3 { margin: 0; }
.pbar { height: 14px; background: var(--locked); border-radius: 99px; overflow: hidden; flex: 1; }
.pbar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; position: relative; min-width: 0; }
.pbar-fill::after { content: ""; position: absolute; left: 8px; right: 8px; top: 3px; height: 3px; background: rgba(255,255,255,0.35); border-radius: 9px; }
.mini-quest { display: flex; gap: 12px; align-items: center; margin: 12px 0; }
.mq-icon { font-size: 1.6rem; }
.mq-body { flex: 1; }
.mq-title { font-weight: 800; margin-bottom: 6px; font-size: 0.95rem; }
.league-mini { display: flex; gap: 14px; align-items: center; cursor: pointer; }
.league-mini p { margin: 0; }
.boost-note { margin: 10px 0 0; font-weight: 800; color: var(--gold-dark); }
.banner { background: var(--primary-soft); color: var(--primary); border-radius: 14px; padding: 12px 16px; font-weight: 800; margin: 12px 0; text-align: center; }

/* ---------- learn path ---------- */
.learn { padding-top: 12px; }
.unit { margin-bottom: 26px; }
.unit-banner {
  background: var(--c); color: #fff; border-radius: var(--radius); padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 70%, black);
  position: sticky; top: 64px; z-index: 10;
}
.unit-banner h2 { margin: 2px 0; font-size: 1.3rem; }
.unit-banner p { margin: 0; opacity: 0.92; font-weight: 700; }
.unit-label { text-transform: uppercase; font-weight: 900; font-size: 0.8rem; opacity: 0.85; letter-spacing: 0.06em; }
.guide-btn {
  border: 2px solid rgba(255,255,255,0.45); background: rgba(255,255,255,0.12); color: #fff; border-radius: 14px;
  padding: 10px 14px; font-weight: 900; display: flex; gap: 8px; align-items: center; text-transform: uppercase; font-size: 0.8rem;
}
.guide-btn span { display: none; }
@media (min-width: 520px) { .guide-btn span { display: inline; } }
.path { display: flex; flex-direction: column; align-items: center; padding: 56px 0 10px; gap: 18px; }
.node-wrap { position: relative; display: flex; flex-direction: column; align-items: center; z-index: 1; }
.node-wrap:has(.node-pop) { z-index: 16; }
.node {
  width: 74px; height: 70px; border-radius: 50%; border: none; display: grid; place-items: center;
  background: var(--c); color: #fff; font-size: 1.9rem; font-weight: 900;
  box-shadow: 0 8px 0 color-mix(in srgb, var(--c) 68%, black);
  transition: transform 0.08s;
}
.node:active { transform: translateY(5px); box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 68%, black); }
.node.locked { background: var(--locked); color: var(--muted); box-shadow: 0 8px 0 var(--locked-dark); font-size: 1.4rem; }
.node.done { background: var(--c); }
.node.done .node-icon { font-size: 2rem; }
.node.active { outline: 6px solid color-mix(in srgb, var(--c) 25%, transparent); outline-offset: 6px; }
.node.chest { border-radius: 22px; background: transparent; box-shadow: none; font-size: 3rem; }
.node.chest.locked { filter: grayscale(1) opacity(0.55); }
.node.chest.active { animation: wiggle 1.6s infinite; outline: none; }
.node.review { width: 84px; height: 78px; font-size: 2.1rem; }
.node.review.locked { filter: grayscale(0.4); }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-8deg); } 90% { transform: rotate(8deg); } 95% { transform: rotate(-4deg); } }
.start-bubble {
  position: absolute; top: -40px; background: var(--card); color: var(--c); border: 2px solid var(--border);
  padding: 6px 12px; border-radius: 12px; font-weight: 900; font-size: 0.85rem; letter-spacing: 0.05em;
  animation: float 1.5s infinite ease-in-out; white-space: nowrap; z-index: 2;
}
.start-bubble::after {
  content: ""; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 12px; height: 12px; background: var(--card); border-right: 2px solid var(--border); border-bottom: 2px solid var(--border);
}
@keyframes float { 50% { transform: translateY(-5px); } }
.node-pop {
  position: absolute; top: 88px; z-index: 15; width: 280px; background: var(--c); color: #fff; padding: 16px;
  border-radius: 16px; box-shadow: 0 6px 20px rgba(0,0,0,0.15); animation: pop 0.15s ease-out;
}
/* Keep the popover centered in the path when the zigzag reaches a phone edge.
   The separate translate property preserves the pop animation's scale. */
@media (max-width: 540px) {
  .node-pop {
    width: min(280px, calc(100vw - 64px));
    translate: calc(-1 * var(--node-offset, 0px)) 0;
  }
}
.node-pop.locked { background: var(--bg-soft); color: var(--muted); border: 2px solid var(--border); }
.node-pop h4 { margin: 0 0 4px; font-size: 1.1rem; font-weight: 900; }
.node-pop p { margin: 0; font-weight: 700; opacity: 0.92; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
.jump-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 22px; }
.jump-line { flex: 1; height: 2px; background: var(--border); }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 12, 30, 0.55); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); border-radius: 20px; padding: 24px; width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; animation: pop 0.18s ease-out; }
.notice { text-align: center; }
.notice-icon { font-size: 3.6rem; }
.notice p { color: var(--muted); font-weight: 700; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 200; background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 14px; font-weight: 800; box-shadow: 0 6px 20px rgba(0,0,0,0.2); max-width: calc(100% - 32px);
  animation: pop 0.2s;
}
.toast.error { background: var(--danger); color: #fff; }
.guidebook h2 { margin-top: 2px; }
.guidebook .unit-label { color: var(--primary); }
.guide-entry { border-top: 2px solid var(--border); padding: 14px 0; }
.guide-entry p { margin: 4px 0 10px; }
.guide-ex { display: flex; gap: 10px; align-items: center; background: var(--bg-soft); border-radius: 12px; padding: 10px 12px; margin: 6px 0; }
.guide-ex-a { font-weight: 800; font-size: 1.1rem; }

/* ---------- player ---------- */
.player { min-height: 100vh; display: flex; flex-direction: column; }
.player-top { display: flex; align-items: center; gap: 14px; padding: 18px 16px; max-width: 1000px; width: 100%; margin: 0 auto; }
.player-progress { flex: 1; position: relative; display: flex; align-items: center; }
.player-progress .pbar { height: 16px; }
.combo { position: absolute; top: -18px; left: 0; font-weight: 900; color: #ff8a00; font-size: 0.8rem; animation: pop 0.2s; }
.player-hearts { font-weight: 900; color: var(--danger); font-size: 1.1rem; white-space: nowrap; }
.player-body { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 8px 16px 160px; }
.ex-title { font-size: 1.55rem; margin: 10px 0 18px; }
.prompt { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 22px; }
.mascot {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 20px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 2rem; font-family: "Noto Sans JP", sans-serif; font-weight: 700;
  box-shadow: 0 4px 0 var(--primary-dark);
}
.bubble {
  position: relative; border: 2px solid var(--border); border-radius: 16px; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.25rem; font-weight: 700;
}
.bubble::before {
  content: ""; position: absolute; left: -9px; bottom: 16px; width: 14px; height: 14px; background: var(--bg);
  border-left: 2px solid var(--border); border-bottom: 2px solid var(--border); transform: rotate(45deg);
}
.prompt-text { line-height: 1.9; }
.speaker {
  border: none; background: var(--blue); color: #fff; border-radius: 12px; width: 40px; height: 40px;
  font-size: 1.1rem; box-shadow: 0 3px 0 var(--blue-dark); flex-shrink: 0;
}
.speaker.slow { background: var(--card); color: var(--blue); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); }
.speaker.big { width: 120px; height: 110px; border-radius: 22px; font-size: 3rem; box-shadow: 0 6px 0 var(--blue-dark); }
.speaker.big.slow { width: 80px; height: 80px; font-size: 2rem; box-shadow: 0 5px 0 var(--border); }
.speaker:active { transform: translateY(2px); }
.listen-buttons { display: flex; gap: 18px; align-items: flex-end; justify-content: center; margin: 10px 0 28px; }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choices.grid { display: grid; grid-template-columns: repeat(2, 1fr); }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card);
  border: 2px solid var(--border); border-radius: 14px; padding: 14px 16px; font-weight: 700; font-size: 1.1rem;
  box-shadow: 0 3px 0 var(--border); transition: transform 0.05s;
}
.choices.grid .choice { justify-content: center; font-size: 1.6rem; padding: 22px 10px; position: relative; }
.choices.grid .choice .key { position: absolute; left: 10px; top: 10px; }
.choice:hover { background: var(--bg-soft); }
.choice:active { transform: translateY(2px); }
.choice .key {
  border: 2px solid var(--border); border-radius: 8px; min-width: 28px; height: 28px; display: inline-grid;
  place-items: center; font-size: 0.8rem; color: var(--muted); font-weight: 800;
}
.choice.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 3px 0 var(--primary); }
.choice.selected .key { border-color: var(--primary); color: var(--primary); }
.choice.correct { border-color: var(--success); background: var(--success-soft); color: var(--success); box-shadow: 0 3px 0 var(--success); }
.choice.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); box-shadow: 0 3px 0 var(--danger); animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.choice-text { line-height: 1.7; }

.cloze-sentence { font-size: 1.35rem; font-weight: 700; line-height: 2.2; margin: 10px 0 24px; }
.blank { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--border-strong); text-align: center; padding: 0 6px; }
.blank.filled { color: var(--primary); border-color: var(--primary); }

.answer-line {
  min-height: 116px; border-top: 2px solid var(--border); border-bottom: 2px solid var(--border);
  background-image: linear-gradient(transparent 56px, var(--border) 56px, var(--border) 58px, transparent 58px);
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 8px 0; margin-bottom: 26px;
}
.bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile {
  background: var(--card); border: 2px solid var(--border); border-radius: 12px; padding: 9px 14px;
  font-weight: 700; font-size: 1.1rem; box-shadow: 0 3px 0 var(--border); line-height: 1.6;
}
.answer-line.ja .tile, .tile ruby { font-family: "Noto Sans JP", "Nunito", sans-serif; }
.tile.used { background: var(--locked); color: transparent; box-shadow: none; border-color: var(--locked); pointer-events: none; }
.tile.used rt { color: transparent; }
.tile:active { transform: translateY(2px); }

.type-input {
  width: 100%; border: 2px solid var(--border); border-radius: 16px; background: var(--bg-soft); color: var(--text);
  padding: 14px 16px; font: inherit; font-size: 1.15rem; font-weight: 700; resize: none; outline: none;
}
.type-input:focus { border-color: var(--primary); }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.tile.match { width: 100%; min-height: 58px; font-size: 1.05rem; }
.tile.match.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 3px 0 var(--primary); }
.tile.match.done { opacity: 0.35; box-shadow: none; pointer-events: none; border-color: var(--success); color: var(--success); }
.tile.match.bad { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); animation: shake 0.3s; }

.mic-btn {
  width: 100%; margin-top: 10px; border: 2px solid var(--border); border-radius: 16px; background: var(--card);
  padding: 22px; font-weight: 900; font-size: 1.05rem; color: var(--blue); box-shadow: 0 4px 0 var(--border);
  display: flex; gap: 12px; justify-content: center; align-items: center; text-transform: uppercase; letter-spacing: 0.04em;
}
.mic-btn.listening { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--card)); }
.mic-btn.listening .mic-icon { animation: pulse 0.8s infinite; }
.mic-icon { font-size: 1.6rem; }
.heard { text-align: center; font-weight: 700; color: var(--muted); }
.heard.live { color: var(--text); font-size: 1.1rem; opacity: .85; animation: heard-pulse 1.2s ease-in-out infinite; }
@keyframes heard-pulse { 50% { opacity: .55; } }
.heard.good { color: var(--green, #58cc02); display: flex; gap: 6px; align-items: center; justify-content: center; }
.heard.retry { color: #ff9600; }

.player-foot { position: fixed; bottom: 0; left: 0; right: 0; border-top: 2px solid var(--border); background: var(--bg); z-index: 40; }
.player-foot.good { background: var(--success-soft); border-color: transparent; }
.player-foot.bad { background: var(--danger-soft); border-color: transparent; }
.foot-inner { max-width: 1000px; margin: 0 auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.foot-inner .btn.primary, .foot-inner .btn.success, .foot-inner .btn.danger { min-width: 150px; }
@media (max-width: 560px) {
  .foot-inner .btn.primary, .foot-inner .btn.success, .foot-inner .btn.danger { width: 100%; }
  .foot-inner .btn.ghost { order: 2; width: 100%; }
  .foot-inner .spacer { display: none; }
}
.verdict { display: flex; gap: 14px; align-items: center; min-width: 0; flex: 1 1 260px; }
.verdict-icon {
  width: 58px; height: 58px; border-radius: 50%; background: var(--card); display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 900; flex-shrink: 0;
}
.good .verdict-icon, .good h3 { color: var(--success); }
.bad .verdict-icon, .bad h3 { color: var(--danger); }
.verdict-text h3 { font-size: 1.35rem; margin: 0; }
.verdict-text p { margin: 2px 0; }
.solution { font-weight: 800; font-size: 1.05rem; color: var(--danger); line-height: 1.8; }
.good .solution { color: var(--success); }
.note { color: var(--muted); font-weight: 700; font-size: 0.92rem; }

.loading { min-height: 50vh; display: grid; place-items: center; }
.spinner { width: 42px; height: 42px; border: 5px solid var(--locked); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.session-error, .results { min-height: 100vh; max-width: 480px; margin: 0 auto; padding: 32px 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.results h1 { font-size: 2rem; color: var(--gold-dark); }
.perfect { font-weight: 900; color: var(--success); margin: 0; }
.result-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin: 16px 0; }
.result-card { border-radius: 16px; border: 2px solid var(--rc); background: var(--rc); overflow: hidden; }
.result-card.gold { --rc: var(--gold); }
.result-card.green { --rc: var(--success); }
.result-card.blue { --rc: var(--blue); }
.rc-label { color: #fff; font-weight: 900; font-size: 0.75rem; text-transform: uppercase; padding: 6px; letter-spacing: 0.05em; }
.rc-value { background: var(--card); color: var(--rc); font-weight: 900; font-size: 1.2rem; padding: 14px 4px; border-radius: 14px 14px 0 0; }
.breakdown { list-style: none; padding: 0; width: 100%; margin: 0 0 8px; }
.breakdown li { display: flex; justify-content: space-between; padding: 8px 4px; border-bottom: 1px dashed var(--border); font-weight: 700; color: var(--muted); }
.breakdown b { color: var(--text); }
.streak-banner { display: flex; gap: 14px; align-items: center; background: color-mix(in srgb, #ff8a00 14%, var(--card)); border-radius: 16px; padding: 12px 18px; width: 100%; text-align: left; }
.streak-banner p { margin: 0; color: var(--muted); font-weight: 700; }
.streak-banner b { color: #ff8a00; font-size: 1.15rem; }
.streak-flame { font-size: 2.4rem; animation: bounce 0.9s; }
.goal-banner { background: color-mix(in srgb, var(--gold) 18%, var(--card)); color: var(--gold-dark); font-weight: 900; border-radius: 14px; padding: 12px; width: 100%; }

/* ---------- courses ---------- */
.courses { padding: 16px 0; }
.courses.first { max-width: 720px; margin: 0 auto; padding: 48px 16px; }
.courses.first h1 { text-align: center; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.course-card { text-align: left; background: var(--card); border: 2px solid var(--border); border-radius: 18px; padding: 18px; box-shadow: 0 4px 0 var(--border); display: flex; flex-direction: column; gap: 4px; }
.course-card:hover { background: var(--bg-soft); }
.course-card.current { border-color: var(--primary); box-shadow: 0 4px 0 var(--primary); }
.course-card p { margin: 0 0 6px; font-weight: 600; }
.course-flag { font-size: 2.8rem; }
.course-meta { display: flex; justify-content: space-between; font-weight: 800; color: var(--muted); font-size: 0.85rem; }
.course-cta { margin-top: 8px; color: var(--primary); font-weight: 900; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; }

/* ---------- practice / words / characters / stories ---------- */
.practice-grid { display: grid; gap: 12px; margin-top: 16px; }
.practice-card { display: flex; gap: 16px; align-items: center; text-align: left; background: var(--card); border: 2px solid var(--border); border-radius: 18px; padding: 16px 18px; box-shadow: 0 4px 0 var(--border); }
.practice-card:hover { background: var(--bg-soft); }
.practice-card.featured { background: var(--primary); color: #fff; border-color: var(--primary-dark); box-shadow: 0 4px 0 var(--primary-dark); }
.practice-card.featured p { color: rgba(255,255,255,0.9); }
.practice-card p { margin: 0; color: var(--muted); font-weight: 600; }
.practice-card h3 { margin: 0; }
.pc-icon { font-size: 2.2rem; width: 48px; text-align: center; }
.pc-icon.jp { font-family: "Noto Sans JP", sans-serif; font-weight: 700; color: var(--primary); }
.word-list { display: flex; flex-direction: column; }
.word-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 2px solid var(--border); }
.words-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 12px 0 4px; }
.lt-typed { margin-top: 12px; }
.lt-essay { margin-top: 12px; min-height: 180px; resize: vertical; font: inherit; line-height: 1.6; }
.words-search { flex: 1 1 100%; min-width: 160px; margin-bottom: 0; }
.words-sort { display: flex; flex-direction: column; gap: 4px; }
.words-sort:not(.words-flash-toggle) { flex: 1 1 210px; min-width: 0; }
.words-sort .kselect { margin-bottom: 10px; }
.words-flash-toggle { flex-direction: row; align-items: center; gap: 8px; padding-bottom: 8px; }
.word-main { flex: 1; min-width: 0; }
.word-text { font-weight: 800; font-size: 1.15rem; line-height: 1.8; }
.strength { display: flex; gap: 3px; align-items: flex-end; }
.sbar { width: 6px; background: var(--locked); border-radius: 3px; }
.sbar:nth-child(1) { height: 8px; } .sbar:nth-child(2) { height: 12px; } .sbar:nth-child(3) { height: 16px; } .sbar:nth-child(4) { height: 20px; }
.sbar.on { background: var(--gold); }
.empty { text-align: center; color: var(--muted); font-weight: 700; padding: 40px 0; }
.characters h1, .characters > p { text-align: center; }
.kana-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 18px; }
.kana-cell { background: var(--card); border: 2px solid var(--border); border-radius: 14px; padding: 10px 4px 8px; box-shadow: 0 3px 0 var(--border); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.kana-cell:hover { background: var(--bg-soft); }
.kana-cell.empty { visibility: hidden; }
.kana-char { font-family: "Noto Sans JP", sans-serif; font-size: 1.6rem; font-weight: 700; }
.kana-romaji { color: var(--muted); font-weight: 800; font-size: 0.8rem; }
.kana-bar { width: 70%; height: 6px; border-radius: 9px; background: var(--locked); overflow: hidden; margin-top: 4px; }
.kana-bar span { display: block; height: 100%; background: var(--gold); }
.kana-section { margin-top: 26px; text-align: center; }
.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 16px; }
.story-card { background: var(--card); border: 2px solid var(--border); border-radius: 18px; padding: 16px; box-shadow: 0 4px 0 var(--border); text-align: center; }
.story-card p { margin: 4px 0 0; font-weight: 700; font-size: 0.85rem; }
.story-card.locked { opacity: 0.6; }
.story-card.done .story-cover { box-shadow: 0 0 0 4px var(--gold); }
.story-cover { width: 92px; height: 92px; margin: 0 auto 10px; border-radius: 24px; background: var(--primary-soft); display: grid; place-items: center; font-size: 3rem; }
.story-cover.big { width: 120px; height: 120px; font-size: 4rem; }
.story-head { text-align: center; margin-bottom: 18px; }
.story-line { margin: 14px 0; animation: pop 0.2s ease-out; }
.story-line.narrator .line-text { font-style: italic; }
.story-line .speaker-name { font-weight: 900; color: var(--primary); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.line-body { display: flex; gap: 12px; align-items: flex-start; }
.line-text { font-size: 1.2rem; font-weight: 700; line-height: 1.9; cursor: pointer; border-bottom: 2px dashed var(--border); }
.translation { color: var(--muted); font-weight: 700; margin-top: 4px; }
.story-q { border: 2px solid var(--border); border-radius: 16px; padding: 16px; margin: 18px 0; display: flex; flex-direction: column; gap: 8px; animation: pop 0.2s ease-out; }

/* ---------- leagues ---------- */
.tiers { display: flex; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.tier { opacity: 0.45; }
.tier.passed { opacity: 0.85; }
.tier.current { opacity: 1; transform: scale(1.4); margin: 0 10px; }
.league-timer { font-weight: 800; color: var(--gold-dark); }
.league-list { margin-top: 12px; }
.league-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; }
.league-row.me { background: var(--primary-soft); }
.league-row .rank { width: 30px; text-align: center; font-weight: 900; color: var(--muted); }
.league-row.promote .rank { color: var(--success); }
.league-row.demote .rank { color: var(--danger); }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; flex-shrink: 0; }
.lname { flex: 1; font-weight: 800; }
.lxp { font-weight: 800; color: var(--muted); }
.zone-divider { text-align: center; font-weight: 900; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 0; border-top: 2px dashed; border-bottom: 2px dashed; margin: 6px 0; }
.zone-divider.up { color: var(--success); border-color: var(--success-soft); }
.zone-divider.down { color: var(--danger); border-color: var(--danger-soft); }

/* ---------- quests / shop ---------- */
.quest-hero { background: linear-gradient(135deg, var(--primary), #b05cff); color: #fff; border-radius: 20px; padding: 22px; display: flex; justify-content: space-between; align-items: center; margin: 16px 0; gap: 12px; }
.quest-hero h1 { margin: 0; }
.quest-hero p { margin: 4px 0 0; font-weight: 700; opacity: 0.92; }
.shop-hero { background: linear-gradient(135deg, var(--blue), #4f7cff); }
.hero-icon { font-size: 3.4rem; }
.quest { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 2px solid var(--border); }
.quest:last-child { border-bottom: none; }
.quest-icon { font-size: 2rem; }
.quest-body { flex: 1; }
.quest-title { font-weight: 800; margin-bottom: 6px; }
.quest-progress { display: flex; gap: 10px; align-items: center; }
.reward { font-weight: 900; color: var(--blue); white-space: nowrap; }
.claimed { font-weight: 900; color: var(--success); white-space: nowrap; }
.shop-item { display: flex; gap: 16px; align-items: center; padding: 18px 0; border-bottom: 2px solid var(--border); }
.shop-icon { font-size: 2.8rem; width: 64px; text-align: center; }
.shop-body { flex: 1; }
.shop-body p { margin: 2px 0; font-weight: 600; }
.shop-body .status { font-weight: 800; color: var(--primary); }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; padding: 18px 0; border-bottom: 2px solid var(--border); }
.profile-head h1 { margin: 0; }
.profile-head p { margin: 2px 0; font-weight: 700; }
.profile-head .gear { margin-left: auto; align-self: flex-start; }
.big-avatar { width: 84px; height: 84px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 2.4rem; font-weight: 900; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 4px 0 var(--primary-dark); }
.flags { font-size: 1.4rem; display: flex; gap: 6px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-box { border: 2px solid var(--border); border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.stat-box b { display: block; font-size: 1.15rem; font-weight: 900; }
.stat-box span:not(.sb-icon) { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.sb-icon { font-size: 1.6rem; display: grid; place-items: center; }
.two-col { display: grid; gap: 0 16px; }
.xp-chart { width: 100%; height: auto; }
.xp-chart .bar { fill: color-mix(in srgb, var(--gold) 55%, var(--locked)); }
.xp-chart .bar.today { fill: var(--gold); }
.xp-chart .bar-label { fill: var(--muted); font-size: 12px; font-weight: 800; }
.xp-chart .bar-value { fill: var(--text); font-size: 11px; font-weight: 800; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: 420px; margin: 0 auto; gap: 5px; text-align: center; }
.cal-head { color: var(--muted); font-weight: 900; font-size: 0.75rem; }
.cal-day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-weight: 800; font-size: 0.85rem; color: var(--muted); }
.cal-day.on { background: #ff8a00; color: #fff; }
.cal-day.frozen { background: #5ad1f5; color: #fff; }
.cal-day.today { outline: 2px solid var(--primary); }
.ach { display: flex; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 2px solid var(--border); }
.ach:last-child { border-bottom: none; }
.ach-badge { width: 64px; height: 72px; border-radius: 14px; background: linear-gradient(160deg, var(--gold), #ff7a59); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; box-shadow: 0 4px 0 var(--gold-dark); }
.ach-badge span { font-size: 1.9rem; }
.ach-badge small { font-weight: 900; font-size: 0.7rem; }
.ach.locked .ach-badge { background: var(--locked); box-shadow: 0 4px 0 var(--locked-dark); filter: grayscale(1); }
.ach-body { flex: 1; }
.ach-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.ach-body p { margin: 6px 0 0; }

/* ---------- settings ---------- */
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 2px solid var(--border); cursor: pointer; }
.toggle-row:last-child { border-bottom: none; }
.toggle-row p { margin: 2px 0 0; }
.switch { appearance: none; width: 52px; height: 30px; border-radius: 99px; background: var(--locked); position: relative; cursor: pointer; flex-shrink: 0; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.switch:checked { background: var(--primary); }
.switch:checked::after { left: 25px; }
.goal-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.goal-opt { border: 2px solid var(--border); background: var(--card); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 3px 0 var(--border); }
.goal-opt span { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.goal-opt.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 3px 0 var(--primary); }

/* =====================================================================
   Playful layer: icons, Koto the mascot, the cast, and celebrations
   ===================================================================== */

/* ---------- icons ---------- */
.ic { display: inline-block; vertical-align: middle; flex-shrink: 0; overflow: visible; }
.emoji { display: inline-block; line-height: 1; vertical-align: middle; }
.btn .ic { margin-top: -3px; }
.btn:hover:not(:disabled) { filter: brightness(1.06); }

/* ---------- Koto ---------- */
.koto { display: block; overflow: visible; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.koto { transition: transform 0.25s cubic-bezier(.3, 1.4, .5, 1); }
.koto:hover { transform: translateY(-3px) scale(1.04) rotate(-1deg); }
.koto:active { transform: translateY(1px) scale(0.96); }
/* Taps focus Koto too; only keyboard focus should draw a ring. */
.koto:focus { outline: none; }
.koto:focus-visible { outline: 3px solid var(--primary); outline-offset: 6px; border-radius: 22px; }
.koto .k-body, .koto .k-eyes, .koto .k-tail, .koto .k-ear, .koto .k-scarf-tail, .koto .k-shadow, .koto .k-arm,
.koto .k-mouth, .koto .k-tear, .koto .sp, .koto .k-dots circle, .koto .k-zzz path, .koto .k-pupils, .koto .kh,
.koto .k-pose, .koto .k-ear-in, .koto .k-tail-wrap, .koto .k-lid, .koto .k-nose, .koto .k-question, .koto .k-sweat,
.koto .k-joy, .koto .k-pop-heart, .koto .k-spark, .koto .k-zoom, .koto .k-yawn-act, .koto .k-brows, .koto .k-face,
.koto .k-flame, .koto .k-blush { transform-box: fill-box; }
.koto .k-body { transform-origin: 50% 100%; animation: k-breathe 3.2s ease-in-out infinite; }
.koto .k-eyes { transform-origin: 50% 50%; animation: k-blink 4.6s infinite; }
.koto .k-tail { transform-origin: 0% 100%; animation: k-wag 1.8s ease-in-out infinite; }
.koto .k-ear-l, .koto .k-ear-l .k-ear-in { transform-origin: 85% 100%; }
.koto .k-ear-r, .koto .k-ear-r .k-ear-in { transform-origin: 15% 100%; }
.koto .k-scarf-tail { transform-origin: 0% 0%; animation: k-flutter 1.3s ease-in-out infinite; }
.koto .k-shadow { transform-origin: 50% 50%; }
.koto .k-cheek { transform-origin: 50% 50%; animation: k-cheek 3.2s ease-in-out infinite; }
@keyframes k-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025, 0.975); } }
@keyframes k-cheek { 0%, 100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.15); opacity: .9; } }
@keyframes k-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@keyframes k-wag { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(10deg); } }
@keyframes k-flutter { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(14deg); } }

.koto.k-happy .k-body { animation: k-hop 0.75s ease-in-out infinite; }
.koto.k-happy .k-shadow { animation: k-shadow 0.75s ease-in-out infinite; }
.koto.k-happy .k-tail { animation-duration: 0.5s; }
@keyframes k-hop {
  0%, 100% { transform: translateY(0) scale(1.04, 0.96); }
  40% { transform: translateY(-9px) scale(0.97, 1.04); }
  70% { transform: translateY(0) scale(1.05, 0.95); }
}
.koto.k-cheer .k-body { animation: k-jump 0.85s cubic-bezier(.3, 0, .4, 1) infinite; }
.koto.k-cheer .k-shadow { animation: k-shadow 0.85s cubic-bezier(.3, 0, .4, 1) infinite; }
.koto.k-cheer .k-tail { animation-duration: 0.45s; }
@keyframes k-jump {
  0%, 100% { transform: translateY(0) scale(1.06, 0.94); }
  45% { transform: translateY(-16px) scale(0.96, 1.05); }
  80% { transform: translateY(0) scale(1.05, 0.95); }
}
@keyframes k-shadow { 40%, 45% { transform: scale(0.72); opacity: 0.06; } }
.koto.k-cheer .k-arm-l { transform-origin: 100% 100%; animation: k-arm-l 0.42s ease-in-out infinite alternate; }
.koto.k-cheer .k-arm-r { transform-origin: 0% 100%; animation: k-arm-r 0.42s ease-in-out infinite alternate; }
@keyframes k-arm-l { from { transform: rotate(6deg); } to { transform: rotate(-16deg); } }
@keyframes k-arm-r { from { transform: rotate(-6deg); } to { transform: rotate(16deg); } }
.koto .k-sparkles .sp { transform-origin: 50% 50%; animation: k-twinkle 1.2s ease-in-out infinite; }
.koto .k-sparkles .sp2 { animation-delay: 0.3s; }
.koto .k-sparkles .sp3 { animation-delay: 0.6s; }
.koto .k-sparkles .sp4 { animation-delay: 0.9s; }
@keyframes k-twinkle { 0%, 100% { transform: scale(0.35) rotate(0); opacity: 0.3; } 50% { transform: scale(1.15) rotate(45deg); opacity: 1; } }

.koto.k-wave .k-wave { transform-origin: 0% 100%; animation: k-waving 0.45s ease-in-out infinite alternate; }
@keyframes k-waving { from { transform: rotate(-14deg); } to { transform: rotate(20deg); } }

.koto.k-sad .k-body { animation: k-sway 3s ease-in-out infinite; }
.koto.k-sad .k-ear-l { animation: none; transform: rotate(-22deg); }
.koto.k-sad .k-ear-r { animation: none; transform: rotate(22deg); }
.koto.k-sad .k-tail { animation: k-droop 3.6s ease-in-out infinite; }
.koto .k-tear { transform-origin: 50% 0; animation: k-tear 1.8s ease-in infinite; }
@keyframes k-sway { 50% { transform: rotate(-2.5deg) translateY(2px); } }
@keyframes k-droop { 0%, 100% { transform: rotate(18deg); } 50% { transform: rotate(24deg); } }
@keyframes k-tear {
  0% { transform: translateY(-4px) scale(0.5); opacity: 0; }
  25% { opacity: 1; transform: translateY(0) scale(1); }
  100% { transform: translateY(18px) scale(0.9); opacity: 0; }
}

/* Emotional reactions have their own body language, rather than a celebration. */
.koto.k-heartbroken .k-body {
  transform: translateY(4px) scale(1.02, .97);
  animation: k-sad-arrive 1.1s ease-out both, k-sigh 4.6s 1.1s ease-in-out infinite;
}
.koto.k-heartbroken:hover { transform: scale(1.015); }
.koto .k-exhale, .koto .k-yawn { transform-box: fill-box; transform-origin: 50% 50%; }
.koto.k-heartbroken .k-ear-l { animation: none; transform: rotate(-30deg); }
.koto.k-heartbroken .k-ear-r { animation: none; transform: rotate(30deg); }
.koto.k-heartbroken .k-tail { animation: k-droop 4.6s ease-in-out infinite; }
.koto.k-heartbroken .k-scarf-tail { animation: none; transform: rotate(6deg); }
.koto.k-heartbroken .k-cheek { animation: none; opacity: .42; }
.koto.k-heartbroken .k-eyes { animation: k-blink 6.8s infinite; }
.koto.k-heartbroken .k-tear { animation: k-tear 2.3s .6s 3 both; }
.koto.k-heartbroken .k-tear-right { animation-delay: 1.5s; }
.koto.k-heartbroken .k-wipe { transform-origin: 85% 100%; animation: k-wipe 4.6s 1.3s 2; }
.koto.k-heartbroken .k-mouth { animation: k-lip-quiver 1.2s 1s 3; }
.koto.k-heartbroken .k-shadow { transform: scaleX(1.08); opacity: .1; }
@keyframes k-sad-arrive {
  from { transform: translateY(-2px) scale(1); }
  to { transform: translateY(4px) scale(1.02, .97); }
}
@keyframes k-sigh {
  0%, 100% { transform: translateY(4px) scale(1.02, .97); }
  35% { transform: translateY(1px) scale(1, 1.01); }
  65% { transform: translateY(5px) scale(1.03, .96); }
}
@keyframes k-wipe {
  0%, 30%, 100% { transform: rotate(0); }
  42%, 62% { transform: rotate(-12deg) translate(-2px, -2px); }
  52% { transform: rotate(-5deg) translate(1px, -1px); }
}
@keyframes k-lip-quiver { 40% { transform: translateX(-.5px); } 60% { transform: translateX(.5px); } }
.koto.k-relieved .k-body { animation: k-exhale-body 4.2s ease-in-out infinite; }
.koto.k-relieved .k-ear-l { animation: none; transform: rotate(-9deg); }
.koto.k-relieved .k-ear-r { animation: none; transform: rotate(9deg); }
.koto.k-relieved .k-tail { animation: k-wag 3.4s ease-in-out infinite; }
.koto.k-relieved .k-exhale { animation: k-exhale 4.2s ease-out infinite; }
.koto.k-relieved .k-reassure { transform-origin: 100% 100%; animation: k-paw-pat 4.2s ease-in-out infinite; }
@keyframes k-exhale-body {
  0%, 100% { transform: translateY(1px) scale(1.01, .99); }
  28% { transform: translateY(-2px) scale(.99, 1.025); }
  62% { transform: translateY(3px) scale(1.025, .98); }
}
@keyframes k-exhale {
  0%, 30%, 100% { opacity: 0; transform: translateX(-3px) scale(.85); }
  45% { opacity: .8; }
  78% { opacity: 0; transform: translateX(7px) scale(1.1); }
}
.koto.k-encourage .k-body { animation: k-support-nod 3.6s ease-in-out infinite; }
.koto.k-encourage .k-tail { animation-duration: 2.8s; }
.koto.k-encourage .k-reassure { transform-origin: 100% 100%; animation: k-paw-pat 3.6s ease-in-out infinite; }
.koto .k-comfort-heart { transform-box: fill-box; transform-origin: center; animation: k-heart-float 3.6s ease-in-out infinite; }
@keyframes k-support-nod {
  0%, 30%, 100% { transform: rotate(0) translateY(0); }
  45% { transform: rotate(2deg) translateY(3px); }
  60% { transform: rotate(-1deg) translateY(-1px); }
}
@keyframes k-paw-pat { 35%, 65% { transform: translateY(0); } 45%, 58% { transform: translateY(-2px); } }
.koto.k-tired .k-body { transform: translateY(3px); animation: k-tired-breathe 5s ease-in-out infinite; }
.koto.k-tired .k-ear-l { animation: none; transform: rotate(-20deg); }
.koto.k-tired .k-ear-r { animation: none; transform: rotate(20deg); }
.koto.k-tired .k-eyes { animation: none; }
.koto.k-tired .k-tail { animation: k-droop 5s ease-in-out infinite; }
.koto.k-tired .k-yawn { transform-origin: center; animation: k-yawn 5s ease-in-out infinite; }
.koto.k-tired .k-scarf-tail { animation: none; }
@keyframes k-tired-breathe { 0%, 100% { transform: translateY(3px) scale(1.02, .98); } 40% { transform: translateY(1px) scale(1, 1.02); } }
@keyframes k-yawn { 0%, 70%, 100% { transform: scale(.7); } 35% { transform: scale(1.15); } }
.koto.k-think .k-body { animation: k-tilt 2.6s ease-in-out infinite; }
@keyframes k-tilt { 50% { transform: rotate(4deg); } }
.koto .k-dots circle { animation: k-dot 1.4s infinite; }
.koto .k-dots circle:nth-child(2) { animation-delay: 0.2s; }
.koto .k-dots circle:nth-child(3) { animation-delay: 0.4s; }
@keyframes k-dot { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
.koto.k-sleep .k-body { animation: k-breathe 4s ease-in-out infinite; }
.koto.k-sleep .k-eyes, .koto.k-sleep .k-ear-l, .koto.k-sleep .k-ear-r { animation: none; }
.koto.k-sleep .k-tail { animation-duration: 4s; }
.koto .k-zzz path { animation: k-zzz 2.4s infinite; opacity: 0; }
.koto .k-zzz path:nth-child(2) { animation-delay: 0.8s; }
@keyframes k-zzz { 0% { opacity: 0; transform: translate(0, 6px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(8px, -10px); } }
.koto.k-wow .k-body { animation: k-wowpop 0.9s cubic-bezier(.3, 1.6, .5, 1) infinite alternate; }
@keyframes k-wowpop { from { transform: scale(1); } to { transform: scale(1.06, 0.95) translateY(-4px); } }
.koto.k-love .k-body { animation: k-hop 0.75s ease-in-out infinite; }
.koto.k-love .k-eyes { animation: k-love-blink 1.8s ease-in-out infinite; }
.koto.k-love .k-tail { animation-duration: 0.4s; }
.koto.k-proud .k-body { animation: k-proud 2.4s ease-in-out infinite; }
.koto.k-proud .k-tail { animation-duration: 0.8s; }
@keyframes k-love-blink { 0%, 88%, 100% { transform: scale(1); } 94% { transform: scale(0.92, 1.06); } }
@keyframes k-proud {
  0%, 100% { transform: rotate(-2deg) scale(1.02, 0.98) translateY(2px); }
  50% { transform: rotate(2deg) scale(1.04, 1.0) translateY(-5px); }
}
.koto .k-hearts .kh { transform-origin: 50% 50%; animation: k-heart-float 2s ease-in-out infinite; }
.koto .k-hearts .kh2 { animation-delay: 0.6s; }
@keyframes k-heart-float { 0%, 100% { transform: translateY(0) scale(.9); opacity: .85; } 50% { transform: translateY(-5px) scale(1.15); opacity: 1; } }

.koto.booped { animation: k-boop 0.5s ease-out; }
@keyframes k-boop {
  0% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.16, 0.84) rotate(-4deg); }
  50% { transform: scale(0.9, 1.12) rotate(3deg); }
  75% { transform: scale(1.05, 0.97) rotate(-1deg); }
  100% { transform: scale(1) rotate(0); }
}
.koto.hop { animation: float 1.6s ease-in-out infinite; }
.koto.hop.booped { animation: k-boop 0.5s ease-out; }
/* ---------- Koto: life layer (see mascot.rs) ---------- */
/* Eyelids stay hidden until a blink; some moods rest them part-way down. */
.koto .k-lid { transform-origin: 50% 0%; transform: scaleY(var(--lid, 0)); transition: transform .08s ease-in; }
.koto[data-blink] .k-lid { transform: scaleY(1); transition-duration: .05s; }
.koto .k-eyes.has-lids { animation: none; }
.koto.k-sad { --lid: .34; }
.koto.k-encourage { --lid: .14; }
.koto.k-determined { --lid: .3; }
.koto.k-oops { --lid: .12; }
.koto .k-ear-in { transition: transform .35s ease; }
.koto .k-pose { transform-origin: 50% 100%; }

/* One-off idle actions, layered over the mood's own loop. */
.koto[data-act="tilt"] .k-pose { animation: k-act-tilt 1.5s cubic-bezier(.4, 0, .3, 1); }
.koto[data-act="tilt"] .k-ear-l .k-ear-in { animation: k-act-ear-l 1.5s ease-out; }
@keyframes k-act-tilt { 0%, 100% { transform: rotate(0); } 25%, 70% { transform: rotate(-7deg) translateX(-1px); } }
.koto[data-act="hop"] .k-pose { animation: k-act-hop .7s cubic-bezier(.3, 0, .4, 1); }
.koto[data-act="hop"] .k-shadow { animation: k-act-shadow .7s cubic-bezier(.3, 0, .4, 1); }
@keyframes k-act-hop {
  0%, 100% { transform: translateY(0) scale(1); }
  15% { transform: translateY(0) scale(1.08, .9); }
  45% { transform: translateY(-12px) scale(.95, 1.07); }
  75% { transform: translateY(0) scale(1.06, .94); }
}
@keyframes k-act-shadow { 45% { transform: scale(.7); opacity: .06; } }
.koto[data-act="stretch"] .k-pose { animation: k-act-stretch 1.7s ease-in-out; }
.koto[data-act="stretch"] .k-lid { transform: scaleY(.92); transition-duration: .3s; }
@keyframes k-act-stretch {
  0%, 100% { transform: scale(1); }
  20% { transform: scale(1.04, .95); }
  50%, 65% { transform: scale(.95, 1.09); }
}
.koto[data-act="nod"] .k-pose { animation: k-act-nod 2.2s ease-in-out; }
@keyframes k-act-nod {
  0%, 100% { transform: rotate(0) translateY(0); }
  40%, 60% { transform: rotate(5deg) translateY(4px); }
  72% { transform: rotate(-1deg) translateY(-1px); }
}
.koto[data-act="ears"] .k-ear-l .k-ear-in { animation: k-act-ear-l .7s ease-out; }
.koto[data-act="ears"] .k-ear-r .k-ear-in { animation: k-act-ear-r .7s .08s ease-out; }
@keyframes k-act-ear-l { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-16deg); } 45% { transform: rotate(5deg); } 70% { transform: rotate(-3deg); } }
@keyframes k-act-ear-r { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(16deg); } 45% { transform: rotate(-5deg); } 70% { transform: rotate(3deg); } }
.koto[data-act="wag"] .k-tail-wrap { transform-origin: 0% 100%; animation: k-act-wag 1.1s ease-in-out; }
@keyframes k-act-wag { 0%, 100% { transform: rotate(0); } 15%, 45%, 75% { transform: rotate(14deg); } 30%, 60%, 90% { transform: rotate(-10deg); } }
.koto[data-act="sniff"] .k-nose { transform-origin: 50% 50%; animation: k-act-sniff .9s ease-in-out; }
.koto[data-act="sniff"] .k-pose { animation: k-act-sniff-head .9s ease-in-out; }
@keyframes k-act-sniff { 0%, 100% { transform: scale(1); } 15%, 45%, 75% { transform: scale(1.18, .86) translateY(-.6px); } 30%, 60% { transform: scale(.95, 1.05); } }
@keyframes k-act-sniff-head { 30%, 60% { transform: translateY(-1.5px) rotate(-1deg); } }
.koto[data-act="yawn"] .k-pose { animation: k-act-stretch 1.9s ease-in-out; }
.koto[data-act="yawn"] .k-lid { transform: scaleY(.7); transition-duration: .4s; }
.koto[data-act="yawn"] .k-yawn-act { transform-origin: 50% 30%; animation: k-act-yawn 1.9s ease-in-out; }
.koto[data-act="yawn"] .k-mouth { animation: k-act-hide 1.9s; }
@keyframes k-act-yawn {
  0%, 100% { opacity: 0; transform: scale(.4); }
  20% { opacity: 1; transform: scale(.8); }
  45%, 60% { opacity: 1; transform: scale(1.35, 1.5); }
  85% { opacity: 1; transform: scale(.6); }
}
@keyframes k-act-hide { 0%, 100% { opacity: 1; } 15%, 85% { opacity: 0; } }

/* Ears perk up when the pointer comes close. */
.koto[data-near] .k-ear-l .k-ear-in { transform: rotate(7deg); transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.koto[data-near] .k-ear-r .k-ear-in { transform: rotate(-7deg); transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }

/* A squash-and-stretch pop whenever the mood changes. */
.koto[data-react] .k-pose { animation: k-react .56s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes k-react {
  0% { transform: scale(.88, 1.1) translateY(2px); }
  40% { transform: scale(1.08, .93); }
  70% { transform: scale(.98, 1.03); }
  100% { transform: scale(1); }
}

/* Hearts pop out on a boop. */
.koto .k-pop { pointer-events: none; }
.koto.booped .k-pop { animation: k-pop-show .9s ease-out; }
.koto.booped .k-pop-heart { transform-origin: 50% 100%; animation: k-pop-heart .9s cubic-bezier(.2, .9, .3, 1) both; }
.koto .kp1 { --hx: -9px; }
.koto .kp2 { --hx: 0px; animation-delay: .06s !important; }
.koto .kp3 { --hx: 9px; animation-delay: .12s !important; }
@keyframes k-pop-show { 0%, 100% { opacity: 0; } 10%, 70% { opacity: 1; } }
@keyframes k-pop-heart {
  0% { transform: translate(0, 10px) scale(.2); }
  50% { transform: translate(var(--hx), -6px) scale(1.15); }
  100% { transform: translate(calc(var(--hx) * 1.5), -16px) scale(.8); }
}

/* Laugh: a giggling shake with tears of joy. */
.koto.k-laugh .k-body { transform-origin: 50% 100%; animation: k-laugh .3s ease-in-out infinite alternate; }
.koto.k-laugh .k-tail { animation-duration: .45s; }
.koto.k-laugh .k-belly { animation: k-belly .3s ease-in-out infinite alternate; }
.koto.k-laugh .k-ear-l { transform: rotate(-6deg); }
.koto.k-laugh .k-ear-r { transform: rotate(6deg); }
@keyframes k-laugh { from { transform: rotate(-2.5deg) scale(1.01, .99); } to { transform: rotate(2.5deg) translateY(-2px) scale(.99, 1.02); } }
@keyframes k-belly { to { transform: translateY(-1.5px); } }
.koto .k-joy { transform-origin: 50% 0; animation: k-joy 1.4s ease-in infinite; --jx: -6px; }
.koto .k-joy-r { animation-delay: .5s; --jx: 6px; }
@keyframes k-joy {
  0% { opacity: 0; transform: translate(0, -2px) scale(.4); }
  30% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translate(var(--jx), 10px) scale(.7); }
}

/* Oops: a sheepish sway, a paw scratching the head and a sweat drop. */
.koto.k-oops .k-body { animation: k-sheepish 2.8s ease-in-out infinite; }
.koto.k-oops .k-scratch { transform-origin: 20% 100%; animation: k-scratch .45s ease-in-out infinite alternate; }
.koto.k-oops .k-ear-l { transform: rotate(-14deg); }
.koto.k-oops .k-ear-r { transform: rotate(10deg); }
.koto.k-oops .k-tail { animation-duration: 2.6s; }
.koto .k-sweat { transform-origin: 50% 0; animation: k-sweat 2.2s ease-in infinite; }
/* The streak-worry ladder: worried, then panicked, then desperate as midnight nears. */
.koto.k-worried { --lid: .1; }
.koto.k-worried .k-body { animation: k-sway 3.4s ease-in-out infinite; }
.koto.k-worried .k-ear-l { animation: none; transform: rotate(-12deg); }
.koto.k-worried .k-ear-r { animation: none; transform: rotate(12deg); }
.koto.k-worried .k-nibble { transform-box: fill-box; transform-origin: 85% 100%; animation: k-nibble 1.6s ease-in-out infinite; }
@keyframes k-nibble { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.5px) rotate(-3deg); } }
.koto.k-panicked .k-body { animation: k-panic .45s ease-in-out infinite; }
.koto.k-panicked .k-ear-l { animation: none; transform: rotate(-34deg); }
.koto.k-panicked .k-ear-r { animation: none; transform: rotate(34deg); }
.koto.k-panicked .k-tail { animation: k-droop 1.2s ease-in-out infinite; }
.koto.k-panicked .k-shock { transform-box: fill-box; transform-origin: center; animation: k-shock .9s ease-in-out infinite; }
@keyframes k-panic { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-1.2px) rotate(-1deg); } 75% { transform: translateX(1.2px) rotate(1deg); } }
@keyframes k-shock { 0%, 100% { opacity: .75; transform: scale(1); } 50% { opacity: .3; transform: scale(1.08); } }
.koto.k-desperate .k-body { animation: k-sway 2.6s ease-in-out infinite; }
.koto.k-desperate .k-ear-l { animation: none; transform: rotate(-26deg); }
.koto.k-desperate .k-ear-r { animation: none; transform: rotate(26deg); }
.koto.k-desperate .k-tail { animation: k-droop 3.6s ease-in-out infinite; }
.koto.k-desperate .k-tear { animation: k-tear 2.1s .3s ease-in infinite; }
.koto.k-desperate .k-tear-right { animation-delay: 1.2s; }
.koto.k-desperate .k-mouth { animation: k-lip-quiver 1.2s ease-in-out infinite; }
.koto.k-desperate .k-clock { transform-box: fill-box; transform-origin: 50% 60%; animation: k-ring .6s ease-in-out infinite; }
@keyframes k-ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes k-sheepish { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-3deg) translateY(1px); } 60% { transform: rotate(1.5deg); } }
@keyframes k-scratch { from { transform: rotate(-5deg); } to { transform: rotate(6deg); } }
@keyframes k-sweat {
  0% { opacity: 0; transform: translateY(-4px) scale(.6); }
  20%, 60% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(9px) scale(.9); }
}

/* Determined: alert ears, a ready bounce and a fist pump. */
.koto.k-determined .k-body { animation: k-ready 1.6s ease-in-out infinite; }
.koto.k-determined .k-fist { transform-origin: 0% 100%; animation: k-fist 1.6s cubic-bezier(.3, 1.6, .5, 1) infinite; }
.koto.k-determined .k-ear-l { transform: rotate(5deg); }
.koto.k-determined .k-ear-r { transform: rotate(-5deg); }
.koto.k-determined .k-flame { transform-origin: 50% 100%; animation: k-flame .5s ease-in-out infinite alternate; }
.koto .k-spark { transform-origin: 0% 50%; animation: k-spark 1.6s ease-out infinite; }
@keyframes k-ready { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-2px) scale(1.02, .99); } }
@keyframes k-fist { 0%, 40%, 100% { transform: rotate(0); } 55% { transform: rotate(-14deg) translateY(-3px); } 70% { transform: rotate(2deg); } }
@keyframes k-flame { from { transform: scale(1, 1); } to { transform: scale(1.12, 1.3); } }
@keyframes k-spark { 0%, 45% { opacity: 0; transform: scale(.4); } 60% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0; transform: scale(1.3); } }

/* Curious: a head tilt, one ear up and a bobbing question mark. */
.koto.k-curious .k-body { transform-origin: 50% 100%; animation: k-curious 3s ease-in-out infinite; }
.koto.k-curious .k-ear-l { transform: rotate(8deg); }
.koto.k-curious .k-ear-r { transform: rotate(18deg); }
.koto .k-question { transform-origin: 50% 100%; animation: k-question 2s ease-in-out infinite; }
@keyframes k-curious { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(-8deg) translateY(-1px); } }
@keyframes k-question { 0%, 100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-3px); } }

/* Excited: bouncing on the spot with paws up and zoom lines. */
.koto.k-excited .k-body { animation: k-excited .5s cubic-bezier(.3, 0, .4, 1) infinite; }
.koto.k-excited .k-shadow { animation: k-shadow .5s cubic-bezier(.3, 0, .4, 1) infinite; }
.koto.k-excited .k-arm-l { transform-origin: 100% 100%; animation: k-arm-l .25s ease-in-out infinite alternate; }
.koto.k-excited .k-arm-r { transform-origin: 0% 100%; animation: k-arm-r .25s ease-in-out infinite alternate; }
.koto.k-excited .k-tail { animation-duration: .3s; }
.koto .k-zoom { transform-origin: 50% 50%; animation: k-zoom .5s ease-in-out infinite alternate; }
@keyframes k-excited { 0%, 100% { transform: translateY(0) scale(1.04, .96); } 50% { transform: translateY(-9px) scale(.97, 1.04); } }
@keyframes k-zoom { from { opacity: .2; transform: scaleX(.6); } to { opacity: .75; transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  .koto .k-face, .koto .k-pupils { transition: none !important; }
}

[data-talking] .prompt .koto .k-mouth { transform-origin: 50% 20%; animation: talk 0.16s ease-in-out infinite alternate; }

/* ---------- the cast ---------- */
.char { display: block; overflow: visible; }
.char .c-eyes, .char .c-mouth { transform-box: fill-box; }
.char .c-eyes { transform-origin: 50% 50%; animation: k-blink var(--blink, 5.2s) infinite; animation-delay: var(--d, 0s); }
.char .c-mouth { transform-origin: 50% 0; transform: scaleY(0.7); }
.bob { animation: bob var(--bob, 2.8s) ease-in-out infinite; animation-delay: var(--d, 0s); }
.bob.delay { animation-delay: -1.4s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-4px) rotate(-1deg); } }
.presenter { transition: transform 0.2s cubic-bezier(.3, 1.6, .5, 1); }
.presenter:hover { transform: translateY(-4px) scale(1.06) rotate(-2deg); }
.story-avatar .char, .presenter .char { transform-origin: 50% 100%; }
[data-talking] .prompt .char .c-mouth,
[data-talking] .story-line.latest .char .c-mouth { animation: talk 0.15s ease-in-out infinite alternate; }
@keyframes talk { from { transform: scaleY(0.3); } to { transform: scaleY(1.2); } }
.avatar-c { display: inline-grid; place-items: end center; border-radius: 50%; overflow: hidden; flex-shrink: 0; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.05); }
.avatar-c svg { display: block; }
.avatar-c.big-avatar { box-shadow: 0 4px 0 var(--border-strong); }

/* ---------- shell ---------- */
.nav-icon { width: 34px; height: 34px; }
.nav-item .ic, .tab .ic { transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1); }
.nav-item:hover .ic, .tab:hover .ic { transform: scale(1.14) rotate(-6deg); }
.nav-item.active .ic, .tab.active .ic { animation: nav-pop 0.45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes nav-pop { 0% { transform: scale(0.6) rotate(-12deg); } 100% { transform: scale(1); } }
.tab { padding: 5px 10px; line-height: 0; }
.brand .koto { margin: -6px 0; }
.stat { display: inline-flex; align-items: center; gap: 6px; }
.stat .ic { transition: transform 0.2s cubic-bezier(.3, 1.6, .5, 1); }
.stat:hover .ic { transform: scale(1.15) rotate(-8deg); }
.stat.flag .ic { filter: drop-shadow(0 2px 0 var(--border)); }
.stat.streak.lit .ic { animation: flicker 1.6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.07, 0.94) rotate(-3deg); }
  60% { transform: scale(0.95, 1.07) rotate(3deg); }
}
.koto-card { display: flex; align-items: center; gap: 12px; }
.koto-card-text b { display: block; font-size: 1.05rem; }
.koto-card-text p { margin: 4px 0 0; }
.boost-note { display: flex; align-items: center; gap: 4px; }
.mq-icon, .quest-icon, .shop-icon, .hero-icon, .sb-icon { display: grid; place-items: center; }

/* ---------- splash / loading / auth ---------- */
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.splash-word { font-size: 2.3rem; font-weight: 900; color: var(--primary); letter-spacing: -0.03em; animation: fade 0.6s 0.2s both; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.loader-dots { display: flex; gap: 7px; }
.loader-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); animation: ldot 1s infinite ease-in-out; }
.loader-dots i:nth-child(2) { animation-delay: 0.15s; background: var(--gold); }
.loader-dots i:nth-child(3) { animation-delay: 0.3s; background: var(--blue); }
@keyframes ldot { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-8px); opacity: 1; } }
.auth-hero { display: grid; place-items: center; }
.auth-hero .koto { margin-bottom: -6px; }
.koto-says { display: flex; align-items: center; gap: 14px; }
.koto-says.vertical { flex-direction: column; text-align: center; gap: 16px; margin-bottom: 8px; }
.koto-bubble {
  position: relative; background: var(--card); border: 2px solid var(--border); border-radius: 18px; padding: 14px 20px;
  font-weight: 800; font-size: 1.2rem; box-shadow: 0 3px 0 var(--border); animation: pop 0.3s 0.2s both;
}
.koto-says.vertical .koto-bubble::before {
  content: ""; position: absolute; top: -9px; left: 50%; width: 14px; height: 14px; background: var(--card);
  border-left: 2px solid var(--border); border-top: 2px solid var(--border); transform: translateX(-50%) rotate(45deg);
}

/* ---------- learn path ---------- */
.node { position: relative; }
.node .node-icon { display: grid; place-items: center; line-height: 0; }
.node:not(.locked) .ic { filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.15)); }
.node.lesson:not(.locked)::after, .node.review:not(.locked)::after {
  content: ""; position: absolute; top: 9px; left: 15px; width: 22px; height: 9px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.32); transform: rotate(-24deg);
}
.node.active .node-icon { animation: star-spin 3s ease-in-out infinite; }
@keyframes star-spin { 0%, 70%, 100% { transform: rotate(0) scale(1); } 80% { transform: rotate(-12deg) scale(1.15); } 90% { transform: rotate(10deg) scale(1.05); } }
.node:hover:not(.locked) { filter: brightness(1.06); }
.node.chest .ic { filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.12)); }
.path-buddy, .path-friend { position: absolute; top: 50%; transform: translateY(-62%); z-index: 0; }
.path-buddy.left { right: calc(100% + 22px); }
.path-buddy.right { left: calc(100% + 22px); }
.path-friend { pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 6px; transform: translateY(-50%); }
.path-friend.left { right: calc(100% + 34px); }
.path-friend.right { left: calc(100% + 34px); }
/* A round portrait, like avatars elsewhere: the bust sits inside its own scene. */
.pf-badge { border-radius: 50%; padding: 4px; background: var(--card); box-shadow: 0 0 0 2px var(--border), 0 6px 0 var(--border-strong); }
.pf-badge .avatar-c { display: grid; }
.pf-name {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; color: var(--muted);
  background: var(--card); border: 2px solid var(--border); border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
@media (max-width: 460px) {
  .path-friend { display: none; }
  .path-buddy .koto { width: 74px; height: 73px; }
  /* Friends are hidden here, so Koto takes the roomier side of the path. */
  .path-buddy.m-left { left: auto; right: calc(100% + 10px); }
  .path-buddy.m-right { right: auto; left: calc(100% + 10px); }
}
.guide-btn .ic { filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15)); }

/* ---------- lesson player ---------- */
.presenter { flex-shrink: 0; display: grid; place-items: end center; }
.prompt.listen { align-items: center; justify-content: center; margin: 4px 0 26px; }
.listen-bubble { gap: 16px; padding: 16px 20px; }
@media (max-width: 420px) {
  .presenter .char, .presenter .koto { width: 78px; height: 78px; }
  .prompt.listen .presenter .char, .prompt.listen .presenter .koto { width: 86px; height: 86px; }
}
.speaker { display: inline-grid; place-items: center; padding: 0; }
.speaker .wave { transform-box: fill-box; transform-origin: 0 50%; }
.speaker.playing .wave { animation: wave 0.9s ease-out; }
.speaker.playing .w2 { animation-delay: 0.12s; }
.speaker.playing { animation: speaker-pulse 0.5s ease-out; }
.speaker:hover { filter: brightness(1.08); }
@keyframes wave { 0% { opacity: 0.15; transform: scale(0.5); } 50% { opacity: 1; transform: scale(1.12); } 100% { opacity: 1; transform: scale(1); } }
@keyframes speaker-pulse { 40% { transform: scale(1.06); } }

.icon-btn { line-height: 0; }
.player-progress.hot .pbar-fill { background: linear-gradient(90deg, #ffc800, #ff9600) !important; }
.player-progress .pbar-fill { background-size: 200% 100%; }
.combo { display: inline-flex; align-items: center; gap: 4px; top: -22px; }
.player-hearts { display: inline-flex; align-items: center; gap: 6px; }
.player-hearts.hit .ic { animation: heart-hit 0.7s ease 0.3s; }
@keyframes heart-hit {
  0% { transform: scale(1); }
  20% { transform: scale(1.4) rotate(-12deg); }
  40% { transform: scale(0.8) rotate(8deg); }
  60% { transform: scale(1.12) rotate(-4deg); }
  100% { transform: scale(1); }
}
.combo-burst {
  position: fixed; top: 74px; left: 50%; z-index: 60; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 2px solid var(--border); border-radius: 24px; padding: 4px 22px 4px 8px;
  box-shadow: 0 12px 34px rgba(40, 20, 120, 0.2); animation: burst-in 1.9s cubic-bezier(.3, 1.4, .5, 1) forwards; pointer-events: none;
}
.cb-text b { font-size: 2.4rem; font-weight: 900; color: #ff9600; display: block; line-height: 1; }
.cb-text span { font-weight: 900; color: var(--muted); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.05em; }
@keyframes burst-in {
  0% { transform: translate(-50%, -30px) scale(0.5); opacity: 0; }
  14% { transform: translate(-50%, 0) scale(1.06); opacity: 1; }
  22% { transform: translate(-50%, 0) scale(1); }
  84% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
}
.choice.selected { animation: choice-pick 0.25s cubic-bezier(.3, 1.6, .5, 1); }
.choice.correct { animation: choice-ok 0.45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes choice-pick { 50% { transform: scale(1.03); } }
@keyframes choice-ok { 40% { transform: scale(1.06); } }
.tile.placed { animation: tile-in 0.24s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tile-in { from { transform: scale(0.6) translateY(24px); opacity: 0.2; } }
.tile:hover:not(.used) { filter: brightness(0.98); transform: translateY(-1px); }
.tile.match.done { animation: match-done 0.45s ease-out; }
@keyframes match-done { 0% { opacity: 1; transform: scale(1); } 40% { opacity: 1; transform: scale(1.08); } 100% { opacity: 0.35; transform: scale(1); } }
.mic-icon { display: grid; }
.player-foot.good, .player-foot.bad { animation: foot-up 0.28s cubic-bezier(.3, 1.3, .5, 1); }
@keyframes foot-up { from { transform: translateY(100%); } }
.verdict-buddy { position: relative; flex-shrink: 0; animation: pop 0.35s cubic-bezier(.3, 1.6, .5, 1); margin: -18px 0 -8px; }
.verdict-badge {
  position: absolute; right: -6px; bottom: 4px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid var(--card); color: #fff;
}
.good .verdict-badge { background: var(--success); }
.bad .verdict-badge { background: var(--danger); }
@media (max-width: 560px) { .verdict-buddy .koto { width: 58px; height: 57px; } .verdict-buddy { margin: -10px 0 -4px; } }

/* ---------- celebrations ---------- */
.results { position: relative; }
.results-hero { position: relative; animation: pop 0.5s cubic-bezier(.3, 1.6, .5, 1); }
.results-trophy { position: absolute; right: -30px; bottom: 6px; animation: badge-in 0.8s 0.5s both cubic-bezier(.3, 1.6, .5, 1); filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15)); }
@keyframes badge-in { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.results-cheer { font-weight: 800; color: var(--muted); margin: 0 0 4px; }
.result-card { animation: card-in 0.5s both cubic-bezier(.3, 1.5, .5, 1); }
.result-card:nth-child(1) { animation-delay: 0.25s; }
.result-card:nth-child(2) { animation-delay: 0.4s; }
.result-card:nth-child(3) { animation-delay: 0.55s; }
@keyframes card-in { from { transform: translateY(24px) scale(0.8); opacity: 0; } }
.rc-value { display: flex; align-items: center; justify-content: center; gap: 6px; }
.result-cards.single { grid-template-columns: minmax(0, 200px); justify-content: center; }
.breakdown b { display: inline-flex; align-items: center; gap: 2px; }
.streak-flame { display: grid; animation: flicker 1.4s ease-in-out infinite; transform-origin: 50% 100%; }
.goal-banner { display: flex; align-items: center; justify-content: center; gap: 6px; animation: card-in 0.5s 0.8s both cubic-bezier(.3, 1.5, .5, 1); }
.streak-banner { animation: card-in 0.5s 0.7s both cubic-bezier(.3, 1.5, .5, 1); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.confetti i { position: absolute; top: -20px; animation-name: confetti-fall; animation-timing-function: cubic-bezier(.2, .6, .4, 1); animation-fill-mode: forwards; }
@keyframes confetti-fall {
  0% { transform: translate(0, -5vh) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: 0; }
}
.notice-art { position: relative; display: inline-block; margin: 0 auto 2px; }
.notice-art .koto { margin: 0 auto; }
.notice-art-badge { position: absolute; right: -34px; bottom: 4px; animation: badge-in 0.7s 0.15s both cubic-bezier(.3, 1.6, .5, 1); filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15)); }
.session-error .koto, .results > .koto { margin: 0 auto; }

/* ---------- screens ---------- */
.page-hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-hero h1 { margin-top: 0.3em; }
.hero-cast { display: flex; flex-shrink: 0; }
.hero-cast .char + .char { margin-left: -16px; }
@media (max-width: 480px) { .page-hero > .koto, .hero-cast { display: none; } }
.characters-hero { display: flex; align-items: center; justify-content: center; gap: 10px; }
.characters-hero h1 { margin-top: 0; }
@media (max-width: 560px) { .characters-hero .char { display: none; } }
.empty .koto { margin: 0 auto 4px; }
.pc-icon { display: grid; place-items: center; }
.practice-card .ic { transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1); }
.practice-card:hover .ic { transform: scale(1.1) rotate(-6deg); }
.practice-card.featured .pc-icon { background: rgba(255, 255, 255, 0.95); border-radius: 14px; padding: 4px; }
.course-flag { line-height: 0; margin-bottom: 4px; }
.reward { display: inline-flex; flex-direction: column; align-items: center; font-size: 0.85rem; }
.reward > span { display: inline-flex; align-items: center; gap: 3px; }
.claim { display: inline-flex; align-items: center; gap: 4px; animation: wiggle 1.8s infinite; }
.btn.price { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.league-row .rank { display: grid; place-items: center; }
.league-timer { display: flex; align-items: center; justify-content: center; gap: 2px; }
.flags { align-items: center; }
.quest-hero .koto, .quest-hero .char { margin: -12px 0 -14px; }

/* ---------- stories as a chat ---------- */
.story-line { display: flex; align-items: flex-end; gap: 10px; margin: 16px 0; animation: pop 0.25s ease-out; }
.story-line.right { flex-direction: row-reverse; }
.story-line.narrator { justify-content: center; }
.story-avatar { flex-shrink: 0; }
.story-bubble {
  position: relative; background: var(--card); border: 2px solid var(--border); border-radius: 18px;
  padding: 10px 14px; min-width: 0; max-width: calc(100% - 80px); box-shadow: 0 3px 0 var(--border);
}
.story-line.left .story-bubble { border-bottom-left-radius: 6px; }
.story-line.right .story-bubble {
  border-bottom-right-radius: 6px; background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); box-shadow: 0 3px 0 color-mix(in srgb, var(--primary) 25%, var(--border));
}
.story-line.narrator .story-bubble { background: transparent; border: none; box-shadow: none; max-width: 100%; }
.story-line.latest .story-avatar .char { animation: bob 1.4s ease-in-out infinite; }
.line-text { border-bottom-color: color-mix(in srgb, var(--muted) 35%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .koto *, .koto, .char *, .bob, .confetti, .combo-burst, .claim, .stat .ic { animation: none !important; }
  .koto { transition: none; }
  .koto:hover { transform: none; }
  .koto.k-heartbroken .k-tear { opacity: .8; transform: none; }
  .koto.k-relieved .k-exhale { opacity: .5; }
}

.notice-setback .notice-art { margin-bottom: 12px; }
.notice-setback .notice-art-badge { background: var(--card); border-radius: 50%; padding: 6px; box-shadow: 0 3px 12px rgba(85, 70, 130, .12); animation: notice-settle .8s ease-out; }
.notice-protected .notice-art-badge { animation: notice-saved 3s ease-in-out infinite; }
.notice .notice-comfort-hint { font-size: .82rem; color: var(--muted); margin-top: 8px; }
.notice .btn + .btn { margin-top: 8px; }
@keyframes notice-settle { from { transform: translateY(-10px) rotate(-12deg); opacity: 0; } to { transform: translateY(0) rotate(0); opacity: 1; } }
@keyframes notice-saved { 50% { transform: translateY(-4px) rotate(5deg); } }
@media (prefers-reduced-motion: reduce) {
  .notice-art-badge { animation: none !important; }
}

/* ---------- emoji-free UI ---------- */
.zone-divider { display: flex; align-items: center; justify-content: center; gap: 4px; }
.link.back { display: inline-flex; align-items: center; gap: 2px; }
.claimed { display: inline-flex; align-items: center; gap: 4px; }
.story-cover { line-height: 0; }
.koto-card-text b .ic { margin-top: -4px; }
.toast .ic { margin: -3px 4px 0 0; }

.avatar-edit { position: relative; border: none; background: none; padding: 0; flex-shrink: 0; border-radius: 50%; }
.avatar-edit:hover .avatar-c { filter: brightness(1.04); }
.avatar-edit-badge {
  position: absolute; right: -2px; bottom: 2px; width: 32px; height: 32px; border-radius: 50%; background: var(--card);
  border: 2px solid var(--border); display: grid; place-items: center; box-shadow: 0 2px 0 var(--border);
}
.avatar-cta { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; }
.settings-avatar { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.settings-avatar .btn { display: inline-flex; align-items: center; gap: 4px; }
.nav-avatar { box-shadow: 0 0 0 2px var(--border); }
.nav-item.active .nav-avatar, .tab.active .nav-avatar { box-shadow: 0 0 0 2px var(--primary); }

/* =====================================================================
   Teaching cards, kanji chart and motion polish
   ===================================================================== */

/* ---------- teach card ---------- */
.teach-label {
  display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 14px; padding: 6px 14px 6px 10px; border-radius: 99px;
  background: color-mix(in srgb, var(--gold) 20%, var(--card)); color: var(--gold-dark); font-weight: 900; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.08em; animation: label-in 0.5s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes label-in { from { transform: scale(0.4) rotate(-8deg); opacity: 0; } }
.teach-hero { display: flex; align-items: flex-end; gap: 10px; perspective: 900px; }
.teach-koto { flex-shrink: 0; animation: koto-peek 0.6s 0.15s both cubic-bezier(.3, 1.5, .5, 1); }
@keyframes koto-peek { from { transform: translateY(30px) scale(0.6); opacity: 0; } }
.teach-card {
  flex: 1; min-width: 0; background: var(--card); border: 2px solid var(--border); border-radius: 22px; padding: 20px 18px 16px;
  text-align: center; box-shadow: 0 5px 0 var(--border); transform-origin: 50% 100%;
  animation: card-flip 0.65s cubic-bezier(.25, 1.3, .45, 1) both;
}
@keyframes card-flip { from { transform: rotateX(-75deg) translateY(20px); opacity: 0; } }
.teach-term { font-size: 2.3rem; font-weight: 800; line-height: 1.7; font-family: "Noto Sans JP", "Nunito", sans-serif; }
.teach-card.single .teach-term { font-size: 5.2rem; line-height: 1.15; }
.teach-term ruby rt { font-size: 0.42em; }
.teach-reading { font-weight: 900; color: var(--primary); font-size: 1.15rem; letter-spacing: 0.04em; margin-top: 2px; }
.teach-meaning { font-weight: 900; font-size: 1.3rem; margin: 6px 0 10px; animation: fade 0.4s 0.45s both; }
.teach-audio { display: flex; justify-content: center; gap: 10px; animation: fade 0.4s 0.55s both; }
.teach-tip {
  display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; padding: 12px 14px; border-radius: 16px;
  background: var(--primary-soft); color: var(--text); font-weight: 700; animation: slide-up 0.45s 0.35s both;
}
.teach-tip .ic { margin-top: 2px; }
.teach-sub { margin: 18px 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.kanji-breakdown { display: grid; gap: 10px; }
.kanji-breakdown .kanji-chip { animation: slide-up 0.45s both; }
.kanji-breakdown .kanji-chip:nth-child(1) { animation-delay: 0.4s; }
.kanji-breakdown .kanji-chip:nth-child(2) { animation-delay: 0.5s; }
.kanji-breakdown .kanji-chip:nth-child(3) { animation-delay: 0.6s; }
.kanji-breakdown .kanji-chip:nth-child(4) { animation-delay: 0.7s; }
.kanji-chip { display: flex; gap: 14px; align-items: center; border: 2px solid var(--border); border-radius: 18px; padding: 10px 14px; background: var(--card); box-shadow: 0 3px 0 var(--border); }
.kc-char {
  width: 72px; height: 72px; flex-shrink: 0; display: grid; place-items: center; border-radius: 16px; font-size: 2.7rem;
  font-family: "Noto Sans JP", sans-serif; font-weight: 700; color: #fff; background: linear-gradient(160deg, #ff7a8a, #e8364f);
  box-shadow: 0 4px 0 #b8243a;
}
.kc-body { min-width: 0; }
.kc-meaning { display: block; font-size: 1.05rem; text-transform: capitalize; }
.kc-read { font-family: "Noto Sans JP", sans-serif; font-weight: 700; margin-top: 3px; font-size: 0.95rem; }
.kc-tag { display: inline-block; font-family: "Nunito", sans-serif; font-size: 0.65rem; font-weight: 900; padding: 1px 6px; border-radius: 6px; margin-right: 4px; vertical-align: 2px; color: #fff; }
.kc-tag.on { background: var(--blue); }
.kc-tag.kun { background: var(--success); }
.kc-strokes { color: var(--muted); font-weight: 800; font-size: 0.8rem; margin-top: 3px; }
.teach-examples { display: grid; gap: 8px; }
.teach-ex { display: flex; gap: 12px; align-items: center; background: var(--bg-soft); border-radius: 14px; padding: 10px 12px; animation: slide-up 0.45s both; }
.teach-examples .teach-ex:nth-child(1) { animation-delay: 0.5s; }
.teach-examples .teach-ex:nth-child(2) { animation-delay: 0.62s; }
.teach-examples .teach-ex:nth-child(3) { animation-delay: 0.74s; }
.teach-ex-text { font-weight: 800; font-size: 1.15rem; line-height: 1.9; }
.teach-foot { background: color-mix(in srgb, var(--gold) 12%, var(--bg)); }
.teach-hint { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--gold-dark); }
@media (max-width: 560px) { .teach-hint { display: none; } .teach-koto .koto { width: 64px; height: 63px; } .teach-term { font-size: 1.9rem; } }
@keyframes slide-up { from { transform: translateY(14px); opacity: 0; } }

/* ---------- kanji chart ---------- */
.kanji-count { text-align: center; color: var(--muted); font-weight: 700; margin: 14px 0 6px; }
.kanji-count b { color: var(--primary); }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-top: 12px; }
.kanji-cell {
  border: 2px solid var(--border); background: var(--card); border-radius: 14px; padding: 8px 4px 6px; box-shadow: 0 3px 0 var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 2px; opacity: 0.55;
  animation: cell-in 0.4s var(--d) both cubic-bezier(.3, 1.5, .5, 1); transition: transform 0.15s;
}
.kanji-cell.learned { opacity: 1; border-color: color-mix(in srgb, #e8364f 45%, var(--border)); box-shadow: 0 3px 0 color-mix(in srgb, #e8364f 45%, var(--border)); }
.kanji-cell:hover { transform: translateY(-3px) rotate(-2deg); opacity: 1; }
.kanji-char { font-family: "Noto Sans JP", sans-serif; font-size: 1.9rem; font-weight: 700; }
.kanji-cell.learned .kanji-char { color: #e8364f; }
.kanji-meaning { font-size: 0.68rem; font-weight: 800; color: var(--muted); text-align: center; line-height: 1.2; }
@keyframes cell-in { from { transform: scale(0.5); opacity: 0; } }
.kanji-detail .kanji-chip { margin: 8px 0; box-shadow: none; }

/* ---------- motion polish ----------
   Wrapper animations use `backwards`, not `both`: a held transform would turn the wrapper
   into the containing block for fixed-position modals inside it. */
.page > * { animation: page-in 0.35s cubic-bezier(.2, .8, .3, 1) backwards; }
@keyframes page-in { from { transform: translateY(12px); opacity: 0; } }
.player-body .ex { animation: ex-in 0.38s cubic-bezier(.2, .9, .3, 1) backwards; }
@keyframes ex-in { from { transform: translateX(46px); opacity: 0; } }
.path .node-wrap { animation: node-in 0.45s both cubic-bezier(.3, 1.5, .5, 1); }
.path .node-wrap:nth-child(1) { animation-delay: 0.05s; } .path .node-wrap:nth-child(2) { animation-delay: 0.1s; }
.path .node-wrap:nth-child(3) { animation-delay: 0.15s; } .path .node-wrap:nth-child(4) { animation-delay: 0.2s; }
.path .node-wrap:nth-child(5) { animation-delay: 0.25s; } .path .node-wrap:nth-child(6) { animation-delay: 0.3s; }
.path .node-wrap:nth-child(7) { animation-delay: 0.35s; } .path .node-wrap:nth-child(8) { animation-delay: 0.4s; }
@keyframes node-in { from { opacity: 0; scale: 0.4; } }
.node.active::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 4px solid color-mix(in srgb, var(--c) 55%, transparent);
  animation: ring 1.8s ease-out infinite; pointer-events: none;
}
.node.chest.active::before, .node.review.active::before { border-radius: 26px; }
@keyframes ring { 0% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0; } }
.unit-banner { overflow: hidden; }
.unit-banner::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.22), transparent); animation: shine 6s ease-in-out infinite;
}
@keyframes shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
.pbar-fill { animation: bar-grow 0.8s cubic-bezier(.2, .8, .3, 1); transform-origin: left center; }
.pbar-fill::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.35) 50%, transparent 100%); background-size: 50% 100%;
  background-repeat: no-repeat; animation: bar-shine 2.6s ease-in-out infinite;
}
@keyframes bar-grow { from { transform: scaleX(0); } }
@keyframes bar-shine { 0% { background-position: -100% 0; } 60%, 100% { background-position: 250% 0; } }
.stat-num { display: inline-block; animation: num-bump 0.45s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes num-bump { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
.choice, .tile { position: relative; }
.choice.correct::after {
  content: ""; position: absolute; inset: -4px; border-radius: 18px; pointer-events: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); animation: burst 0.6s ease-out;
}
@keyframes burst { to { box-shadow: 0 0 0 16px transparent; } }
.modal { animation: modal-in 0.4s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes modal-in { from { transform: translateY(40px) scale(0.9); opacity: 0; } }
.practice-card, .story-card, .course-card, .shop-item, .quest, .card.league-mini {
  transition: transform 0.18s cubic-bezier(.3, 1.5, .5, 1), box-shadow 0.18s;
}
.practice-card:hover, .story-card:hover, .course-card:hover { transform: translateY(-3px); }
.practice-grid > *, .story-grid > *, .course-grid > *, .league-list > *, .quest, .shop-item, .ach, .word-row, .stats-grid > * {
  animation: slide-up 0.4s both;
}
.practice-grid > :nth-child(2), .story-grid > :nth-child(2), .league-list > :nth-child(2), .stats-grid > :nth-child(2) { animation-delay: 0.05s; }
.practice-grid > :nth-child(3), .story-grid > :nth-child(3), .league-list > :nth-child(3), .stats-grid > :nth-child(3) { animation-delay: 0.1s; }
.practice-grid > :nth-child(4), .story-grid > :nth-child(4), .league-list > :nth-child(4), .stats-grid > :nth-child(4) { animation-delay: 0.15s; }
.practice-grid > :nth-child(5), .story-grid > :nth-child(5), .league-list > :nth-child(5), .stats-grid > :nth-child(5) { animation-delay: 0.2s; }
.practice-grid > :nth-child(6), .story-grid > :nth-child(6), .league-list > :nth-child(6), .stats-grid > :nth-child(6) { animation-delay: 0.25s; }
.league-list > :nth-child(n+7), .story-grid > :nth-child(n+7) { animation-delay: 0.3s; }
.verdict-text h3 { animation: label-in 0.4s cubic-bezier(.3, 1.6, .5, 1); }
.btn.primary:not(:disabled):hover { transform: translateY(-1px); }
.btn.primary:not(:disabled):active { transform: translateY(3px); }
.node.locked:active { animation: shake 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .page > *, .player-body .ex, .path .node-wrap, .node.active::before, .unit-banner::after, .pbar-fill, .pbar-fill::before,
  .stat-num, .teach-card, .teach-koto, .kanji-cell, .kanji-chip, .teach-ex, .modal { animation: none !important; }
}
/* The reading line under the term replaces furigana on teaching cards. */
.teach-term rt { display: none; }

/* =====================================================================
   Avatar builder
   ===================================================================== */
.page:has(.avatar-builder) { max-width: 1080px; }
.avatar-builder { padding-bottom: 28px; }
.ab-top h1 { margin: 0.15em 0 0.5em; }
.ab-layout { display: grid; gap: 18px; }
@media (min-width: 900px) {
  .ab-layout { grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); align-items: start; }
  .ab-stage-wrap { position: sticky; top: 76px; }
}

/* ---- stage */
.ab-stage {
  position: relative; aspect-ratio: 1 / 1; border-radius: 30px; overflow: hidden; isolation: isolate;
  box-shadow: 0 8px 0 var(--border), 0 18px 40px rgba(40, 20, 120, 0.14); border: 3px solid var(--card);
}
.ab-portrait { position: absolute; inset: 0; }
.ab-portrait.spin { animation: ab-spin 0.6s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes ab-spin { 0% { transform: scale(0.75) rotate(-14deg); opacity: 0.3; } 100% { transform: none; opacity: 1; } }
.ab-svg { display: block; width: 100%; height: 100%; }
.ab-svg .c-eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: k-blink 4.8s infinite; }
.ab-svg .c-mouth { transform-box: fill-box; transform-origin: 50% 0; }
.ab-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 18%, rgba(255, 255, 255, 0.35), transparent 55%),
              linear-gradient(to top, rgba(0, 0, 0, 0.12), transparent 30%);
}
.ab-stage-tools { position: absolute; top: 12px; right: 12px; z-index: 3; display: flex; gap: 8px; }
.ab-tool {
  width: 48px; height: 48px; border-radius: 15px; border: none; background: rgba(255, 255, 255, 0.92); color: #3c3a4d;
  display: grid; place-items: center; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16); transition: transform 0.15s;
}
.ab-tool:hover:not(:disabled) { transform: translateY(-2px); }
.ab-tool:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16); }
.ab-tool:disabled { opacity: 0.45; cursor: default; }
.ab-tool.dice:hover { transform: rotate(-14deg) scale(1.06); }
.ab-tool.dice:active { transform: rotate(40deg) scale(0.95); }
.ab-koto { position: absolute; left: 8px; bottom: 6px; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.ab-koto .koto-bubble { font-size: 0.82rem; padding: 6px 12px; border-radius: 14px; color: #2b2a35; background: #fff; border-color: rgba(0, 0, 0, 0.06); animation: none; max-width: 150px; }
.ab-nameplate {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; background: rgba(255, 255, 255, 0.92); color: #2b2a35;
  font-weight: 900; padding: 6px 16px; border-radius: 99px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12); white-space: nowrap; max-width: 46%;
  overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem;
}
.ab-actions { display: flex; gap: 10px; margin-top: 18px; }
.ab-actions .btn { flex: 1; }
.ab-actions .btn.primary { flex: 2; }

/* ---- panel */
.ab-panel { background: var(--card); border: 2px solid var(--border); border-radius: 24px; padding: 14px; box-shadow: 0 4px 0 var(--border); }
.ab-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; padding-bottom: 14px; border-bottom: 2px dashed var(--border); }
.ab-cat {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px; border-radius: 16px;
  border: 2px solid transparent; background: var(--bg-soft); color: var(--muted); font-weight: 900; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em; transition: transform 0.15s, background 0.15s;
}
.ab-cat:hover { transform: translateY(-2px); }
.ab-cat.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 3px 0 var(--primary); }
.ab-cat .avatar-c { box-shadow: 0 0 0 2px var(--card); }
.ab-options { padding-top: 6px; animation: fade 0.25s; }
.ab-section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 2px 10px; }
.ab-section-head h3 { margin: 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.ab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.ab-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px;
  border: 2px solid var(--border); background: var(--card); border-radius: 18px; box-shadow: 0 3px 0 var(--border);
  transition: transform 0.15s cubic-bezier(.3, 1.6, .5, 1), border-color 0.15s;
}
.ab-tile:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.ab-tile:active { transform: translateY(1px); }
.ab-tile .avatar-c { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.04); }
.ab-tile-label { font-size: 0.74rem; font-weight: 800; color: var(--muted); text-align: center; line-height: 1.15; }
.ab-tile.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 3px 0 var(--primary); animation: choice-pick 0.25s cubic-bezier(.3, 1.6, .5, 1); }
.ab-tile.active .ab-tile-label { color: var(--primary); }
.ab-tick {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%; background: var(--primary);
  display: grid; place-items: center; border: 2px solid var(--card); animation: label-in 0.3s cubic-bezier(.3, 1.6, .5, 1);
}
.ab-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--card); display: grid; place-items: center;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.55), transparent 42%), var(--sw);
  box-shadow: 0 0 0 2px var(--border), 0 3px 0 2px var(--border); transition: transform 0.15s cubic-bezier(.3, 1.6, .5, 1);
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 3px var(--primary), 0 3px 0 3px var(--primary); transform: scale(1.08); }
.swatch .ic { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
.ab-surprise { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; }

/* ---- save celebration */
.ab-done { text-align: center; }
.ab-done-stage { position: relative; width: 190px; height: 190px; margin: 0 auto 8px; border-radius: 28px; overflow: hidden; box-shadow: 0 6px 0 var(--border); animation: card-flip 0.6s cubic-bezier(.25, 1.3, .45, 1); }
.ab-done-koto { position: absolute; right: -6px; bottom: -8px; }
.ab-done h2 { margin-top: 12px; }

@media (max-width: 899px) {
  .ab-stage-wrap { max-width: 440px; width: 100%; margin: 0 auto; }
  .ab-actions { position: sticky; bottom: 76px; z-index: 5; background: var(--bg); padding: 10px 0; margin: 10px 0 0; }
}
@media (max-width: 480px) {
  .ab-koto .koto { width: 56px; height: 55px; }
  .ab-koto .koto-bubble { font-size: 0.72rem; max-width: 110px; }
  .ab-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
  .ab-tile .avatar-c, .ab-tile .avatar-c svg { width: 60px !important; height: 60px !important; }
  .ab-cats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .ab-cat span { font-size: 0.6rem; }
  .ab-cat .avatar-c, .ab-cat .avatar-c svg { width: 34px !important; height: 34px !important; }
}
.ab-cats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ab-cat span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- achievement celebration: treasure chest reveal ---------- */
/* Timeline: 0 to 0.5 s the chest drops in; 0.5 to 1.25 s it rattles with light
   leaking from the seam; 1.25 s the lid bursts open in a flash and a column of
   light; 1.45 to 2.35 s the badge rises out spinning; then the text arrives. */
.ach-celebrate {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; overflow: hidden;
  background: radial-gradient(circle at 50% 38%, #4b2fb8 0%, #2a1a6e 45%, #140c35 100%);
  color: #fff; animation: ac-fade .35s ease-out;
}
@keyframes ac-fade { from { opacity: 0; } to { opacity: 1; } }
.ach-celebrate .confetti { z-index: 1; }
.ac-stage { position: relative; z-index: 2; width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.ac-label {
  font-weight: 900; letter-spacing: .18em; font-size: .85rem; color: #ffe066; min-height: 1.2em; margin-bottom: 14px; position: relative; z-index: 3;
  animation: ac-drop .5s 2.1s cubic-bezier(.3,1.5,.5,1) backwards;
}
@keyframes ac-drop { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }

.ac-scene { height: 330px; margin: 2px auto 0; }
.ac-scene .c3-scene { bottom: 52px; }
.ac-scene .ac-spark { top: 200px; z-index: 3; }
@keyframes ac-spin { to { transform: rotate(360deg); } }
@keyframes ac-pulse { 50% { transform: scale(1.15); opacity: .85; } }
@keyframes ac-flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

/* The badge rises out of the chest, spinning, into the spotlight. */
.ac-rise {
  position: absolute; left: 50%; top: 132px; width: 140px; height: 140px; margin-left: -70px; z-index: 3;
  opacity: 0; animation: ac-rise-out .9s 1.45s cubic-bezier(.25,.9,.35,1) both;
}
@keyframes ac-rise-out {
  0% { opacity: 0; transform: perspective(600px) translateY(0) scale(.25) rotateY(0); }
  14% { opacity: 1; }
  70% { opacity: 1; transform: perspective(600px) translateY(-158px) scale(1.08) rotateY(540deg); }
  100% { opacity: 1; transform: perspective(600px) translateY(-146px) scale(1) rotateY(720deg); }
}
.ac-badge {
  position: relative; width: 140px; height: 140px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--tier-light), var(--tier-dark), var(--tier-light), var(--tier-dark), var(--tier-light));
  box-shadow: 0 8px 0 rgba(0,0,0,.25), 0 0 0 6px rgba(255,255,255,.14), 0 0 44px var(--tier-light);
  display: grid; place-items: center; overflow: hidden;
  animation: ac-hover 2.6s 2.5s ease-in-out infinite;
}
@keyframes ac-hover { 50% { transform: translateY(-6px); } }
.ac-badge-inner { width: 106px; height: 106px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0%, #f3efff 55%, #ddd4ff 100%); display: grid; place-items: center; box-shadow: inset 0 -6px 0 rgba(0,0,0,.08); }
.ac-icon { display: grid; animation: ac-icon-bob 2.4s 2.6s ease-in-out infinite; }
@keyframes ac-icon-bob { 50% { transform: translateY(-4px) rotate(-4deg); } }
.ac-shine { position: absolute; inset: 0; background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.75) 48%, transparent 60%); transform: translateX(-120%); animation: ac-shine 2.8s 2.3s ease-in-out infinite; pointer-events: none; }
@keyframes ac-shine { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.ac-ribbon {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: #ff4b6e; color: #fff; font-weight: 900; font-size: .74rem; letter-spacing: .08em;
  padding: 3px 12px; border-radius: 999px; box-shadow: 0 3px 0 #c42a4c; white-space: nowrap;
  animation: ac-drop .4s 2.35s cubic-bezier(.3,1.6,.5,1) backwards;
}
.ac-spark { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px; opacity: 0; animation: ac-burst 1.1s ease-out forwards; }
.ac-spark.dot { width: 9px; height: 9px; margin: -4.5px; border-radius: 50%; background: #7fe0ff; }
.ac-spark.star { background: #ffe066; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
@keyframes ac-burst {
  0% { opacity: 0; transform: rotate(var(--a)) translateY(0) scale(.2); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) scale(1.2); }
}
/* Koto jumps in to cheer as the badge appears. */
.ac-koto { position: absolute; left: -10px; bottom: 0; z-index: 5; animation: ac-koto-in .55s 1.6s cubic-bezier(.3,1.6,.5,1) backwards; }
@keyframes ac-koto-in { from { opacity: 0; transform: translateY(40px) scale(.4); } }

.ac-title { font-size: 2rem; margin: 4px 0 8px; text-shadow: 0 3px 0 rgba(0,0,0,.25); animation: ac-rise .5s 2.25s ease-out backwards; }
@keyframes ac-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.ac-dots { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; animation: ac-rise .5s 2.35s ease-out backwards; }
.ac-dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.25); }
.ac-dot.on { background: #ffc800; border-color: #ffe066; }
.ac-dot.new { background: #ffc800; border-color: #fff; box-shadow: 0 0 12px #ffe066; animation: ac-dot-pop .6s 2.7s cubic-bezier(.3,1.8,.5,1) backwards; }
@keyframes ac-dot-pop { from { transform: scale(0); } }
.ac-next { color: rgba(255,255,255,.85); font-weight: 700; margin: 12px 0 2px; animation: ac-rise .5s 2.45s ease-out backwards; }
.ac-count { font-size: .8rem; font-weight: 800; color: rgba(255,255,255,.6); margin-top: 6px; }
.ac-btn { max-width: 340px; margin-top: 12px; opacity: .001; transform: translateY(10px); transition: opacity .3s, transform .3s; pointer-events: none; }
.ac-btn.ready { opacity: 1; transform: none; pointer-events: auto; }
/* A tap during the reveal, or reduced motion, jumps to the finished scene. */
.ac-skip .ac-stage *, .ac-skip .ac-stage { animation-delay: -10s !important; }
@media (max-height: 640px) { .ac-scene { transform: scale(.85); margin: -24px 0 -26px; } .ac-title { font-size: 1.6rem; } }
@media (prefers-reduced-motion: reduce) {
  .ach-celebrate .ac-stage * { animation-delay: -10s !important; }
  .c3-rays, .c3-halo, .ac-icon, .ac-shine, .c3-beam, .ac-badge { animation: none; }
  .c3-beam { opacity: .7; }
}

/* ---------- treasure reveal on the learning path ---------- */
/* Gems arc out of the open chest, then swoop down into the counter, which adds
   one share per gem (chest::gem_arrival). */
.tr-label { text-transform: uppercase; }
.tr-gems { position: absolute; left: 50%; top: 172px; width: 0; height: 0; z-index: 3; --land: 168px; }
.tr-gem { position: absolute; left: 0; top: 0; width: 28px; height: 28px; margin: -14px; display: grid; place-items: center; opacity: 0;
  filter: drop-shadow(0 0 6px rgba(127,224,255,.8)); animation-name: tr-gem; animation-fill-mode: both; animation-timing-function: linear; }
@keyframes tr-gem {
  0% { opacity: 0; transform: translate(0, 0) scale(.3) rotate(0deg); animation-timing-function: cubic-bezier(.2,.7,.4,1); }
  10% { opacity: 1; }
  40% { transform: translate(var(--dx), calc(var(--up) * -1)) scale(1.15) rotate(calc(var(--spin) * .6)); animation-timing-function: cubic-bezier(.55,0,.8,.45); }
  92% { opacity: 1; }
  100% { opacity: 0; transform: translate(0, var(--land)) scale(.55) rotate(var(--spin)); }
}
.tr-amount {
  position: relative; z-index: 3; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 132px; margin: -4px 0 2px;
  padding: 8px 20px; border-radius: 999px; background: rgba(0,0,0,.3); box-shadow: inset 0 0 0 2px rgba(255,255,255,.14);
  font-weight: 900; font-size: 2rem; line-height: 1.1; opacity: .3; transition: opacity .25s, box-shadow .25s;
}
.tr-amount.on { opacity: 1; box-shadow: inset 0 0 0 2px rgba(127,224,255,.55), 0 0 26px rgba(127,224,255,.4); }
.tr-num { display: inline-block; font-variant-numeric: tabular-nums; animation: tr-bump .28s cubic-bezier(.3,1.8,.5,1); }
@keyframes tr-bump { from { transform: scale(1.4); color: #7fe0ff; } }
.tr-message { margin-top: 8px; }

/* ---------- level test ---------- */
.level-test { max-width: 680px; margin: 0 auto; padding: 0 16px 140px; min-height: 100vh; }
.level-test .player-top { padding-left: 0; padding-right: 0; }
.lt-intro, .lt-result { text-align: center; }
.lt-hero { position: relative; display: inline-block; margin: 6px auto 4px; }
.lt-hero-badge { position: absolute; right: -36px; bottom: 4px; animation: ac-badge-in .8s .2s cubic-bezier(.2,1.6,.4,1) backwards; }
.lt-intro h1 { font-size: 2rem; margin: 8px 0 6px; }
.lt-lead { color: var(--muted); font-weight: 700; font-size: 1.05rem; max-width: 520px; margin: 0 auto 18px; }
.lt-facts { list-style: none; padding: 0; margin: 0 auto 16px; max-width: 480px; text-align: left; display: grid; gap: 10px; }
.lt-facts li { display: flex; gap: 12px; align-items: center; background: var(--bg-soft); border: 2px solid var(--border); border-radius: 14px; padding: 10px 14px; font-weight: 600; }
.lt-last { font-weight: 700; }
.lt-note { margin-top: 12px; }
.btn.big { padding: 16px; font-size: 1.1rem; max-width: 480px; }
.lt-count { font-weight: 900; color: var(--muted); min-width: 28px; text-align: right; }
.lt-body { padding-top: 4px; }
.lt-section { display: inline-block; font-size: .78rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); background: var(--primary-soft); padding: 4px 10px; border-radius: 999px; }
.lt-instruction { font-size: 1.35rem; margin: 10px 0 14px; }
.lt-listen { display: flex; gap: 14px; justify-content: center; margin: 8px 0 18px; }
.lt-passage { background: var(--bg-soft); border: 2px solid var(--border); border-radius: 16px; padding: 14px 16px; font-size: 1.15rem; line-height: 2.1; margin-bottom: 14px; }
.lt-passage p { margin: 0; }
.lt-passage.small { font-size: 1rem; line-height: 1.9; }
.lt-prompt { font-size: 1.45rem; font-weight: 700; line-height: 2.2; margin: 6px 0 18px; }
.lt-prompt.small { font-size: 1.1rem; line-height: 1.8; }
.lt-target { text-decoration: underline; text-decoration-color: var(--primary); text-decoration-thickness: 3px; text-underline-offset: 6px; color: var(--primary); }
.lt-blank { display: inline-block; width: 3.2em; height: 1.1em; border-bottom: 3px solid var(--primary); vertical-align: -0.1em; margin: 0 .2em; }
.lt-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lt-options.en { grid-template-columns: 1fr; }
.lt-option {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; min-height: 64px;
  background: var(--card); color: var(--text); border: 2px solid var(--border); border-radius: 16px; box-shadow: 0 4px 0 var(--border);
  font-size: 1.15rem; font-weight: 700; transition: transform .08s, background .15s, border-color .15s;
}
.lt-options.en .lt-option { font-size: 1rem; }
.lt-option:hover { background: var(--bg-soft); }
.lt-option:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--border); }
.lt-option.selected { background: var(--primary-soft); border-color: var(--primary); box-shadow: 0 4px 0 var(--primary); color: var(--primary-dark); }
.lt-key { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--border); display: grid; place-items: center; font-size: .85rem; font-weight: 900; color: var(--muted); }
.lt-option.selected .lt-key { border-color: var(--primary); color: var(--primary); }
.lt-footer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 2px solid var(--border); padding: 14px max(16px, calc((100% - 680px) / 2 + 16px)); display: flex; justify-content: space-between; align-items: center; gap: 12px; z-index: 10; }
.lt-footer .btn { min-width: 160px; }
@media (max-width: 560px) {
  .lt-options { grid-template-columns: 1fr; }
  .lt-footer .muted { display: none; }
  .lt-footer .btn { flex: 1; }
}
.lt-kicker { font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 6px 0 0; font-size: .85rem; }
.lt-level {
  font-size: 4.6rem; font-weight: 900; line-height: 1.05;
  background: linear-gradient(135deg, var(--primary), #ff6bb5); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: ac-badge-in .8s .1s cubic-bezier(.2,1.6,.4,1) backwards;
}
.lt-headline { margin: 2px 0 10px; }
.lt-best { display: inline-flex; align-items: center; gap: 6px; background: #fff4cc; color: #9a6400; font-weight: 900; padding: 6px 14px; border-radius: 999px; margin-bottom: 10px; }
.lt-meter { margin: 12px auto 16px; max-width: 520px; }
.lt-track { position: relative; height: 16px; border-radius: 999px; background: var(--locked); }
.lt-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, #58cc02, #1cb0f6, var(--primary), #ff6bb5); transition: width 1.4s cubic-bezier(.2,.8,.2,1); }
.lt-marker { position: absolute; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: #fff; border: 5px solid var(--primary); box-shadow: 0 3px 0 rgba(0,0,0,.15); transition: left 1.4s cubic-bezier(.2,.8,.2,1); }
.lt-scale { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; margin-top: 10px; font-size: .78rem; font-weight: 800; color: var(--muted); }
.lt-seg { white-space: nowrap; }
.lt-seg.on { color: var(--primary); font-size: .9rem; }
.lt-seg.past { color: var(--text); }
.lt-summary { font-weight: 700; font-size: 1.05rem; max-width: 560px; margin: 0 auto 6px; }
.lt-card { text-align: left; margin-top: 16px; }
.lt-card h3 { margin-top: 0; }
.lt-skill { margin: 10px 0; }
.lt-skill-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.lt-levels { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.lt-lvl { background: var(--bg-soft); border: 2px solid var(--border); border-radius: 10px; padding: 4px 10px; font-weight: 700; font-size: .9rem; }
.lt-lvl.good { border-color: var(--success); background: var(--success-soft); }
.lt-next { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lt-next li { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.lt-next li .ic { color: var(--success); transform: rotate(90deg); flex: none; margin-top: 3px; }
.lt-review-toggle { margin-top: 18px; }
.lt-review { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 12px; text-align: left; }
.lt-rev { border: 2px solid var(--border); border-left-width: 6px; border-radius: 14px; padding: 12px 14px; background: var(--card); }
.lt-rev.right { border-left-color: var(--success); }
.lt-rev.wrong { border-left-color: var(--danger); }
.lt-rev-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.lt-rev-mark { display: grid; place-items: center; width: 22px; height: 22px; }
.lt-rev.wrong .lt-rev-mark { color: var(--danger); }
.lt-rev-listen { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 700; }
.lt-rev-prompt { font-size: 1.1rem; font-weight: 700; line-height: 2; }
.lt-rev-yours { color: var(--danger); font-weight: 700; }
.lt-rev-answer { color: var(--success-dark); font-weight: 700; }
.lt-rev-why { margin: 6px 0 0; color: var(--muted); font-weight: 600; }
.lt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.lt-actions .btn.wide { margin-top: 0; }
.level-test-card {
  width: 100%; display: flex; align-items: center; gap: 16px; text-align: left; margin: 0 0 16px;
  background: linear-gradient(120deg, #2a1a6e, #5b3fd9 60%, #8f74ff); color: #fff;
  border: none; border-radius: 20px; padding: 18px 20px; box-shadow: 0 5px 0 #1d1250; position: relative; overflow: hidden;
}
.level-test-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.18) 50%, transparent 60%); transform: translateX(-100%); animation: ac-shine 4s 1s ease-in-out infinite; }
.level-test-card h3 { margin: 2px 0 4px; font-size: 1.25rem; }
.level-test-card p { margin: 0; color: rgba(255,255,255,.88); font-weight: 600; }
.level-test-card:active { transform: translateY(3px); box-shadow: 0 2px 0 #1d1250; }
.ltc-badge { flex: none; display: grid; animation: ac-icon-bob 2.4s ease-in-out infinite; }
.ltc-kicker { font-size: .72rem; font-weight: 900; letter-spacing: .12em; background: #ffc800; color: #5a3b00; padding: 2px 8px; border-radius: 999px; }
.ltc-go { margin-left: auto; transform: rotate(180deg); opacity: .85; }
.ltc-go .ic { color: #fff; }
.stat-link { background: var(--card); color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.stat-link:hover { background: var(--bg-soft); }
.app-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.app-row p { margin: 2px 0 0; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- version (Settings) ---------- */
.version-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px solid var(--border); }
.version-row:last-of-type { border-bottom: none; }
.version-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.version-main .muted { word-break: break-all; }
.version-note { margin: 8px 0 4px; }
.badge {
  font-size: 0.72rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; flex-shrink: 0;
}
.badge.up-to-date { background: var(--success-soft); color: var(--success); }
.badge.update { background: var(--danger-soft); color: var(--danger); animation: badge-pulse 1.6s ease-in-out infinite; }
.badge.muted { background: var(--bg-soft); color: var(--muted); }
@keyframes badge-pulse { 50% { transform: scale(1.06); } }
/* Dot on the Settings sidebar button when an update is available */
.nav-dot { position: relative; display: inline-block; width: 0; height: 0; }
.nav-dot .dot {
  position: absolute; top: -2px; right: -10px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--card);
}

/* ---------- reports ---------- */
.report-btn { color: var(--muted); flex-shrink: 0; }
.report-btn:hover { color: var(--danger); }
/* Difficult words (lightning bolt) */
.hard-btn { flex-shrink: 0; }
.hard-btn .ic { filter: grayscale(1); opacity: 0.35; transition: opacity 0.15s, filter 0.15s, transform 0.15s; }
.hard-btn:hover .ic { opacity: 0.7; }
.hard-btn.on .ic { filter: none; opacity: 1; transform: scale(1.1); }
.hard-count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; margin-left: 8px;
  border-radius: 999px; background: var(--gold); color: #fff; font-size: 0.8rem; font-weight: 900; vertical-align: middle;
}
.hard-banner {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  background: color-mix(in srgb, var(--gold) 16%, var(--card)); border-radius: 16px; padding: 12px 18px;
  animation: card-in 0.5s 0.75s both cubic-bezier(.3, 1.5, .5, 1);
}
.hard-banner b { display: block; }
.hard-banner p { margin: 2px 0 0; color: var(--muted); font-weight: 600; }
.hard-banner-icon { flex-shrink: 0; line-height: 0; }
.report-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.report-head h2 { margin: 0; }
.report-head p { margin: 2px 0 0; }
.report-badge {
  width: 52px; height: 52px; border-radius: 16px; flex-shrink: 0;
  background: var(--danger-soft); display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--border);
}
.report-cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 12px; }
.report-cat {
  border: 2px solid var(--border); background: var(--card); border-radius: 14px;
  padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 3px 0 var(--border); text-align: center;
}
.report-cat b { font-size: 0.85rem; }
.report-cat span { font-size: 0.72rem; color: var(--muted); font-weight: 700; line-height: 1.3; }
.report-cat.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 3px 0 var(--primary); }
.report-cat:hover { background: var(--bg-soft); }
.report-cat.active:hover { background: var(--primary-soft); }
.report-message { resize: vertical; min-height: 78px; }
.report-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.report-line { margin-top: 6px; font-size: 0.78rem; display: inline-flex; align-items: center; gap: 4px; }
.line-main { flex: 1; min-width: 0; }
.report-link {
  margin-top: 10px; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(255,255,255,0.16); color: inherit; border: 2px solid rgba(255,255,255,0.45);
  border-radius: 10px; padding: 8px 10px; font-weight: 800; font-size: 0.82rem;
}
.node-pop.locked .report-link { border-color: var(--border); }
.node-pop:not(.locked):hover .report-link { background: rgba(255,255,255,0.24); }
.report-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.report-row { position: relative; margin-bottom: 0; padding-right: 90px; }
.report-row-body { min-width: 0; }
.report-target { overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: 0.78rem; }
.report-msg { font-weight: 700; overflow-wrap: anywhere; }
.report-status {
  position: absolute; top: 12px; right: 12px;
  font-size: 0.72rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
}
.report-status.reviewed { background: var(--gold); color: #5a3b00; }
.report-status.fixed { background: var(--success-soft); color: var(--success); }
@media (max-width: 560px) {
  .report-cats { grid-template-columns: 1fr; }
  .report-cat { flex-direction: row; align-items: center; text-align: left; gap: 10px; }
  .report-cat span { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .report-cat.active { animation: none !important; }
}

/* Koto's daily plan and the Android companion controls. */
.daily-plan { display:flex; align-items:center; gap:20px; margin:20px 0; background:var(--primary-soft, #f4efff); }
.daily-plan > .koto { flex-shrink:0; }
.daily-plan-copy { min-width:0; }
.daily-plan h2 { font-size:1.2rem; margin:4px 0 8px; }
.daily-plan p { margin:6px 0 12px; }
.companion-kicker { font-size:.7rem; font-weight:900; letter-spacing:.09em; color:var(--primary); }
.companion-heading { display:flex; justify-content:space-between; align-items:center; gap:16px; }
.companion-heading h3 { margin-bottom:6px; }
.reminder-time { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:12px 0; }
.time-pick { display:flex; align-items:center; gap:6px; }
.time-colon { font-size:1.3rem; font-weight:900; color:var(--muted); }
.reminder-permission { padding:12px; border-radius:12px; background:var(--bg); margin:12px 0; }
.widget-previews { display:grid; grid-template-columns:repeat(auto-fill, minmax(190px,1fr)); gap:12px; margin:16px 0; }
/* Home-screen widget look-alikes. */
.wm { position:relative; width:100%; height:132px; border-radius:22px; overflow:hidden; padding:12px; text-align:left; box-sizing:border-box; display:flex; flex-direction:column; gap:6px; }
.wm-plum { background:linear-gradient(45deg, #5b3be2, #9a7bff); color:#fff; }
.wm-card { background:var(--card); border:1px solid var(--border); color:var(--text); }
.wm-big { font-size:1.9rem; font-weight:900; line-height:1; }
.wm-label { font-size:.75rem; font-weight:800; opacity:.9; margin-top:-4px; }
.wm-week { display:flex; gap:5px; }
.wm-week i { width:13px; height:13px; border-radius:50%; background:#fff; }
.wm-week i.off { background:transparent; box-shadow:inset 0 0 0 1.6px #ffffff80; }
.wm-week i.today { box-shadow:0 0 0 2px #5b3be2, 0 0 0 3.6px #fff; }
.wm-pill { align-self:flex-start; margin-top:auto; background:#fff; color:#6d44d7; font-size:.68rem; font-weight:800; padding:4px 10px; border-radius:12px; }
.wm-koto { position:absolute; right:-6px; bottom:-8px; }
.wm-row { display:flex; align-items:center; gap:8px; }
.wm-bubble { background:var(--card); border:1px solid var(--border); border-radius:14px 14px 14px 4px; padding:5px 9px; font-size:.72rem; font-weight:800; line-height:1.2; color:var(--text); }
.wm-ring { --p:50%; width:40px; height:40px; border-radius:50%; display:grid; place-items:center; flex:none; background:radial-gradient(closest-side, var(--card) 72%, transparent 74%), conic-gradient(#7c5cff, #ff6fae var(--p), var(--border) 0); }
.wm-ring b { font-size:.62rem; }
.wm-ring.big { width:92px; height:92px; margin:auto; align-content:center; gap:0; }
.wm-ring.big b { font-size:1.5rem; line-height:1; } .wm-ring.big small { font-size:.62rem; font-weight:800; opacity:.9; }
.wm-goal { justify-content:center; }
.wm-goal .wm-ring.big { background:radial-gradient(closest-side, #7756f0 76%, transparent 78%), conic-gradient(#ffd23f, #ff8fc7 var(--p), #ffffff40 0); }
.wm-small { font-size:.7rem; line-height:1.25; color:var(--muted); } .wm-small b { color:var(--text); }
.wm-button { margin-top:auto; text-align:center; background:linear-gradient(90deg, #6d44d7, #9a6bff); color:#fff; font-size:.72rem; font-weight:800; padding:6px 10px; border-radius:12px; }
.wm-word { flex-direction:row; align-items:center; }
.wm-text { display:flex; flex-direction:column; flex:1; min-width:0; }
.wm-text small { font-size:.6rem; font-weight:900; color:var(--primary); letter-spacing:.06em; }
.wm-text b { font-size:1.6rem; } .wm-text span { color:var(--primary); font-size:.75rem; } .wm-text em { font-style:normal; color:var(--muted); font-size:.75rem; }
.wm-reviews { height:62px; flex-direction:row; align-items:center; padding:8px 10px; margin:35px 0; }
.wm-reviews .wm-small { flex:1; } .wm-reviews .wm-button { margin:0; }
.wm-buddy { background:linear-gradient(180deg, #f6f1ff, #ddd0ff); align-items:center; justify-content:space-between; padding-bottom:0; }
.wm-buddy .wm-bubble { border-radius:14px; background:#fff; color:#292139; }
@media (prefers-color-scheme:dark) { .wm-buddy { background:linear-gradient(180deg, #2b2142, #3d2d66); } .wm-buddy .wm-bubble { background:#2d2540; color:#f6f0ff; } }
.wm-kicker { font-size:.62rem; font-weight:900; letter-spacing:.08em; text-transform:uppercase; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.wm-chip { background:var(--chip, #efe8ff); color:#6d44d7; font-size:.62rem; font-weight:800; padding:3px 8px; border-radius:10px; white-space:nowrap; }
.wm-quests { gap:5px; padding:10px 12px; } .wm-quests .wm-kicker { color:var(--primary); }
.wm-quest { display:flex; align-items:center; gap:7px; font-size:.68rem; }
.wm-quest > span { width:18px; text-align:center; } .wm-quest > div { flex:1; min-width:0; }
.wm-quest b { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wm-quest i { --p:50%; display:block; height:5px; margin-top:2px; border-radius:3px; background:linear-gradient(90deg, #ffc23d, #ff8a3d) 0 0 / var(--p) 100% no-repeat, var(--border); }
.wm-quest em { font-style:normal; font-weight:800; color:var(--muted); white-space:nowrap; } .wm-quest em.ready { color:#ff8a3d; }
.wm-league { background:linear-gradient(45deg, #221a46, #4b3896); color:#fff; } .wm-league .wm-kicker { opacity:.8; flex:none; }
.wm-rank { display:flex; align-items:center; justify-content:center; gap:8px; margin-top:4px; } .wm-rank b { font-size:1.9rem; font-weight:900; line-height:1; }
.wm-shield { --c:#c98a4b; width:30px; height:34px; display:grid; place-items:center; font-size:.9rem; color:#fff; background:linear-gradient(135deg, color-mix(in srgb, var(--c), #fff 35%), color-mix(in srgb, var(--c), #000 20%)); clip-path:polygon(50% 0, 100% 12%, 100% 50%, 50% 100%, 0 50%, 0 12%); }
.wm-league .wm-label { text-align:center; }
.wm-pill.glass { background:#ffffff33; color:#fff; }
@media (prefers-color-scheme:dark) { .wm-chip { background:#33284a; color:#c5aeff; } }
.koto-day { display:flex; justify-content:space-between; gap:6px; margin:14px 0 4px; padding:10px 12px; border-radius:18px; background:linear-gradient(90deg, #f1ebff, #ffe3ec); }
.koto-day figure { margin:0; display:flex; flex-direction:column; align-items:center; gap:2px; }
.koto-day figcaption { font-size:.7rem; font-weight:800; color:#6d44d7; }
@media (prefers-color-scheme:dark) { .koto-day { background:linear-gradient(90deg, #2b2142, #3d1f3a); } .koto-day figcaption { color:#c5aeff; } }
/* Post-lesson suggestion: a tiny phone where Koto's widget pops onto the home screen. */
.widget-promo { display:flex; gap:16px; align-items:center; text-align:left; margin:16px 0; padding:16px; border:2px solid color-mix(in srgb, var(--primary) 30%, var(--border)); animation:wp-in .5s .8s ease-out both; }
.widget-promo h3 { margin:0 0 4px; }
.wp-copy { flex:1; min-width:0; }
.wp-steps { margin:8px 0 0; padding-left:20px; font-size:.82rem; line-height:1.45; }
.wp-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.wp-phone { position:relative; flex:none; width:86px; height:150px; border-radius:18px; border:3px solid var(--text); background:linear-gradient(180deg, #cdbcff, #ffc9dc); overflow:hidden; }
.wp-apps { position:absolute; inset:auto 8px 12px; display:grid; grid-template-columns:repeat(4,1fr); gap:6px; }
.wp-apps i { aspect-ratio:1; border-radius:5px; background:#ffffffb3; }
.wp-widget { position:absolute; top:12px; left:8px; right:8px; height:62px; border-radius:12px; padding:5px 6px; box-sizing:border-box; background:linear-gradient(45deg, #5b3be2, #9a7bff); color:#fff; font-size:.72rem; display:flex; justify-content:space-between; align-items:flex-end; transform-origin:30% 30%; animation:wp-pop 4.2s ease-in-out infinite; }
.wp-widget b { align-self:flex-start; }
.wp-tap { position:absolute; top:34px; left:30px; width:18px; height:18px; border-radius:50%; background:#fff; box-shadow:0 0 0 3px #ffffff80; opacity:0; animation:wp-tap 4.2s ease-in-out infinite; }
@keyframes wp-in { from { opacity:0; transform:translateY(10px); } }
@keyframes wp-pop { 0%, 30% { opacity:0; transform:scale(.4); } 42% { opacity:1; transform:scale(1.08); } 50%, 92% { opacity:1; transform:scale(1); } 100% { opacity:0; transform:scale(1); } }
@keyframes wp-tap { 0%, 4% { opacity:0; transform:scale(.6); } 10%, 26% { opacity:.95; transform:scale(1); } 30%, 100% { opacity:0; transform:scale(1.8); } }
@media (prefers-reduced-motion: reduce) { .widget-promo, .wp-widget, .wp-tap { animation:none; } }
@media (max-width:480px) { .widget-promo { padding:12px; gap:12px; } .wp-phone { width:72px; height:128px; } }
.widget-preview { display:flex; flex-direction:column; align-items:center; text-align:center; gap:8px; padding:16px 10px; border:2px solid var(--border); border-radius:20px; background:var(--bg); }
.widget-preview .btn { white-space:normal; width:100%; margin-top:8px; }
@media (prefers-color-scheme:dark) { .daily-plan { background:#292039; } }
@media (max-width:480px) { .daily-plan { gap:12px; padding:16px; } .daily-plan > .koto { width:72px; height:auto; } .widget-previews { grid-template-columns:1fr; } }

/* English curriculum grades */
.grade-roadmap { max-width: 720px; margin: 8px auto 30px; padding: 20px; border: 2px solid var(--border); border-radius: 22px; background: var(--bg-soft); }
.grade-roadmap-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grade-roadmap-heading h1 { font-size: 1.4rem; line-height: 1.25; }
.grade-completion { font-weight: 800; color: var(--primary); }
.grade-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.grade-card { min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 7px; padding: 13px; border: 2px solid var(--border); border-radius: 14px; background: var(--card); box-shadow: 0 3px 0 var(--border); }
.grade-card.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 3px 0 var(--primary); }
.grade-card:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.grade-card-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; color: var(--primary); }
.grade-card-top > span { font-size: .65rem; font-weight: 800; }
.grade-card strong { font-size: .9rem; }
.grade-progress { height: 7px; background: var(--border); border-radius: 20px; overflow: hidden; display: block; }
.grade-progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.grade-detail { scroll-margin-top: 76px; max-width: 640px; margin: 0 auto 24px; padding: 20px; background: var(--primary-soft); border: 2px solid var(--primary); border-radius: 18px; }
.grade-detail ul { padding-left: 20px; line-height: 1.6; }
@media (max-width: 540px) {
  .grade-roadmap { padding: 14px; }
  .grade-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .grade-card { padding: 10px; }
  .grade-roadmap-heading h1 { font-size: 1.2rem; }
}

.language-picker { display: grid; gap: 8px; text-align: left; font-size: .9rem; font-weight: 800; margin: 8px 0 16px; }
.auth-card > .language-picker { max-width: 280px; margin: 0 auto 18px; }
.placement-recommendation { max-width: 640px; margin: 0 auto 24px; border: 2px solid var(--primary); }
.placement-recommendation p { overflow-wrap: anywhere; }

/* ---------- friends ---------- */
.friends h2, .user-profile h2 { margin: 18px 0 10px; }
.invite-card { display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, var(--primary-soft), var(--card) 70%); }
.invite-body { flex: 1; min-width: 0; }
.invite-body h2 { margin: 0 0 4px; }
.invite-body p { margin: 0 0 12px; }
.invite-body .btn.primary { display: inline-flex; align-items: center; gap: 6px; }
.invite-link { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.invite-link .field { flex: 1; min-width: 0; margin: 0; font-size: 0.85rem; padding: 10px 12px; color: var(--muted); }
@media (max-width: 460px) {
  .invite-card { flex-direction: column; text-align: center; }
  .invite-link { flex-direction: column; align-items: stretch; }
}
.card-head h3 { display: inline-flex; align-items: center; gap: 6px; }
.fs-empty { margin: 4px 0; }
.fs-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 2px solid var(--border); }
.fs-row:first-of-type { border-top: none; }
.fs-avatar { background: none; border: none; padding: 0; }
.fs-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-today { display: flex; gap: 4px; }
.fs-dot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--locked); flex-shrink: 0; }
.fs-dot .ic { opacity: 0.6; }
.fs-dot.on { background: var(--success); }
.fs-dot.on .ic { opacity: 1; }
.fs-days { display: inline-flex; align-items: center; gap: 2px; font-weight: 900; color: var(--muted); min-width: 48px; justify-content: flex-end; }
.fs-days .ic { filter: grayscale(1); opacity: 0.55; }
.fs-days.lit { color: #ff9600; }
.fs-days.lit .ic { filter: none; opacity: 1; }
.fs-suggest { margin-top: 10px; border-top: 2px solid var(--border); padding-top: 8px; }
.fs-suggest p { margin: 0 0 8px; }
.fs-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fs-chip { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--border); background: var(--card); border-radius: 999px; padding: 3px 12px 3px 3px; font-weight: 800; color: var(--text); box-shadow: 0 2px 0 var(--border); }
.fs-chip b { color: var(--primary); font-size: 1.1rem; line-height: 1; }
.fs-chip:active { transform: translateY(2px); box-shadow: none; }
.friends-tabs { margin: 0 0 8px; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-radius: 14px; cursor: pointer; }
.friend-row:hover { background: var(--bg-soft); }
.friend-av { position: relative; display: inline-flex; }
.friend-done { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--success); border: 2px solid var(--card); display: grid; place-items: center; }
.friend-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.friend-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 0.72rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.03em; }
.friend-streak { display: inline-flex; align-items: center; gap: 2px; font-weight: 900; color: var(--muted); }
.friend-streak .ic { filter: grayscale(1); opacity: 0.55; }
.friend-streak.lit { color: #ff9600; }
.friend-streak.lit .ic { filter: none; opacity: 1; }
.btn.nudge { display: inline-flex; align-items: center; gap: 4px; padding: 7px 10px; }
@media (max-width: 520px) { .nudge-label { display: none; } }
.friends-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 16px 8px; }
.friends-empty p { margin: 0; max-width: 360px; }
.user-head-main { flex: 1; min-width: 0; }
.user-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.user-streak { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.user-streak p { flex: 1; margin: 0; font-weight: 800; }
.invite-banner { display: flex; align-items: center; justify-content: center; gap: 6px; }
.friends-mini .mini-friend { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.mf-name { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-requests { display: block; width: 100%; border: none; margin: 4px 0 8px; cursor: pointer; }
.board-tabs { max-width: 640px; margin: 16px auto 0; }
.league-row.clickable { cursor: pointer; }
.league-row.clickable:hover { background: var(--bg-soft); }
.profile-friends { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin-top: 16px; color: var(--text); font: inherit; cursor: pointer; }
.profile-friends div { flex: 1; display: flex; flex-direction: column; }
.profile-friends:hover { background: var(--bg-soft); }
.pf-go { transform: rotate(90deg); opacity: 0.6; }
.auth-invite { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--primary-soft); border-radius: 14px; padding: 10px 14px; margin: 12px 0 0; }
.auth-invite div { display: flex; flex-direction: column; }
.auth-invite b { color: var(--primary); }

/* ---------- friends: motion ---------- */
/* Lists slide in one after another. */
.friends > .card { animation: slide-up 0.45s both; }
.friends > .card:nth-child(2) { animation-delay: 0.06s; }
.friends > .card:nth-child(3) { animation-delay: 0.12s; }
.friends > .card:nth-child(4) { animation-delay: 0.18s; }
.friend-row, .fs-row, .mini-friend, .fs-chip { animation: slide-up 0.4s both; }
.friend-row:nth-child(2), .fs-row:nth-of-type(2), .mini-friend:nth-of-type(2), .fs-chip:nth-child(2) { animation-delay: 0.05s; }
.friend-row:nth-child(3), .fs-row:nth-of-type(3), .mini-friend:nth-of-type(3), .fs-chip:nth-child(3) { animation-delay: 0.1s; }
.friend-row:nth-child(4), .fs-row:nth-of-type(4), .mini-friend:nth-of-type(4), .fs-chip:nth-child(4) { animation-delay: 0.15s; }
.friend-row:nth-child(n+5), .fs-row:nth-of-type(n+5), .mini-friend:nth-of-type(n+5), .fs-chip:nth-child(n+5) { animation-delay: 0.2s; }
.friend-row { transition: background 0.15s, transform 0.18s cubic-bezier(.3, 1.5, .5, 1); }
.friend-row:hover { transform: translateX(3px); }
.friend-row .avatar-c, .fs-avatar .avatar-c { transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1); }
.friend-row:hover .avatar-c, .fs-avatar:hover .avatar-c { transform: scale(1.08) rotate(-3deg); }
.fs-chip { transition: transform 0.18s cubic-bezier(.3, 1.6, .5, 1); }
.fs-chip:hover { transform: translateY(-2px) scale(1.03); }
.fs-chip:hover b { animation: chip-plus 0.5s; }
@keyframes chip-plus { 50% { transform: rotate(90deg) scale(1.3); } }

/* Live streak flames flicker; done-today checks pop in. */
.fs-days.lit .ic, .friend-streak.lit .ic { transform-origin: 50% 90%; animation: flame-flicker 1.6s ease-in-out infinite; }
@keyframes flame-flicker {
  0%, 100% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.08, 0.95) rotate(-4deg); }
  50% { transform: scale(0.96, 1.07) rotate(3deg); }
  75% { transform: scale(1.04, 0.98) rotate(-2deg); }
}
.fs-dot.on { animation: dot-pop 0.5s 0.2s both cubic-bezier(.3, 1.8, .5, 1); }
@keyframes dot-pop { from { transform: scale(0); } }
.friend-done { animation: dot-pop 0.5s 0.3s both cubic-bezier(.3, 1.8, .5, 1); }

/* The invite card. */
.invite-card .koto { animation: float 3s ease-in-out infinite; }
.invite-body .btn.primary { position: relative; overflow: hidden; }
.invite-body .btn.primary::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: shine 3.2s ease-in-out 1s infinite;
}
@keyframes shine { 0% { left: -60%; } 35%, 100% { left: 130%; } }
.invite-body .btn.primary .ic { animation: wiggle 2.6s ease-in-out infinite; }
.auth-invite { animation: slide-up 0.5s 0.1s both; }
.auth-invite .avatar-c { animation: avatar-pop 0.6s 0.35s both cubic-bezier(.3, 1.7, .5, 1); }
@keyframes avatar-pop { from { transform: scale(0.3) rotate(-15deg); opacity: 0; } }

/* Sparks fly out from the middle of their parent. */
.sparks { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 2; }
.sparks i {
  position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--c);
  animation: spark-fly 0.8s cubic-bezier(.2, .7, .3, 1) both;
}
.sparks i:nth-child(3n) { border-radius: 2px; width: 7px; height: 7px; }
@keyframes spark-fly {
  0% { transform: rotate(var(--a)) translateY(0) scale(0.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(-1 * var(--dist))) scale(0.2); opacity: 0; }
}

/* Following someone: their avatar bounces with a burst. */
.friend-av, .user-avatar { position: relative; display: inline-flex; }
.just-followed .friend-av .avatar-c, .user-avatar.just-followed .avatar-c { animation: follow-bounce 0.7s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes follow-bounce { 0% { transform: scale(1); } 30% { transform: scale(1.25) rotate(-6deg); } 60% { transform: scale(0.94) rotate(3deg); } 100% { transform: scale(1); } }
.row-sparks i { --dist: 40px; }
.follow-pop {
  position: fixed; left: 50%; bottom: 88px; z-index: 120; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; width: min(420px, calc(100vw - 32px));
  background: var(--card); border: 2px solid var(--border); border-radius: 18px; padding: 10px 16px 10px 10px;
  box-shadow: 0 10px 30px rgba(40, 25, 90, 0.22), 0 4px 0 var(--border); cursor: pointer;
  animation: follow-pop-in 0.55s cubic-bezier(.3, 1.5, .5, 1) both, follow-pop-out 0.35s ease-in 2.25s forwards;
}
@media (min-width: 760px) { .follow-pop { bottom: 28px; } }
@keyframes follow-pop-in { from { transform: translate(-50%, 40px) scale(0.85); opacity: 0; } }
@keyframes follow-pop-out { to { transform: translate(-50%, 24px) scale(0.95); opacity: 0; } }
.fp-avatar { position: relative; display: inline-flex; animation: avatar-pop 0.6s 0.1s both cubic-bezier(.3, 1.7, .5, 1); }
.fp-check { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%; background: var(--success); border: 2px solid var(--card); display: grid; place-items: center; animation: dot-pop 0.45s 0.45s both cubic-bezier(.3, 1.8, .5, 1); }
.fp-sparks i { --dist: 46px; animation-delay: 0.25s !important; }
.fp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fp-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-heart { animation: heart-beat 0.9s 0.5s ease-in-out 2 both; }
@keyframes heart-beat { 0%, 100% { transform: scale(1); } 20% { transform: scale(1.3); } 40% { transform: scale(0.95); } 60% { transform: scale(1.15); } }

/* Nudge and cheer: the hand waves and an emoji floats up. */
.nudge-wrap { position: relative; display: inline-flex; }
.btn.nudge .nudge-ic { display: inline-flex; transform-origin: 70% 90%; }
.btn.nudge:not(:disabled):hover .nudge-ic { animation: hand-wave 0.9s ease-in-out; }
.btn.nudge.sent-anim .nudge-ic { animation: hand-wave 0.9s ease-in-out 2; }
@keyframes hand-wave { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-18deg); } 40% { transform: rotate(14deg); } 60% { transform: rotate(-10deg); } 80% { transform: rotate(6deg); } }
.nudge-fly { position: absolute; left: 50%; top: -6px; pointer-events: none; animation: nudge-fly 1.2s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes nudge-fly {
  0% { transform: translate(-50%, 0) scale(0.5); opacity: 0; }
  20% { transform: translate(-50%, -14px) scale(1.2); opacity: 1; }
  100% { transform: translate(-30%, -60px) scale(0.9) rotate(12deg); opacity: 0; }
}

/* Friend notices show the friend: avatar with pulsing rings and a badge. */
.friend-notice-art { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px auto 10px; }
.fn-hero { position: relative; width: 150px; height: 150px; display: grid; place-items: center; }
.fn-avatar { position: relative; z-index: 1; display: inline-flex; animation: avatar-pop 0.65s 0.05s both cubic-bezier(.3, 1.6, .5, 1); }
.fn-avatar .avatar-c { box-shadow: 0 6px 0 var(--border-strong); }
.fn-ring { position: absolute; inset: 6px; border-radius: 50%; border: 3px solid var(--primary); opacity: 0; animation: ring-out 2.2s 0.4s ease-out infinite; }
.fn-ring2 { animation-delay: 1.5s; }
@keyframes ring-out { 0% { transform: scale(0.85); opacity: 0.55; } 100% { transform: scale(1.35); opacity: 0; } }
.fn-badge { position: absolute; right: -8px; bottom: 0; z-index: 2; background: var(--card); border-radius: 50%; padding: 6px; box-shadow: 0 4px 14px rgba(60, 40, 120, 0.2); animation: badge-in 0.7s 0.35s both cubic-bezier(.3, 1.6, .5, 1); }
.fn-badge.waving .ic { transform-origin: 70% 90%; animation: hand-wave 1s 1s ease-in-out 3; }
.fn-sparks i { animation-delay: 0.3s !important; --dist: 86px !important; }
.fn-others { display: flex; align-items: center; justify-content: center; }
.fn-other { margin-left: -8px; display: inline-flex; border-radius: 50%; box-shadow: 0 0 0 3px var(--card); animation: avatar-pop 0.5s both cubic-bezier(.3, 1.7, .5, 1); }
.fn-other:first-child { margin-left: 0; }
.fn-more { margin-left: 6px; font-weight: 900; color: var(--muted); animation: fade 0.4s 0.7s both; }

/* Friend Streak: two avatars meet and the flame lights. */
.duo { display: flex; align-items: center; justify-content: center; gap: 0; margin: 4px auto 6px; }
.duo-side { display: inline-flex; z-index: 1; }
.duo-side .avatar-c { box-shadow: 0 0 0 4px var(--card), 0 6px 0 var(--border-strong); }
.duo-left { animation: duo-left 0.7s cubic-bezier(.3, 1.4, .5, 1) both; }
.duo-right { animation: duo-right 0.7s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes duo-left { from { transform: translateX(-70px) rotate(-12deg); opacity: 0; } }
@keyframes duo-right { from { transform: translateX(70px) rotate(12deg); opacity: 0; } }
.duo-flame { position: relative; z-index: 2; margin: 0 -14px; display: grid; place-items: center; animation: flame-light 0.6s 0.55s both cubic-bezier(.3, 1.8, .5, 1); }
.duo-flame > .ic { position: relative; z-index: 1; transform-origin: 50% 90%; animation: flame-flicker 1.4s 1.2s ease-in-out infinite; filter: drop-shadow(0 4px 6px rgba(255, 120, 0, 0.35)); }
.duo-glow { position: absolute; width: 140%; height: 140%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 170, 40, 0.55), transparent 65%); animation: glow 2s 1s ease-in-out infinite; }
@keyframes flame-light { from { transform: scale(0) translateY(20px); opacity: 0; } }
@keyframes glow { 50% { transform: scale(1.2); opacity: 0.6; } }
.duo-sparks i { animation-delay: 0.7s !important; }
.streak-start { position: relative; text-align: center; overflow: hidden; }
.streak-start .confetti { position: absolute; z-index: 0; }
.streak-start > :not(.confetti) { position: relative; z-index: 1; }
.streak-start h2 { animation: slide-up 0.45s 0.8s both; }
.streak-start p { animation: slide-up 0.45s 0.9s both; }
.streak-start .btn { animation: slide-up 0.45s 1s both; }

/* Profile entry and the friends leaderboard. */
.profile-friends > .ic { transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1); }
.profile-friends:hover > .ic { transform: scale(1.12) rotate(-6deg); }
.profile-friends:hover .pf-go { transform: rotate(90deg) translateY(-3px); }
.pf-go { transition: transform 0.2s; }
.user-profile .profile-head .avatar-c { animation: avatar-pop 0.6s both cubic-bezier(.3, 1.6, .5, 1); }
.user-streak { animation: slide-up 0.45s 0.15s both; }

@media (prefers-reduced-motion: reduce) {
  .friends > .card, .friend-row, .fs-row, .mini-friend, .fs-chip, .fs-dot.on, .friend-done, .invite-card .koto,
  .invite-body .btn.primary::after, .invite-body .btn.primary .ic, .auth-invite, .auth-invite .avatar-c, .sparks,
  .fs-days.lit .ic, .friend-streak.lit .ic, .just-followed .avatar-c, .follow-pop, .fp-avatar, .fp-check, .fp-heart,
  .nudge-ic, .nudge-fly, .friend-notice-art *, .duo *, .streak-start *, .user-profile .avatar-c, .user-streak {
    animation: none !important;
  }
  .sparks, .nudge-fly, .fn-ring { display: none; }
  .follow-pop { animation: fade 0.2s both !important; }
}

/* Dropdowns (ui::Select). A chunky trigger plus a listbox popover that becomes
   a bottom sheet on phones. */
.kselect { position: relative; text-align: left; }
.ks-trigger {
  width: 100%; min-height: 50px; display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; border-radius: 14px; border: 2px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-weight: 800; font-size: 0.98rem;
  box-shadow: 0 3px 0 var(--border); cursor: pointer; text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.ks-trigger:hover:not(:disabled) { border-color: var(--border-strong); box-shadow: 0 3px 0 var(--border-strong); }
.ks-trigger:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--border-strong); }
.ks-trigger:focus-visible, .kselect.open .ks-trigger { outline: none; border-color: var(--primary); box-shadow: 0 3px 0 var(--primary); }
.ks-trigger:disabled { opacity: .6; cursor: progress; }
.ks-trigger .ks-lead { width: 28px; height: 28px; border-radius: 9px; }
.ks-value { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-chev {
  flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  background: var(--bg-soft); color: var(--muted); transition: transform .2s cubic-bezier(.3,1.4,.5,1), background .15s, color .15s;
}
.kselect.open .ks-chev { transform: rotate(180deg); background: var(--primary-soft); color: var(--primary); }
.ks-lead { flex: none; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--bg-soft); }
.ks-glyph { font-weight: 900; font-size: 0.85rem; color: var(--primary); letter-spacing: -0.02em; }
.ks-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--card) 70%, transparent), 0 0 0 5px var(--border); }
.ks-backdrop { position: fixed; inset: 0; z-index: 290; background: transparent; }
.ks-menu {
  position: absolute; z-index: 300; top: calc(100% + 8px); left: 0; min-width: 100%; width: max-content; max-width: min(360px, calc(100vw - 32px));
  max-height: 340px; overflow-y: auto; overscroll-behavior: contain; padding: 6px;
  background: var(--card); border: 2px solid var(--border); border-radius: 18px;
  box-shadow: 0 4px 0 var(--border), 0 22px 44px -18px rgba(40, 24, 110, .35);
  animation: ks-in .16s cubic-bezier(.2, 1.2, .4, 1); transform-origin: top left;
}
.ks-menu.up { top: auto; bottom: calc(100% + 8px); transform-origin: bottom left; animation-name: ks-in-up; }
.ks-menu.end { left: auto; right: 0; transform-origin: top right; }
@keyframes ks-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes ks-in-up { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.ks-sheet-head { display: none; }
.ks-opt {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; cursor: pointer;
  border: 2px solid transparent; font-weight: 800; user-select: none; transition: background .1s;
}
.ks-opt + .ks-opt { margin-top: 2px; }
.ks-opt.active { background: var(--bg-soft); }
.ks-opt.selected { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, transparent); color: var(--primary); }
.ks-opt.selected .ks-lead { background: var(--card); }
.ks-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ks-label { white-space: nowrap; }
.ks-hint { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.ks-check {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--border); margin-left: 8px; transition: transform .15s;
}
.ks-check .ic { opacity: 0; }
.ks-opt.selected .ks-check { background: var(--primary); border-color: var(--primary); box-shadow: 0 2px 0 var(--primary-dark); }
.ks-opt.selected .ks-check .ic { opacity: 1; }
.ks-num .ks-trigger { min-width: 86px; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.ks-num .ks-trigger .ks-lead { display: none; }
@media (max-width: 600px) {
  .ks-backdrop { background: rgba(20, 14, 40, .42); animation: ks-fade .2s ease; }
  .ks-menu, .ks-menu.up, .ks-menu.end {
    position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto; max-width: none; min-width: 0; max-height: 72vh; padding: 0 8px 10px; border-radius: 22px;
    animation: ks-sheet .26s cubic-bezier(.2, 1.1, .3, 1);
  }
  .ks-sheet-head {
    display: grid; justify-items: center; gap: 8px; position: sticky; top: 0; z-index: 1;
    padding: 8px 0 10px; background: var(--card); font-size: 0.95rem;
  }
  .ks-grip { width: 40px; height: 5px; border-radius: 9px; background: var(--border-strong); }
  .ks-opt { padding: 11px 12px; }
}
@keyframes ks-sheet { from { transform: translateY(110%); } }
@keyframes ks-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ks-menu, .ks-backdrop { animation: none; } }

/* ---------- treasure chest (src/chest.rs) ---------- */
/* A real 3D chest. Timeline, shared with the sounds in audio.rs:
   0 to 0.65 s it drops in, spinning to face you, and lands with a thud;
   0.75 to 1.25 s it rattles while the lid hops and light leaks out;
   1.3 s the lid swings open, light pours out and the treasure flies up. */
.c3-stage { position: relative; width: 300px; height: 300px; margin: 0 auto; }
.c3-scene { position: absolute; left: 50%; bottom: 46px; width: 0; height: 0; perspective: 900px; perspective-origin: 50% -160px; z-index: 2; }
.c3-move { position: absolute; left: 0; top: -39px; width: 0; height: 0; transform-style: preserve-3d; transform-origin: 0 39px;
  animation: c3-drop .65s both, c3-rattle .5s .75s ease-in, c3-pop .45s 1.3s cubic-bezier(.3,1.6,.5,1); }
.c3 { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(-26deg);
  animation: c3-turn .65s cubic-bezier(.2,.8,.3,1) both; }
.c3-body, .c3-lid { position: absolute; left: 0; width: 0; height: 0; transform-style: preserve-3d; }
.c3-body { top: 0; }
.c3-lid { transform: translateZ(-48px) rotateX(0deg);
  animation: c3-hops .5s .75s ease-in-out, c3-open .62s 1.3s forwards; }
.c3-face { position: absolute; left: 0; top: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.c3-face svg { display: block; width: 100%; height: 100%; }
.c3-left { filter: brightness(.72); }
.c3-right { filter: brightness(.86); }
.c3-back { filter: brightness(.7); }
.c3-end { filter: brightness(.8); }
.c3-lid-inside { filter: brightness(.55); animation: c3-lit .4s 1.3s ease-out forwards; }
.c3-inside { animation: c3-leak .5s .75s ease-in, c3-inside-glow .9s 1.3s ease-out forwards; filter: brightness(.6); }
/* The soft shadow on the ground. */
.c3-shadow { position: absolute; left: -100px; top: -14px; width: 200px; height: 28px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,.45), rgba(0,0,0,0) 70%); animation: c3-shadow .65s both; }

@keyframes c3-drop {
  0% { transform: translateY(-340px); animation-timing-function: cubic-bezier(.5,0,.9,.5); }
  58% { transform: translateY(0) scale(1); animation-timing-function: ease-out; }
  70% { transform: scale(1.14, .84); animation-timing-function: ease-in-out; }
  86% { transform: translateY(-10px) scale(.96, 1.05); animation-timing-function: ease-in; }
  100% { transform: none; }
}
@keyframes c3-turn { from { transform: rotateX(-24deg) rotateY(-120deg); } to { transform: rotateX(-24deg) rotateY(-26deg); } }
@keyframes c3-shadow { 0% { transform: scale(.25); opacity: 0; } 58% { transform: scale(1); opacity: 1; } 70% { transform: scale(1.12, 1); } 100% { transform: none; } }
@keyframes c3-rattle {
  0%, 100% { transform: none; }
  12% { transform: rotate(-2deg); }
  24% { transform: rotate(2.2deg); }
  40% { transform: rotate(-3deg) translateY(-3px); }
  54% { transform: rotate(3.2deg); }
  68% { transform: rotate(-4deg) translateY(-5px); }
  80% { transform: rotate(4deg) translateY(-2px); }
  92% { transform: rotate(-2deg) translateY(-6px); }
}
/* Three hops of the lid, each a little higher, as if something inside wants out. */
@keyframes c3-hops {
  0%, 14%, 40%, 66%, 100% { transform: translateZ(-48px) rotateX(0deg); }
  6% { transform: translateZ(-48px) rotateX(7deg); }
  28% { transform: translateZ(-48px) rotateX(11deg); }
  54% { transform: translateZ(-48px) rotateX(15deg); }
  86% { transform: translateZ(-48px) rotateX(9deg); }
}
@keyframes c3-open {
  0% { transform: translateZ(-48px) rotateX(0deg); animation-timing-function: cubic-bezier(.2,.7,.3,1); }
  55% { transform: translateZ(-48px) rotateX(128deg); animation-timing-function: ease-in-out; }
  78% { transform: translateZ(-48px) rotateX(104deg); animation-timing-function: ease-in-out; }
  100% { transform: translateZ(-48px) rotateX(112deg); }
}
@keyframes c3-pop { 0% { transform: scale(1.08, .9); } 45% { transform: scale(.97, 1.05) translateY(-6px); } 100% { transform: none; } }
@keyframes c3-lit { to { filter: brightness(1.15) sepia(.4) saturate(1.6); } }
@keyframes c3-leak { 0%, 14%, 40%, 66%, 100% { filter: brightness(.9); } 6% { filter: brightness(1.6); } 28% { filter: brightness(1.9); } 54% { filter: brightness(2.3); } 86% { filter: brightness(2); } }
@keyframes c3-inside-glow { 0% { filter: brightness(.6); } 25% { filter: brightness(1.7); } 100% { filter: brightness(1.02); } }

/* Light: rays behind, a halo, the column of light pouring out and the flash. */
.c3-rays { position: absolute; left: 50%; top: 40%; width: 420px; height: 420px; margin: -210px 0 0 -210px; border-radius: 50%; z-index: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255,224,102,.28) 0deg 9deg, transparent 9deg 22.5deg);
  -webkit-mask: radial-gradient(circle, #000 22%, transparent 66%); mask: radial-gradient(circle, #000 22%, transparent 66%);
  animation: ac-spin 16s linear infinite, c3-fade-in .8s 1.45s ease-out backwards; }
.c3-halo { position: absolute; left: 50%; top: 40%; width: 230px; height: 230px; margin: -115px 0 0 -115px; border-radius: 50%; z-index: 0;
  background: radial-gradient(circle, rgba(255,224,102,.75), rgba(255,224,102,0) 68%); filter: blur(6px);
  animation: c3-fade-in .6s 1.35s ease-out backwards, ac-pulse 2.4s 2s ease-in-out infinite; }
@keyframes c3-fade-in { from { opacity: 0; transform: scale(.3); } }
.c3-beam { position: absolute; left: 50%; bottom: 112px; width: 230px; height: 240px; margin-left: -115px; z-index: 3; pointer-events: none;
  transform-origin: 50% 100%; clip-path: polygon(0 0, 100% 0, 72% 100%, 28% 100%); mix-blend-mode: screen;
  background: linear-gradient(to top, rgba(255,246,200,0) 0, rgba(255,246,200,.7) 22%, rgba(255,224,102,.3) 55%, rgba(255,224,102,0));
  opacity: 0; animation: c3-beam .55s 1.36s cubic-bezier(.2,.9,.3,1) forwards, c3-beam-pulse 2s 1.95s ease-in-out infinite; }
@keyframes c3-beam { from { opacity: 0; transform: scaleY(0) scaleX(.3); } to { opacity: .7; transform: none; } }
@keyframes c3-beam-pulse { 0%, 100% { opacity: .7; } 50% { opacity: .45; } }
.c3-flash { position: absolute; inset: -120px; z-index: 4; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 62%, #fff 0, rgba(255,244,200,.85) 14%, rgba(255,224,102,0) 50%);
  animation: ac-flash .7s 1.3s ease-out; }
