/* ========= Material You tokens (tonal palette from a seed hue via OKLCH) ========= */
:root { --h: 165; --font-display: 'Bricolage Grotesque', 'Roboto Flex', system-ui, sans-serif; }

:root, [data-hue] {
  --primary: oklch(0.47 0.115 var(--h));
  --on-primary: oklch(0.99 0.01 var(--h));
  --primary-container: oklch(0.90 0.07 var(--h));
  --on-primary-container: oklch(0.27 0.08 var(--h));
  --secondary: oklch(0.50 0.04 var(--h));
  --secondary-container: oklch(0.91 0.035 var(--h));
  --on-secondary-container: oklch(0.27 0.03 var(--h));
  --tertiary: oklch(0.52 0.11 calc(var(--h) + 70));
  --tertiary-container: oklch(0.91 0.06 calc(var(--h) + 70));
  --on-tertiary-container: oklch(0.28 0.07 calc(var(--h) + 70));
  --surface: oklch(0.984 0.008 var(--h));
  --surface-container-lowest: oklch(1 0 0);
  --surface-container-low: oklch(0.966 0.012 var(--h));
  --surface-container: oklch(0.951 0.015 var(--h));
  --surface-container-high: oklch(0.936 0.017 var(--h));
  --surface-container-highest: oklch(0.92 0.019 var(--h));
  --on-surface: oklch(0.23 0.012 var(--h));
  --on-surface-variant: oklch(0.43 0.022 var(--h));
  --outline: oklch(0.62 0.022 var(--h));
  --outline-variant: oklch(0.85 0.018 var(--h));
  --inverse-surface: oklch(0.30 0.012 var(--h));
  --inverse-on-surface: oklch(0.95 0.01 var(--h));
  --fig-near: var(--primary);
  --fig-far: oklch(0.74 0.075 var(--h));
  --fig-shadow: oklch(0.47 0.10 var(--h) / 0.12);
  --scrim: oklch(0.1 0.01 var(--h) / 0.4);
  --shadow-1: 0 1px 2px oklch(0.2 0.02 var(--h) / .12), 0 1px 3px 1px oklch(0.2 0.02 var(--h) / .07);
  --shadow-3: 0 4px 8px 3px oklch(0.2 0.02 var(--h) / .10), 0 1px 3px oklch(0.2 0.02 var(--h) / .15);
  --group-item: var(--surface-container-lowest);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]), :root:not([data-theme="light"]) [data-hue] {
    --primary: oklch(0.83 0.10 var(--h));
    --on-primary: oklch(0.30 0.07 var(--h));
    --primary-container: oklch(0.37 0.085 var(--h));
    --on-primary-container: oklch(0.92 0.055 var(--h));
    --secondary: oklch(0.80 0.035 var(--h));
    --secondary-container: oklch(0.36 0.03 var(--h));
    --on-secondary-container: oklch(0.91 0.03 var(--h));
    --tertiary: oklch(0.82 0.09 calc(var(--h) + 70));
    --tertiary-container: oklch(0.38 0.08 calc(var(--h) + 70));
    --on-tertiary-container: oklch(0.92 0.05 calc(var(--h) + 70));
    --surface: oklch(0.165 0.01 var(--h));
    --surface-container-lowest: oklch(0.13 0.008 var(--h));
    --surface-container-low: oklch(0.205 0.012 var(--h));
    --surface-container: oklch(0.225 0.014 var(--h));
    --surface-container-high: oklch(0.26 0.016 var(--h));
    --surface-container-highest: oklch(0.295 0.018 var(--h));
    --on-surface: oklch(0.92 0.01 var(--h));
    --on-surface-variant: oklch(0.79 0.02 var(--h));
    --outline: oklch(0.62 0.02 var(--h));
    --outline-variant: oklch(0.38 0.018 var(--h));
    --inverse-surface: oklch(0.92 0.01 var(--h));
    --inverse-on-surface: oklch(0.25 0.01 var(--h));
    --fig-far: oklch(0.56 0.07 var(--h));
    --fig-shadow: oklch(0 0 0 / 0.3);
    --group-item: var(--surface-container-high);
  }
}
:root[data-theme="dark"], :root[data-theme="dark"] [data-hue] {
  --primary: oklch(0.83 0.10 var(--h));
  --on-primary: oklch(0.30 0.07 var(--h));
  --primary-container: oklch(0.37 0.085 var(--h));
  --on-primary-container: oklch(0.92 0.055 var(--h));
  --secondary: oklch(0.80 0.035 var(--h));
  --secondary-container: oklch(0.36 0.03 var(--h));
  --on-secondary-container: oklch(0.91 0.03 var(--h));
  --tertiary: oklch(0.82 0.09 calc(var(--h) + 70));
  --tertiary-container: oklch(0.38 0.08 calc(var(--h) + 70));
  --on-tertiary-container: oklch(0.92 0.05 calc(var(--h) + 70));
  --surface: oklch(0.165 0.01 var(--h));
  --surface-container-lowest: oklch(0.13 0.008 var(--h));
  --surface-container-low: oklch(0.205 0.012 var(--h));
  --surface-container: oklch(0.225 0.014 var(--h));
  --surface-container-high: oklch(0.26 0.016 var(--h));
  --surface-container-highest: oklch(0.295 0.018 var(--h));
  --on-surface: oklch(0.92 0.01 var(--h));
  --on-surface-variant: oklch(0.79 0.02 var(--h));
  --outline: oklch(0.62 0.02 var(--h));
  --outline-variant: oklch(0.38 0.018 var(--h));
  --inverse-surface: oklch(0.92 0.01 var(--h));
  --inverse-on-surface: oklch(0.25 0.01 var(--h));
  --fig-far: oklch(0.56 0.07 var(--h));
  --fig-shadow: oklch(0 0 0 / 0.3);
  --group-item: var(--surface-container-high);
}

/* ========= Base ========= */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--surface); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--on-surface);
  font-family: 'Roboto Flex', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
.ms {
  font-family: 'Material Symbols Rounded';
  font-weight: normal; font-style: normal;
  font-size: 24px; line-height: 1; letter-spacing: normal;
  display: inline-block; white-space: nowrap; direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 450, 'opsz' 24;
  -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga';
  user-select: none; flex: none;
}
.ms.filled { font-variation-settings: 'FILL' 1, 'wght' 500, 'opsz' 24; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ========= Views ========= */
#app { max-width: 720px; margin: 0 auto; }
.view { display: none; min-height: 100dvh; }
.view.active { display: block; animation: view-in .38s cubic-bezier(.2,0,0,1) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
#view-home, #view-detail, #view-done {
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ========= Ripple / state layer ========= */
.ripple { position: relative; overflow: hidden; isolation: isolate; }
.ripple::before {
  content: ''; position: absolute; inset: 0; background: currentColor; opacity: 0;
  transition: opacity .2s; pointer-events: none; border-radius: inherit; z-index: -1;
}
@media (hover: hover) { .ripple:hover::before { opacity: .08; } }
.ripple:active::before { opacity: .12; }
.ripple-wave {
  position: absolute; border-radius: 50%; background: currentColor; opacity: .16;
  transform: scale(0); animation: ripple .55s cubic-bezier(.2,0,0,1) forwards; pointer-events: none; z-index: -1;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ========= Top app bar ========= */
.top-bar { padding: 8px 4px 12px; }
.top-bar-row { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; letter-spacing: .01em; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
  border-radius: 12px 12px 12px 4px;
}
.brand-mark .ms { font-size: 22px; }
.brand-mark { background: var(--primary-container); overflow: hidden; }
.brand-mark .critter { width: 42px; height: 42px; margin-top: 4px; }

/* ========= Buttons ========= */
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; display: inline-grid; place-items: center;
  color: var(--on-surface-variant); flex: none;
}
.icon-btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.icon-btn.big { width: 64px; height: 64px; border-radius: 24px; }
.icon-btn.big .ms { font-size: 30px; }
.btn {
  height: 48px; padding: 0 24px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; letter-spacing: .01em;
}
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.text { color: var(--primary); padding: 0 14px; }
.fab-ext {
  height: 64px; padding: 0 28px 0 22px; border-radius: 20px; gap: 12px; font-size: 17px;
  background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-3);
  display: inline-flex; align-items: center; font-weight: 650;
}
.fab-ext .ms { font-size: 28px; }

/* ========= Week streak card ========= */
.week-card {
  background: var(--surface-container-low); border-radius: 28px; padding: 14px 14px 14px 14px;
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.streak { display: flex; align-items: center; gap: 12px; min-width: 0; white-space: nowrap; }
.streak-icon {
  width: 48px; height: 48px; display: grid; place-items: center; flex: none;
  background: var(--tertiary-container); color: var(--on-tertiary-container);
  border-radius: 16px;
}
.streak b { display: block; font-size: 20px; font-weight: 650; line-height: 1.1; }
.streak small { color: var(--on-surface-variant); font-size: 13px; display: block; white-space: normal; line-height: 1.25; }
.streak > div:last-child { min-width: 0; }
.week-dots { margin-left: auto; display: flex; gap: 4px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--on-surface-variant); font-weight: 600; }
.wd i {
  width: 22px; height: 22px; border-radius: 50%; display: block; background: var(--surface-container-highest);
  display: grid; place-items: center;
}
.wd i .ms { font-size: 15px; }
.wd.done i { background: var(--primary); color: var(--on-primary); }
.wd.today span { color: var(--primary); }
.wd.today i { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ========= Hero ========= */
.section-label { font-size: 14px; font-weight: 600; color: var(--on-surface-variant); margin: 0 4px 10px; letter-spacing: .02em; }
.hero {
  display: block; width: 100%; text-align: left;
  background: var(--primary-container); color: var(--on-primary-container);
  border-radius: 32px; padding: 20px; position: relative; overflow: hidden;
  min-height: 236px;
}
.hero::after {
  content: ''; position: absolute; width: 260px; height: 260px; right: -60px; top: -40px;
  background: var(--primary); opacity: .1;
  clip-path: polygon(50% 0%, 61% 11%, 75% 7%, 79% 21%, 93% 25%, 89% 39%, 100% 50%, 89% 61%, 93% 75%, 79% 79%, 75% 93%, 61% 89%, 50% 100%, 39% 89%, 25% 93%, 21% 79%, 7% 75%, 11% 61%, 0% 50%, 11% 39%, 7% 25%, 21% 21%, 25% 7%, 39% 11%);
  border-radius: 40%;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hero-fig { position: absolute; right: -6px; bottom: -4px; width: 58%; max-width: 250px; z-index: 1; }
.hero-body { position: relative; z-index: 2; max-width: 56%; display: flex; flex-direction: column; min-height: 196px; }
.hero-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.hero-kicker .ms { font-size: 18px; }
.hero-title { font-size: 28px; line-height: 1.1; font-weight: 600; margin-top: 10px; font-variation-settings: 'wdth' 105, 'opsz' 40; letter-spacing: -.01em; }
.hero-meta { margin-top: 8px; font-size: 15px; opacity: .85; }
.hero-play {
  margin-top: auto; align-self: flex-start;
  height: 56px; padding: 0 22px 0 16px; border-radius: 18px; gap: 8px; display: inline-flex; align-items: center;
  background: var(--primary); color: var(--on-primary); font-weight: 650; font-size: 16px;
  box-shadow: var(--shadow-1);
}

/* ========= Chips ========= */
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 28px -16px 14px; padding: 2px 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 40px; padding: 0 16px; border-radius: 12px; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--outline-variant); color: var(--on-surface-variant); font-weight: 600; font-size: 14px;
  transition: background .2s, color .2s, border-color .2s, border-radius .25s;
}
.chip .ms { font-size: 18px; }
.chip[aria-selected="true"] {
  background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent;
  border-radius: 20px;
}

/* ========= Routine cards ========= */
.routine-list { display: grid; gap: 10px; }
.routine-card {
  display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 14px;
  width: 100%; text-align: left; padding: 10px 14px 10px 10px; border-radius: 24px;
  background: var(--surface-container-low);
  transition: border-radius .25s cubic-bezier(.2,0,0,1), transform .15s;
}
.routine-card:active { border-radius: 16px; transform: scale(.985); }
.rc-thumb {
  width: 76px; height: 76px; border-radius: 20px; background: var(--primary-container);
  display: grid; place-items: center; overflow: hidden;
}
.rc-thumb .fig { width: 100%; height: 100%; }
.rc-title { font-size: 17px; font-weight: 600; line-height: 1.2; }
.rc-meta { color: var(--on-surface-variant); font-size: 14px; margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rc-cat { color: var(--primary); font-weight: 600; }
.rc-dur {
  min-width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; text-align: center;
  background: var(--primary-container); color: var(--on-primary-container); font-weight: 700; font-size: 17px; line-height: 1;
}
.rc-dur small { display: block; font-size: 11px; font-weight: 600; opacity: .8; margin-top: 2px; }
.top-badge {
  display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px 0 5px; border-radius: 8px;
  background: var(--tertiary-container); color: var(--on-tertiary-container); font-size: 12px; font-weight: 700;
}
.top-badge .ms { font-size: 15px; }
.ranking { margin-top: 28px; }
.rank-hint {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: 24px;
  background: var(--surface-container); color: var(--on-surface-variant); font-size: 14px;
}
.rank-hint b { color: var(--on-surface); }
.rank-head { padding: 0 4px 12px; }
.rank-head h2 { font-size: 22px; font-weight: 600; font-variation-settings: 'wdth' 105, 'opsz' 32; letter-spacing: -.01em; }
.rank-head p { color: var(--on-surface-variant); font-size: 14px; margin-top: 4px; }
.rank-head b { color: var(--primary); }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rank-row {
  display: grid; grid-template-columns: 30px 56px 1fr; gap: 12px; align-items: center;
  padding: 8px 12px 8px 8px; border-radius: 20px; background: var(--surface-container-low);
}
.rank-row.is-top { background: var(--primary-container); color: var(--on-primary-container); }
.rank-n {
  width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums;
  background: var(--surface-container-highest); color: var(--on-surface-variant);
}
.rank-row.is-top .rank-n { background: var(--primary); color: var(--on-primary); }
.rank-thumb { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-container-high); overflow: hidden; }
.rank-row.is-top .rank-thumb { background: color-mix(in oklch, var(--surface) 55%, transparent); }
.rank-thumb .fig { width: 100%; height: 100%; }
.rank-text { min-width: 0; }
.rank-text b { display: block; font-weight: 600; font-size: 15px; line-height: 1.25; }
.rank-text small { display: block; font-size: 13px; line-height: 1.35; margin-top: 2px; opacity: .8; }
.rank-sep { display: flex; justify-content: center; padding: 8px 0 10px; }
.rank-sep .btn { height: 48px; }
.footnote { text-align: center; color: var(--on-surface-variant); font-size: 13px; margin-top: 28px; }

/* ========= Figure ========= */
.fig { display: block; width: 100%; height: auto; overflow: visible; }
.fig.fit { overflow: hidden; }
.fig.fit .fig-ground, .fig.fit .fig-shadow { display: none; }
.fig-limb { fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.fig-limb.near { stroke: var(--fig-near); }
.fig-limb.far { stroke: var(--fig-far); }
.fig-torso { fill: none; stroke: var(--fig-near); stroke-width: 14; stroke-linecap: round; }
.fig-head { fill: var(--fig-near); }
.fig-ground { stroke: var(--outline-variant); stroke-width: 2.5; stroke-linecap: round; }
.fig-shadow { fill: var(--fig-shadow); }
.fig-wall { stroke: var(--outline); stroke-width: 5; stroke-linecap: round; }
.fig-mat { fill: var(--surface-container-highest); opacity: .7; }
.fig-strap { stroke: var(--tertiary); stroke-width: 3; stroke-linecap: round; fill: none; stroke-dasharray: 2 5; }
.fig[data-view="front"] .fig-limb.near, .fig[data-view="top"] .fig-limb.near { stroke: var(--fig-near); }
.fig[data-view="front"] .fig-limb.far, .fig[data-view="top"] .fig-limb.far { stroke: var(--fig-near); }

/* ========= Detail ========= */
.detail-top { display: flex; align-items: center; justify-content: space-between; height: 64px; margin: 0 -4px; }
.detail-hero {
  background: var(--primary-container); color: var(--on-primary-container); border-radius: 32px;
  padding: 20px 20px 0; position: relative; overflow: hidden;
}
.detail-hero .kicker { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 6px; opacity: .85; }
.detail-hero .kicker .ms { font-size: 18px; }
.detail-hero h1 { font-size: clamp(30px, 8vw, 40px); line-height: 1.08; font-weight: 600; margin-top: 8px; font-variation-settings: 'wdth' 108, 'opsz' 48; letter-spacing: -.015em; }
.detail-hero p { margin-top: 10px; font-size: 16px; opacity: .9; max-width: 34em; }
.detail-stats { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 12px;
  background: color-mix(in oklch, var(--surface) 55%, transparent); font-weight: 600; font-size: 14px;
}
.stat-pill .ms { font-size: 18px; }
.detail-fig { width: 62%; max-width: 260px; margin: 0 auto -6px; }
.move-list { margin-top: 24px; display: grid; gap: 2px; counter-reset: mv; }
.move-list h3 { font-size: 14px; font-weight: 600; color: var(--on-surface-variant); margin: 0 4px 10px; }
.move-row {
  display: grid; grid-template-columns: 60px 1fr auto; gap: 14px; align-items: center;
  padding: 8px 6px; border-radius: 18px;
}
.move-row:nth-child(even) { background: var(--surface-container-low); }
.mr-thumb { width: 60px; height: 60px; border-radius: 16px; background: var(--surface-container-high); display: grid; place-items: center; overflow: hidden; }
.mr-thumb .fig { width: 100%; height: 100%; }
.mr-name { font-weight: 600; font-size: 16px; line-height: 1.25; }
.mr-target { color: var(--on-surface-variant); font-size: 13px; margin-top: 2px; }
.mr-time { color: var(--on-surface-variant); font-size: 14px; font-weight: 600; text-align: right; white-space: nowrap; }
.mr-time small { display: block; font-size: 12px; font-weight: 500; }
.start-bar {
  position: sticky; bottom: 0; padding: 16px 0 calc(12px + env(safe-area-inset-bottom));
  display: flex; justify-content: center;
  background: linear-gradient(to top, var(--surface) 65%, transparent);
  margin-top: 8px;
}
.detail-tip {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; padding: 14px 16px; border-radius: 20px;
  background: var(--surface-container); color: var(--on-surface-variant); font-size: 14px;
}

/* ========= Player ========= */
#view-player { background: var(--surface); }
.player {
  height: 100dvh; display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  gap: 12px; overscroll-behavior: none; touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.player-top { display: flex; align-items: center; justify-content: space-between; height: 56px; margin: 0 -4px; }
.player-title { display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 600; font-size: 15px; min-width: 0; }
.player-title > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw; }
.awake-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--primary); letter-spacing: .02em; }
.awake-chip .ms { font-size: 14px; }
.segments { display: flex; gap: 4px; height: 6px; }
.seg { flex: 1; border-radius: 3px; background: var(--surface-container-highest); overflow: hidden; }
.seg > i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 3px; }
.seg.done > i { width: 100%; }

.stage {
  position: relative; border-radius: 36px; background: var(--surface-container);
  display: grid; place-items: center; overflow: hidden; min-height: 180px;
  transition: background .5s;
}
.player[data-kind="rest"] .stage, .player[data-kind="prep"] .stage { background: var(--tertiary-container); }
.stage-fig { width: min(92%, 52vh, 440px); aspect-ratio: 1; }
.stage-fig .fig { width: 100%; height: 100%; }
.player[data-kind="rest"] .stage-fig, .player[data-kind="prep"] .stage-fig { opacity: .92; }
.stage-badge {
  position: absolute; top: 16px; left: 16px; z-index: 2;
  height: 32px; padding: 0 14px; border-radius: 10px; display: inline-flex; align-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--surface-container-highest); color: var(--on-surface-variant);
}
.player[data-kind="rest"] .stage-badge, .player[data-kind="prep"] .stage-badge { background: var(--tertiary); color: var(--surface); }
.player[data-kind="hold"] .stage-badge { background: var(--primary); color: var(--on-primary); }
.stage-side {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  height: 32px; padding: 0 12px 0 8px; border-radius: 10px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; font-weight: 650; background: var(--secondary-container); color: var(--on-secondary-container);
}
.stage-side .ms { font-size: 20px; }
.paused-veil {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: color-mix(in oklch, var(--surface) 55%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  font-weight: 700; font-size: 20px; color: var(--on-surface); opacity: 0; pointer-events: none; transition: opacity .25s;
}
.paused-veil .ms { font-size: 32px; }
.player.paused .paused-veil { opacity: 1; }

.player-info { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.ring-wrap { position: relative; width: 116px; height: 116px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-container-highest); stroke-width: 10; }
.ring-bar {
  fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.73; stroke-dashoffset: 0;
}
.player[data-kind="rest"] .ring-bar, .player[data-kind="prep"] .ring-bar { stroke: var(--tertiary); }
.ring-time {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 34px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  font-variation-settings: 'wdth' 90, 'opsz' 40;
}
.ring-wrap.warn .ring-time { color: var(--primary); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.info-text { min-width: 0; }
.move-target { font-size: 13px; font-weight: 650; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; }
.player[data-kind="rest"] .move-target, .player[data-kind="prep"] .move-target { color: var(--tertiary); }
.move-name { font-size: clamp(22px, 6vw, 28px); line-height: 1.12; font-weight: 600; margin-top: 4px; font-variation-settings: 'wdth' 100, 'opsz' 36; letter-spacing: -.01em; }
.move-cue { color: var(--on-surface-variant); font-size: 15px; margin-top: 6px; min-height: 2.9em; transition: opacity .3s; }

.player-controls { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 4px 0; }
.play-btn {
  width: 96px; height: 96px; border-radius: 32px; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-3);
  transition: border-radius .35s cubic-bezier(.2,0,0,1), transform .15s;
}
.play-btn .ms { font-size: 44px; }
.player.paused .play-btn { border-radius: 50%; }
.play-btn:active { transform: scale(.94); }
.up-next {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 14px 6px 6px;
  border-radius: 18px; background: var(--surface-container-low); font-size: 14px; color: var(--on-surface-variant);
}
.up-next:empty { visibility: hidden; }
.up-next .un-thumb { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-container-high); overflow: hidden; flex: none; display: grid; place-items: center; }
.up-next .un-thumb .fig { width: 100%; height: 100%; }
.up-next b { color: var(--on-surface); font-weight: 600; }
.up-next .un-time { margin-left: auto; font-weight: 600; white-space: nowrap; }

@media (max-height: 700px) {
  .ring-wrap { width: 96px; height: 96px; }
  .ring-time { font-size: 28px; }
  .play-btn { width: 80px; height: 80px; border-radius: 26px; }
  .icon-btn.big { width: 56px; height: 56px; }
  .move-cue { font-size: 14px; min-height: 2.8em; }
  .up-next { display: none; }
  .player { gap: 10px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .player {
    grid-template-columns: 1fr 1fr; grid-template-rows: auto auto 1fr auto;
    column-gap: 20px;
  }
  .player-top, .segments { grid-column: 1 / -1; }
  .stage { grid-row: 3 / 5; }
  .player-info { align-self: end; }
  .up-next { display: none; }
  .stage-fig { width: min(80%, 70vh); }
}

/* ========= Done ========= */

/* ========= Sheet / dialog ========= */
dialog { color: var(--on-surface); }
dialog::backdrop { background: var(--scrim); animation: fade .25s both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  margin: auto auto 0; width: 100%; max-width: 640px; border: 0; padding: 8px 24px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface-container-low); border-radius: 28px 28px 0 0; max-height: 92dvh;
}
.sheet[open] { animation: sheet-up .38s cubic-bezier(.2,0,0,1) both; }
.sheet { overflow-y: auto; overscroll-behavior: contain; }
/* While a dialog is open the page behind stays put, so a drag moves the sheet, not the page. */
html:has(dialog[open]) { overflow: hidden; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-handle { width: 32px; height: 4px; border-radius: 2px; background: var(--outline); opacity: .5; margin: 8px auto 16px; }
.sheet-title { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.li-text { flex: 1; min-width: 0; }
.li-text b { display: block; font-weight: 600; }
.li-text small { color: var(--on-surface-variant); font-size: 13px; }
.set-note { color: var(--on-surface-variant); font-size: 13px; margin-top: 8px; line-height: 1.4; }
.sheet-done { width: 100%; margin-top: 24px; height: 52px; }

/* M3 switch */
.switch {
  appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 16px; flex: none; margin: 0;
  background: var(--surface-container-highest); border: 2px solid var(--outline); position: relative; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.switch::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--outline);
  top: 6px; left: 6px; transition: all .25s cubic-bezier(.2,0,0,1);
}
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::after { width: 24px; height: 24px; top: 2px; left: 22px; background: var(--on-primary); }

/* Segmented button */
.segmented { display: flex; border: 1px solid var(--outline); border-radius: 999px; overflow: hidden; }
.segmented button { min-width: 0; padding: 0 6px; }
.segmented button {
  flex: 1; height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 500; font-size: 14px; border-right: 1px solid var(--outline); color: var(--on-surface);
  transition: background .2s;
}
.segmented button:last-child { border-right: 0; }
.segmented button .ms { font-size: 18px; }
.segmented button[aria-checked="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }
.segmented button[aria-checked="true"] .ms { display: none; }
.segmented button[aria-checked="true"]::before { content: 'check' / ''; font-family: 'Material Symbols Rounded'; font-size: 18px; line-height: 1; }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
#set-cloud-sub.warn { color: var(--on-surface); font-weight: 600; }
.swatch {
  width: 48px; height: 48px; border-radius: 16px; position: relative; overflow: hidden;
  background: conic-gradient(var(--primary) 0 50%, var(--primary-container) 0 75%, var(--tertiary-container) 0);
  transition: border-radius .25s;
}
.swatch[aria-checked="true"] { border-radius: 50%; outline: 3px solid var(--on-surface); outline-offset: 2px; }
.swatch[aria-checked="true"]::after {
  content: 'check'; font-family: 'Material Symbols Rounded'; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--on-primary); font-size: 22px;
}

.dialog {
  border: 0; border-radius: 28px; padding: 24px; max-width: min(340px, calc(100vw - 48px));
  background: var(--surface-container-high); text-align: center;
}
.dialog[open] { animation: dlg .3s cubic-bezier(.2,0,0,1) both; }
@keyframes dlg { from { opacity: 0; transform: scale(.9); } }
.dialog-icon { color: var(--secondary); }
.dialog h2 { font-size: 22px; font-weight: 500; margin-top: 14px; }
.dialog p { color: var(--on-surface-variant); margin-top: 12px; font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 22px; }

.snackbar {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 140%);
  background: var(--inverse-surface); color: var(--inverse-on-surface); padding: 14px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: var(--shadow-3); transition: transform .3s cubic-bezier(.2,0,0,1), visibility 0s .3s; visibility: hidden; z-index: 20; max-width: calc(100vw - 32px);
}
.snackbar.show { transform: translate(-50%, 0); visibility: visible; transition: transform .3s cubic-bezier(.2,0,0,1); }

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

/* ========= Reward screen (chest + payout) ========= */
#view-done { padding: 0 !important; }
.reward {
  --tc: #f2c14e; --tc2: #ff9f1c;
  /* Material You dark tokens from the app colour, whatever the app theme (this screen is always dark) */
  --primary: oklch(0.83 0.10 var(--h)); --on-primary: oklch(0.30 0.07 var(--h));
  --secondary-container: oklch(0.36 0.03 var(--h)); --on-secondary-container: oklch(0.91 0.03 var(--h));
  --surface-container-high: oklch(0.26 0.016 var(--h)); --on-surface: oklch(0.92 0.01 var(--h)); --on-surface-variant: oklch(0.79 0.02 var(--h));
  --outline: oklch(0.62 0.02 var(--h)); --outline-variant: oklch(0.38 0.018 var(--h));
  position: relative; min-height: 100dvh; overflow: hidden; color: #fff;
  background: #140e26; /* fallback for browsers without color-mix() */
  background:
    radial-gradient(120% 70% at 50% 18%, color-mix(in oklch, var(--tc) 38%, transparent), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, color-mix(in oklch, var(--tc2) 25%, transparent), transparent 70%),
    #140e26;
  user-select: none; -webkit-user-select: none;
}
.reward[data-tier="1"] { --tc: #5aa9e6; --tc2: #4cc9f0; }
.reward[data-tier="2"] { --tc: #b388ff; --tc2: #ff5fa2; }
.reward[data-tier="3"] { --tc: #ffd60a; --tc2: #ff5fa2; }
.rw-inner {
  position: relative; z-index: 2; min-height: 100dvh; max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}
.rw-beams {
  position: absolute; left: 50%; top: 21%; width: 110vmax; height: 110vmax; translate: -50% -50%; z-index: 1; will-change: transform;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.18) 0 9deg, transparent 9deg 24deg);
  background: repeating-conic-gradient(from 0deg, color-mix(in oklch, var(--tc) 55%, transparent) 0 9deg, transparent 9deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 0 13%, transparent 69%); mask: radial-gradient(circle, #000 0 13%, transparent 69%);
  opacity: 0; transition: opacity .6s; animation: spin 14s linear infinite;
}
.reward[data-tier="3"] .rw-beams {
  background: repeating-conic-gradient(from 0deg, #ff5fa2aa 0 6deg, transparent 6deg 15deg, #ffd60aaa 15deg 21deg, transparent 21deg 30deg, #4cc9f0aa 30deg 36deg, transparent 36deg 45deg);
}
.reward.opened .rw-beams { opacity: 1; }
.rw-fx { position: absolute; inset: 0; z-index: 5; pointer-events: none; contain: strict; }
.pt { will-change: transform, opacity; }

.rw-tier {
  font-size: 15px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; margin-top: 4px;
  color: color-mix(in oklch, var(--tc) 55%, #fff); opacity: 0; transition: opacity .4s;
  position: relative; z-index: 4;
}
.reward.ready .rw-tier { opacity: 1; }
.rw-chest { width: min(54vw, 210px); margin-top: 34px; position: relative; z-index: 3; }
.rw-chest::after { content: ''; position: absolute; inset: 0 -14% -10%; z-index: -2; pointer-events: none; opacity: .85;
  background: radial-gradient(closest-side, color-mix(in oklch, var(--tc) 55%, transparent), transparent); }
.rw-chest svg { will-change: transform; }
.rw-chest svg { width: 100%; height: auto; display: block; overflow: visible; }
.reward.dropping .rw-chest { animation: chest-drop .55s cubic-bezier(.3,1.5,.6,1) both; }
@keyframes chest-drop { from { transform: translateY(-70vh) rotate(-12deg) scale(.6); } }
.reward.ready:not(.opening) .rw-chest svg { animation: wobble 1.4s ease-in-out infinite; }
@keyframes wobble { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-5deg) scale(1.04); } 80% { transform: rotate(5deg) scale(1.04); } 90% { transform: rotate(-3deg); } }
.reward.opening:not(.opened) .rw-chest svg { animation: rattle .12s linear infinite; }
@keyframes rattle { 0% { transform: translate(-3px, 1px) rotate(-3deg); } 50% { transform: translate(3px, -1px) rotate(3deg); } 100% { transform: translate(-3px, 1px) rotate(-3deg); } }
.chest-lid { transform-box: fill-box; transform-origin: 0% 100%; transition: transform .5s cubic-bezier(.3,1.6,.5,1); }
.reward.opened .chest-lid { transform: translate(-4px, -34px) rotate(-24deg); }
.chest-glow { opacity: 0; transition: opacity .3s; }
.reward.opened .chest-glow { opacity: 1; }
.cf-open { display: none; }
.reward.opened .cf-open { display: inline; }
.reward.opened .cf-closed { display: none; }
.rw-tap { margin-top: 2px; font-weight: 800; font-size: 16px; letter-spacing: .02em; opacity: 0; transition: opacity .3s; height: 22px; }
.reward.ready:not(.opening) .rw-tap { opacity: 1; animation: pulse 1s ease-in-out infinite; }

.rw-count, .rw-loot, .rw-level, .rw-stats, .rw-actions { opacity: 0; transform: translateY(16px); transition: opacity .35s, transform .45s cubic-bezier(.2,1.4,.4,1); pointer-events: none; }
.reward.show-count .rw-count, .reward.show-loot .rw-loot, .reward.show-level .rw-level,
.reward.done .rw-stats, .reward.done .rw-actions { opacity: 1; transform: none; pointer-events: auto; }
.rw-count { width: 100%; }
.rw-label { font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: color-mix(in oklch, var(--tc) 70%, #fff); }
.rw-big-wrap, .rw-big-wrap::before {
  font-size: clamp(46px, 15vw, 80px); line-height: 1.05; font-weight: 900; font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' 70, 'opsz' 96; letter-spacing: -.01em;
}
.rw-big {
  color: #ffd166;
  position: relative; z-index: 0;
}
/* Cheap 3D edge: a dark copy 4px lower (a drop-shadow filter would be redrawn every frame while counting). */
.rw-big-wrap { position: relative; }
.rw-big-wrap::before { content: attr(data-n); position: absolute; inset: 0; translate: 0 4px; color: rgba(0,0,0,.45); pointer-events: none; font-size: inherit; }
.rw-count { position: relative; }
.rw-count::before { content: ''; position: absolute; left: 50%; top: 52%; width: min(92vw, 420px); height: 120px; translate: -50% -50%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in oklch, var(--tc) 45%, transparent), transparent); }
.rw-big-wrap.bump { animation: bump .35s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.18); } }
.rw-big-wrap.final { animation: final 1.2s ease-in-out 2; }
@keyframes final { 50% { transform: scale(1.08); } }
.rw-mults { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; min-height: 34px; }
.rw-mult {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 8px; border-radius: 8px;
  background: var(--surface-container-high); border: 1px solid var(--outline-variant); color: var(--on-surface); font-weight: 500; font-size: 14px;
  animation: slam .45s cubic-bezier(.3,1.7,.5,1) both;
}
.rw-mult .ms { font-size: 18px; color: var(--tc); }
.rw-mult b { color: #ffd60a; font-size: 15px; font-weight: 900; }
.rw-mult.hot { background: linear-gradient(90deg, #ff5fa2, #ff9f1c); border-color: transparent; }
.rw-mult.hot .ms, .rw-mult.hot b { color: #fff; }
@keyframes slam { from { transform: scale(2.4) rotate(-6deg); opacity: 0; } }

.rw-loot { width: 100%; margin-top: 14px; }
.rw-card {
  display: grid; grid-template-columns: 104px 1fr; gap: 12px; align-items: center; text-align: left;
  padding: 10px 14px 10px 8px; border-radius: 24px; background: color-mix(in oklch, var(--surface-container-high) 88%, transparent); border: 1px solid var(--outline-variant); color: var(--on-surface);
}
.reward.show-loot .rw-card { animation: card-pop .6s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes card-pop { from { transform: scale(.3) rotate(-10deg); opacity: 0; } }
.rw-card[data-rarity="1"] { border: 2px solid #5aa9e6; }
.rw-card[data-rarity="2"] { border: 2px solid #b388ff; }
.rw-card[data-rarity="3"] { border: 2px solid #ffd60a; }
.rw-critter .critter { width: 104px; height: 104px; display: block; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(2deg); } }
.rw-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rw-new { font-size: 12px; font-weight: 900; letter-spacing: .1em; color: #ffd60a; }
.rw-card-text b { font-size: 22px; font-weight: 800; line-height: 1.1; }
.rw-rarity { align-self: flex-start; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,.16); }
.rw-card[data-rarity="1"] .rw-rarity { background: #5aa9e6; }
.rw-card[data-rarity="2"] .rw-rarity { background: #9b6bf2; }
.rw-card[data-rarity="3"] .rw-rarity { background: #ffd60a; color: #2b2233; }
.rw-card-text small { font-size: 13px; opacity: .8; line-height: 1.35; margin-top: 2px; }

.rw-level { width: 100%; margin-top: 16px; }
.rw-lv-row { display: flex; align-items: center; gap: 10px; }
.rw-lv { font-weight: 900; font-size: 14px; padding: 4px 10px; border-radius: 10px; background: var(--tc); color: #1b1230; white-space: nowrap; }
.rw-lv.next { background: rgba(255,255,255,.14); color: #fff; }
.rw-bar { flex: 1; height: 14px; border-radius: 7px; background: rgba(255,255,255,.14); overflow: hidden; }
.rw-bar i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; will-change: transform; border-radius: 7px; background: linear-gradient(90deg, var(--tc), #fff6c2); }
.rw-xp { font-size: 12px; font-weight: 700; opacity: .75; margin-top: 6px; font-variant-numeric: tabular-nums; }
.rw-level.levelup .rw-lv { animation: lvpop .7s cubic-bezier(.3,1.8,.5,1); }
.rw-level.levelup::after {
  content: var(--levelup-text, 'LEVEL UP!'); display: block; margin-top: 4px; font-weight: 900; font-size: 22px; letter-spacing: .06em;
  color: #ffd60a; text-shadow: 0 3px 0 rgba(0,0,0,.4); animation: lvpop .7s cubic-bezier(.3,1.8,.5,1);
}
@keyframes lvpop { from { transform: scale(2); opacity: 0; } }
.rw-stats { display: flex; gap: 18px; justify-content: center; margin-top: 18px; font-size: 12px; color: rgba(255,255,255,.8); }
.rw-stats span { display: flex; flex-direction: column; }
.rw-stats b { font-size: 16px; font-weight: 800; }
.rw-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; width: 100%; margin-top: auto; padding-top: 20px; }
/* Material You buttons from the app's colour scheme: filled (primary) + tonal icon button, M3 press shape-morph */
.rw-btn {
  height: 56px; border-radius: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 500; font-size: 16px; letter-spacing: .01em; padding: 0 24px 0 16px;
  background: var(--secondary-container); color: var(--on-secondary-container);
  transition: border-radius .25s cubic-bezier(.2,0,0,1);
}
.rw-btn .ms { font-size: 24px; }
.rw-btn:active { border-radius: 16px; }
.rw-btn.primary { background: var(--primary); color: var(--on-primary); }
.reward.shake .rw-inner { animation: screen-shake .28s linear; }
@keyframes screen-shake { 20% { transform: translate(-5px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 3px); } 80% { transform: translate(3px, -1px); } }

.pt { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; animation: fly 1s cubic-bezier(.15,.7,.4,1) forwards; }
.pt.coin { border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6c2, #ffd60a 45%, #e09f00); box-shadow: inset 0 0 0 2px #c77d00; }
.pt.star { background: var(--tc); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.pt.spark { width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: radial-gradient(circle, #fff 0 28%, rgba(255,255,255,.45) 40%, transparent 70%); }
.pt.heart { background: #ff5fa2; clip-path: polygon(50% 100%, 0 40%, 10% 10%, 35% 5%, 50% 22%, 65% 5%, 90% 10%, 100% 40%); }
@keyframes fly {
  0% { transform: translate(0, 0) scale(.2) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--tx), calc(var(--ty) + 80px)) scale(var(--s)) rotate(var(--r)); opacity: 0; }
}

/* ========= Home: progress, quests, collection ========= */
.progress-card { background: var(--surface-container-low); border-radius: 28px; padding: 14px; margin-bottom: 12px; }
.pc-top { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: center; }
.pc-buddy { width: 56px; height: 56px; border-radius: 18px; background: var(--primary-container); display: grid; place-items: center; overflow: hidden; }
.pc-buddy .critter { width: 60px; height: 60px; margin-top: 4px; }
.pc-line { display: flex; align-items: baseline; justify-content: space-between; gap: 2px 8px; flex-wrap: wrap; }
.pc-line b { font-size: 17px; font-weight: 700; }
.pc-line small { color: var(--on-surface-variant); font-size: 12px; font-weight: 600; }
.pc-bar { height: 10px; border-radius: 5px; background: var(--surface-container-highest); overflow: hidden; margin-top: 6px; }
.pc-bar i { display: block; height: 100%; border-radius: 5px; background: var(--primary); }
.quests { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.quest {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 16px;
  background: var(--surface-container); color: var(--on-surface-variant); font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.2;
}
.quest .ms { font-size: 22px; }
.quest.done { background: var(--primary); color: var(--on-primary); }
.quest-hint { font-size: 12.5px; color: var(--on-surface-variant); margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.quest-hint .ms { font-size: 18px; color: var(--tertiary); }
.quest-hint b { color: var(--on-surface); }
.collection { margin: 26px 0 0; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px 8px; }
.col-head h2 { font-size: 18px; font-weight: 600; }
.col-head small { color: var(--on-surface-variant); font-weight: 700; }
.col-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 6px; }
.col-row::-webkit-scrollbar { display: none; }
.col-item { flex: none; width: 76px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--on-surface-variant); }
.col-item .critter { width: 68px; height: 68px; }
.col-item.owned .critter { animation: bob 2.4s ease-in-out infinite; }
.col-item .lv { font-size: 10px; padding: 1px 6px; border-radius: 6px; background: var(--secondary-container); color: var(--on-secondary-container); }

@media (max-height: 720px) {
  .rw-chest { width: min(42vw, 160px); margin-top: 26px; }
  .rw-big-wrap { font-size: clamp(40px, 13vw, 60px); }
  .rw-card { grid-template-columns: 80px 1fr; padding: 8px 12px 8px 6px; }
  .rw-critter .critter { width: 80px; height: 80px; }
  .rw-card-text b { font-size: 19px; }
  .rw-loot { margin-top: 10px; }
  .rw-level { margin-top: 12px; }
  .rw-stats { margin-top: 12px; }
  .rw-actions { padding-top: 14px; }
  .rw-btn { height: 52px; }
}

/* After opening, the chest shrinks so the payout fits on the screen */
/* The size change happens under the white flash in one step (animating width/margin re-lays out the page every frame). */
.reward.collapse .rw-tier { transition: none; }
.reward.collapse .rw-tap { display: none; }
.reward.collapse .rw-chest { width: min(34vw, 140px); margin-top: 30px; }
@media (max-height: 720px) {
  .reward.collapse .rw-chest { width: min(26vw, 100px); margin-top: 22px; }
}
@media (max-height: 680px) {
  .rw-big-wrap { font-size: clamp(36px, 12vw, 52px); }
  .rw-mult { height: 30px; font-size: 12px; }
  .rw-mults { gap: 4px; margin-top: 6px; }
  .rw-card { grid-template-columns: 68px 1fr; }
  .rw-critter .critter { width: 68px; height: 68px; }
  .rw-card-text small { display: none; }
  .rw-level.levelup::after { font-size: 18px; }
  .rw-stats { display: none; }
}
.rw-nochest { justify-content: center; gap: 12px; }
.rw-nochest .rw-chest { filter: grayscale(.6) brightness(.8); }
.rw-nochest .rw-chest::after { content: none; }
.rw-nochest h1 { font-size: 32px; font-weight: 800; }
.rw-nochest p { opacity: .8; max-width: 300px; }
.rw-nochest .rw-actions { opacity: 1; transform: none; pointer-events: auto; margin-top: 12px; }

/* ========= Extra flash: anticipation, pillar, white flash, coin rain, banner ========= */
.rw-tap { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 18px; height: 28px; color: #fff6c2; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.rw-tap .ms { font-size: 24px; }
.reward.ready:not(.opening) .rw-tap { animation: tap-bounce .9s ease-in-out infinite; }
@keyframes tap-bounce { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.08); } }
/* light leaking from the seams before it opens */
.reward.ready:not(.opened) .chest-glow { opacity: .7; }
.reward.ready:not(.opening) .rw-chest::after { animation: halo 1.6s ease-in-out infinite; }
@keyframes halo { 50% { transform: scale(1.3); opacity: 1; } }
/* charging: grows, glows, rattles harder */
.rw-chest > svg { transition: transform .9s cubic-bezier(.5,0,.9,.4); }
.rw-chest::after { transition: transform .4s cubic-bezier(.5,0,.9,.4); }
.reward.opening:not(.opened) .rw-chest::after { transform: scale(1.7); opacity: 1;
  background: radial-gradient(closest-side, #fff 0, #fff 45%, color-mix(in oklch, var(--tc) 85%, transparent) 70%, transparent); }
.reward.opening:not(.opened) .rw-chest svg { animation: rattle .07s linear infinite; scale: 1.18; transition: scale .9s cubic-bezier(.5,0,.9,.4); }

.rw-flash { position: fixed; inset: 0; z-index: 9; background: #fff; opacity: 0; pointer-events: none; }
.rw-flash.go { animation: white-flash .6s ease-out; }
.rw-flash.go.soft { animation: white-flash-soft .25s ease-out; }
@keyframes white-flash { 0% { opacity: .95; } 100% { opacity: 0; } }
@keyframes white-flash-soft { 0% { opacity: .35; } 100% { opacity: 0; } }

.rw-pillar {
  position: absolute; left: 50%; top: 45%; width: 64%; height: 220vh; translate: -50% -50%; z-index: -1;
  background: linear-gradient(to top, transparent 0%, rgba(255,255,255,.5) 46%, #fff 50%, rgba(255,255,255,.5) 54%, transparent 100%);
  background: linear-gradient(to top, transparent 0%, color-mix(in oklch, var(--tc) 35%, transparent) 30%, var(--tc) 46%, #fff 50%, var(--tc) 54%, color-mix(in oklch, var(--tc) 35%, transparent) 70%, transparent 100%);
  border-radius: 50%; transform-origin: 50% 50%; transform: scaleY(0) scaleX(.4); opacity: 0; will-change: transform, opacity;
  -webkit-mask: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent); mask: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent);
}
.reward.opened .rw-pillar { animation: pillar-up .55s cubic-bezier(.2,1.4,.4,1) forwards, pillar-pulse 1.4s ease-in-out .55s infinite; }
@keyframes pillar-up { to { transform: scaleY(1) scaleX(1); opacity: .9; } }
@keyframes pillar-pulse { 0%, 100% { transform: scaleY(1) scaleX(1); opacity: .9; } 50% { transform: scaleY(1.03) scaleX(.82); opacity: .7; } }
.reward.done .rw-pillar { animation: none; transform: none; opacity: .75; }

/* party mode: beams spin faster and cycle through colors */
.reward.party:not(.done) .rw-beams { animation: spin 7s linear infinite; }
.rw-beams::before, .rw-beams::after { content: ''; position: absolute; inset: 0; border-radius: 50%; opacity: 0; }
.rw-beams::before { background: repeating-conic-gradient(from 0deg, color-mix(in oklch, #ff5fa2 55%, transparent) 0 9deg, transparent 9deg 24deg); }
.rw-beams::after { background: repeating-conic-gradient(from 0deg, color-mix(in oklch, #4cc9f0 55%, transparent) 0 9deg, transparent 9deg 24deg); }
.reward.party:not(.done) .rw-beams::before { animation: beam-tint 4s linear infinite; }
.reward.party:not(.done) .rw-beams::after { animation: beam-tint 4s linear 2s infinite; }
@keyframes beam-tint { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
.reward[data-tier="3"] .rw-beams::before { background: repeating-conic-gradient(from 0deg, #ffd60aaa 0 6deg, transparent 6deg 15deg, #4cc9f0aa 15deg 21deg, transparent 21deg 30deg, #ff5fa2aa 30deg 36deg, transparent 36deg 45deg); }
.reward[data-tier="3"] .rw-beams::after { background: repeating-conic-gradient(from 0deg, #4cc9f0aa 0 6deg, transparent 6deg 15deg, #ff5fa2aa 15deg 21deg, transparent 21deg 30deg, #ffd60aaa 30deg 36deg, transparent 36deg 45deg); }
.reward.party:not(.done) .rw-label { animation: label-flash .5s steps(2) infinite; }
@keyframes label-flash { 50% { color: #fff; } }

/* coin rain */
.pt.fall { animation-name: fall; animation-timing-function: linear; }
@keyframes fall {
  0% { transform: translate(0, 0) scale(.3) rotate(0); opacity: 1; }
  30% { transform: translate(calc(var(--tx) * .35), var(--peak)) scale(var(--s)) rotate(calc(var(--r) * .3)); }
  100% { transform: translate(var(--tx), var(--fall)) scale(var(--s)) rotate(var(--r)); opacity: 1; }
}
.pt.gem { width: 12px; height: 16px; margin: -8px 0 0 -6px; clip-path: polygon(50% 0, 100% 35%, 50% 100%, 0 35%); background: linear-gradient(135deg, #a5f3ff, #4cc9f0 45%, #7b2ff7); }
.pt.fw { width: 14px; height: 14px; margin: -7px 0 0 -7px; }

/* praise stamp */
.rw-banner {
  position: absolute; left: 0; right: 0; top: 34%; z-index: 8; text-align: center; pointer-events: none; padding: 0 12px;
  font-size: clamp(34px, 11vw, 58px); font-weight: 900; letter-spacing: .02em; line-height: 1;
  font-variation-settings: 'wdth' 75, 'opsz' 96;
  color: #fff6c2; -webkit-text-stroke: 2px #7a3e00;
  text-shadow: 0 5px 0 #c77d00, 0 8px 0 rgba(0,0,0,.35);
  opacity: 0;
}
.rw-banner.go { animation: stamp 1.9s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes stamp {
  0% { opacity: 0; transform: scale(3.2) rotate(-8deg); }
  14% { opacity: 1; transform: scale(.92) rotate(-4deg); }
  22% { transform: scale(1.06) rotate(-4deg); }
  70% { opacity: 1; transform: scale(1) rotate(-4deg); }
  100% { opacity: 0; transform: translateY(-60px) scale(.9) rotate(-4deg); }
}
.rw-card { position: relative; overflow: hidden; }
.rw-card::before {
  content: ''; position: absolute; inset: -50%; z-index: -1;
  background: repeating-conic-gradient(rgba(255,255,255,.12) 0 10deg, transparent 10deg 30deg);
  animation: spin 9s linear infinite;
}
.rw-card[data-rarity="3"]::before { background: repeating-conic-gradient(#ffd60a55 0 10deg, transparent 10deg 20deg, #ff5fa255 20deg 30deg, transparent 30deg 40deg); }

/* ========= Native app (Capacitor) ========= */
html.native, html.native body { overscroll-behavior: none; }
html.native body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html.native input, html.native textarea { -webkit-user-select: text; user-select: text; }

/* Language picker */
.lang-note { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* ---------- Procedural Fibbies: collection, stars, details sheet, merging ---------- */
.stars { color: #f4a100; font-size: 12px; letter-spacing: 1px; line-height: 1; white-space: nowrap; }
.stars i { font-style: normal; opacity: .22; }
.col-item { position: relative; }
.col-name { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-count { position: absolute; top: 0; right: 2px; z-index: 1; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 8px; background: var(--primary); color: var(--on-primary); }
.col-item.can-merge .critter { border-radius: 50%; animation: bob 2.4s ease-in-out infinite; }
/* Ready to merge: a tonal circle with a primary ring behind the Fibbie (no neon glow) */
.col-item.can-merge .critter { background: var(--primary-container); box-shadow: 0 0 0 2px var(--primary); }
.col-empty { display: flex; align-items: center; gap: 12px; padding: 4px 0 8px; color: var(--on-surface-variant); font-size: 13px; line-height: 1.4; }
.col-empty .critter { width: 56px; height: 56px; flex: none; }
.critter.sil { filter: brightness(0) opacity(.3); }
:root[data-theme="dark"] .critter.sil { filter: brightness(0) invert(1) opacity(.3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .critter.sil { filter: brightness(0) invert(1) opacity(.3); } }

.fib-sheet #fib-body { display: flex; flex-direction: column; align-items: center; text-align: center; }
.fs-stage { position: relative; width: 100%; height: 190px; display: grid; place-items: center; border-radius: 28px; overflow: hidden;
  background: radial-gradient(circle at 50% 60%, var(--primary-container), transparent 70%); }
.fs-stage[data-glow="2"] { background: radial-gradient(circle at 50% 60%, #b388ff66, transparent 70%); }
.fs-stage[data-glow="3"] { background: radial-gradient(circle at 50% 60%, #ffd60a77, transparent 70%); }
.fs-critter .critter { width: 170px; height: 170px; display: block; animation: bob 2s ease-in-out infinite; }
.fs-critter.born .critter { animation: born .8s cubic-bezier(.3,1.7,.5,1) both, bob 2s ease-in-out .8s infinite; }
@keyframes born { from { transform: scale(.2) rotate(-20deg); filter: brightness(3); } }
.fs-fx { position: absolute; left: 50%; top: 50%; pointer-events: none; }
.fs-fx i { position: absolute; width: 10px; height: 10px; border-radius: 50%; animation: fs-spark .9s cubic-bezier(.2,.8,.4,1) forwards; }
@keyframes fs-spark { to { transform: translate(var(--tx), var(--ty)) scale(.2); opacity: 0; } }
.fs-name { font-size: 26px; font-weight: 800; margin-top: 10px; }
.fs-chips { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.fs-chips .stars { font-size: 16px; }
.rar-chip { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 8px; background: var(--surface-container-highest); color: var(--on-surface-variant); }
.rar-chip[data-r="1"] { background: #5aa9e6; color: #fff; }
.rar-chip[data-r="2"] { background: #9b6bf2; color: #fff; }
.rar-chip[data-r="3"] { background: #ffd60a; color: #2b2233; }
.fs-blurb { color: var(--on-surface-variant); margin-top: 10px; font-size: 14px; line-height: 1.45; max-width: 34ch; }
.fs-evo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; padding: 8px 16px; border-radius: 20px; background: var(--surface-container-high); }
.fs-evo > .ms { color: var(--on-surface-variant); }
.fs-mini { display: flex; flex-direction: column; align-items: center; font-size: 12px; font-weight: 700; }
.fs-mini .critter { width: 64px; height: 64px; }
.fs-owned { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); }
.fs-merge { width: 100%; height: 52px; margin-top: 12px; }
.fs-max { margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #f4a100; }
.fib-sheet .sheet-done { margin-top: 8px; }

/* ---------- Chest: centered start, multi-tap opening, skip ---------- */
.rw-tier { transition: margin-top .55s cubic-bezier(.2,0,0,1); }
.rw-skip { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 8px); right: 8px; z-index: 30; display: inline-flex; align-items: center; gap: 2px;
  height: 32px; padding: 0 8px 0 12px; border-radius: 8px; border: 1px solid var(--outline-variant); font: inherit; font-size: 14px; font-weight: 500;
  background: rgba(20,14,38,.6); color: var(--on-surface-variant); }
.rw-skip .ms { font-size: 18px; }
.rw-skip:active { background: rgba(255,255,255,.22); }
.rw-dots { display: inline-flex; gap: 5px; margin-left: 8px; }
.rw-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.28); transition: background .2s, transform .2s; }
.reward[data-hits="1"] .rw-dots i:nth-child(-n+1), .reward[data-hits="2"] .rw-dots i:nth-child(-n+2), .reward[data-hits="3"] .rw-dots i { background: #ffd60a; transform: scale(1.2); }
.reward.ready:not(.opening) .rw-chest.hit svg { animation: chest-hit .38s cubic-bezier(.3,1.8,.5,1); }
@keyframes chest-hit { 0% { transform: scale(1); } 30% { transform: scale(1.14, .88) rotate(-4deg); } 60% { transform: scale(.94, 1.08) rotate(3deg); } 100% { transform: scale(1); } }
.chest-cracks path { opacity: 0; transition: opacity .2s; }
.reward[data-hits="1"] .chest-cracks .ck1, .reward[data-hits="2"] .chest-cracks path, .reward[data-hits="3"] .chest-cracks path { opacity: 1; }
.reward[data-hits="1"]:not(.opened) .chest-lid { transform: translate(0, -3px) rotate(-2deg); }
.reward[data-hits="2"]:not(.opened) .chest-lid, .reward[data-hits="3"]:not(.opened) .chest-lid { transform: translate(-1px, -7px) rotate(-5deg); }
.reward[data-hits="2"]:not(.opened) .chest-glow, .reward[data-hits="3"]:not(.opened) .chest-glow { opacity: .95; }
.rw-card-text .stars { font-size: 14px; margin-top: 2px; }
.rw-card-text small.rw-merge { opacity: 1; color: #ffd60a; font-weight: 700; }

/* ---------- Fibbie album ---------- */
.col-album { display: inline-flex; align-items: center; gap: 4px; padding: 6px 4px 6px 10px; border-radius: 16px; font-size: 13px; font-weight: 700;
  color: var(--primary); background: none; position: relative; overflow: hidden; }
.col-album .ms { font-size: 18px; }
.col-head { align-items: center; }
.al-hint { color: var(--on-surface-variant); font-size: 14px; line-height: 1.45; }
.al-sub { margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--primary); }
.al-head { font-size: 15px; font-weight: 700; margin: 20px 0 10px; }
.al-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.al-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 10px; border-radius: 18px; min-width: 0;
  background: var(--surface-container); font-size: 11px; font-weight: 700; color: var(--on-surface-variant); position: relative; overflow: hidden; }
.al-cell .critter { width: 64px; height: 64px; }
.al-cell.unknown { background: var(--surface-container-high); }
.al-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-pips { display: flex; gap: 3px; }
.al-pips i { width: 7px; height: 7px; border-radius: 50%; background: var(--outline-variant, var(--outline)); opacity: .45; }
.al-pips i.on { background: #f4a100; opacity: 1; }
.al-empty { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--on-surface-variant); font-size: 13px; line-height: 1.4; }
.al-empty .critter { width: 48px; height: 48px; flex: none; }

/* ---------- Flexibility check ---------- */
.flex-card { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 18px; padding: 14px 16px; border-radius: 24px; text-align: left;
  background: var(--surface-container); color: var(--on-surface); position: relative; overflow: hidden; }
.flex-card.due { background: var(--secondary-container); color: var(--on-secondary-container); }
.fx-icon { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); }
.fx-text { flex: 1; min-width: 0; }
.fx-text b { display: block; font-weight: 600; }
.fx-text small { display: block; font-size: 13px; line-height: 1.35; opacity: .8; }
.fx-go { flex: none; color: var(--primary); margin-right: -6px; }
.flex-card .flex-chart.mini { width: 72px; height: 30px; flex: none; }
.flex-chart { display: block; width: 100%; height: auto; overflow: visible; }
.fc-grid { stroke: var(--outline-variant, var(--outline)); stroke-width: 1; opacity: .35; }
.fc-tick { fill: var(--on-surface-variant); font-size: 10px; font-family: inherit; }
.fc-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.fc-area { fill: var(--primary); opacity: .1; }
.fc-dot { fill: var(--primary); stroke: var(--surface-container-low); stroke-width: 2; }
.flex-card .fc-dot { stroke: none; }
.fc-hit { fill: transparent; cursor: pointer; }
.fc-val { fill: var(--on-surface); font-size: 12px; font-weight: 700; font-family: inherit; }
.flex-chart-box { padding: 14px 14px 10px; border-radius: 20px; background: var(--surface-container); margin-bottom: 8px; }
.fcb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.fcb-head small { color: var(--primary); font-weight: 700; font-size: 13px; }
.fcb-read { font-size: 12px; color: var(--on-surface-variant); margin-top: 4px; min-height: 16px; }
.flex-note { display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: 10px; border-radius: 16px;
  background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; font-size: 14px; }
.flex-intro { color: var(--on-surface-variant); font-size: 14px; line-height: 1.45; margin: 8px 0 4px; }
.ft { margin-top: 18px; }
.ft-head { display: flex; align-items: center; gap: 12px; }
.ft-fig { width: 56px; height: 56px; flex: none; border-radius: 16px; background: var(--surface-container); padding: 2px; }
.ft-fig .fig { width: 100%; height: 100%; }
.ft-head h3 { font-size: 16px; font-weight: 600; }
.ft-prev { font-size: 12px; color: var(--on-surface-variant); }
.ft-prev .up { color: var(--primary); }
.ft-how { font-size: 13px; line-height: 1.4; color: var(--on-surface-variant); margin: 8px 0; }
.ft-opts { display: grid; gap: 6px; }
.fo { display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 12px; border-radius: 14px; font-size: 14px;
  background: var(--surface-container); color: var(--on-surface); border: 1.5px solid transparent; position: relative; overflow: hidden; }
.fo i { font-style: normal; width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--surface-container-highest); color: var(--on-surface-variant); }
.fo[aria-checked="true"] { border-color: var(--primary); background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; }
.fo[aria-checked="true"] i { background: var(--primary); color: var(--on-primary); }
.flex-save { width: 100%; height: 52px; margin-top: 22px; }
.flex-save[aria-disabled="true"] { opacity: .5; }
.flex-need { text-align: center; font-size: 13px; font-weight: 600; margin-top: 8px; color: var(--on-surface); }
.fx-score { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.fx-score b { font-size: 22px; font-weight: 700; line-height: 1; color: var(--primary); }
.flex-card .fx-score .flex-chart.mini { width: 64px; height: 26px; }
.fc-val, .fc-dot { pointer-events: none; }
/* Two-sided flexibility tests: a left and a right choice per level */
.ft-opts.two { gap: 4px; }
.fo2-head, .fo2 { display: grid; grid-template-columns: minmax(0, 1fr) 64px 64px; align-items: center; gap: 6px; }
.fo2-head b { font-size: 11.5px; font-weight: 700; text-align: center; color: var(--on-surface-variant); }
.fo2 { padding: 4px 4px 4px 12px; border-radius: 14px; background: var(--surface-container); }
.fo2-lab { font-size: 14px; line-height: 1.3; }
.fs { height: 36px; border-radius: 12px; font-size: 13px; font-weight: 700; background: var(--surface-container-highest); color: var(--on-surface-variant);
  border: 1.5px solid transparent; position: relative; overflow: hidden; }
.fs[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.flex-tight { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; font-size: 13px; line-height: 1.4; font-weight: 600; }
.flex-tight .ms { color: var(--primary); font-size: 20px; }
/* Safety note */
.safety-list { text-align: left; display: grid; gap: 10px; margin: 4px 0 0; padding: 0; list-style: none; }
.safety-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; color: var(--on-surface-variant); }
.safety-list .ms { color: var(--primary); font-size: 20px; flex: none; }
.footnote-btn { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px; }

/* ---------- Fibbie ran away (reward screen) ---------- */
.rw-card.runaway { box-shadow: none; }
.rw-card.runaway .rw-new { color: #ff8fab; }
.rw-card.runaway .rw-critter { position: relative; height: 104px; }
@media (max-height: 720px) { .rw-card.runaway .rw-critter { height: 80px; } }
@media (max-height: 680px) { .rw-card.runaway .rw-critter { height: 68px; } }
.rw-card.runaway .critter { animation: none; }
.rw-runner { position: absolute; inset: 0; transform-origin: 50% 100%; animation: rw-peek 1.25s ease-in-out both, rw-dash .55s cubic-bezier(.5,0,.9,.4) 1.3s forwards; }
@keyframes rw-peek {
  0% { transform: translateY(14px) scale(.6); opacity: 0; }
  20% { transform: translateY(0) scale(1); opacity: 1; }
  40% { transform: scaleX(-1); }
  60% { transform: scaleX(1) rotate(-6deg); }
  80% { transform: translateY(-10px) scaleY(1.08); }
  100% { transform: translateY(0) scaleY(.85) scaleX(1.1); }
}
@keyframes rw-dash { from { transform: translateX(0) skewX(-12deg) scaleX(1.15); opacity: 1; } to { transform: translateX(110vw) skewX(-24deg) scaleX(1.4); opacity: 1; } }
.rw-dust { position: absolute; left: 30%; bottom: 6px; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.55); opacity: 0;
  animation: rw-dust .7s ease-out 1.32s forwards; pointer-events: none; }
.rw-dust.d2 { left: 8%; bottom: 14px; width: 22px; height: 22px; animation-delay: 1.4s; }
@keyframes rw-dust { 0% { opacity: .9; transform: scale(.4); } 100% { opacity: 0; transform: scale(2.2) translateX(-24px); } }
@media (prefers-reduced-motion: reduce) { .rw-runner { animation: none; opacity: .35; } .rw-dust { display: none; } }

/* ---------- Evolution show (merge) ---------- */
dialog.merge-fx { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; }
dialog.merge-fx::backdrop { background: #07040f; animation: fade .3s both; }
.mx { position: fixed; inset: 0; display: grid; place-items: center; overflow: hidden; color: #fff; user-select: none; -webkit-user-select: none; opacity: 1;
  background: radial-gradient(circle at 50% 42%, oklch(0.32 0.13 var(--mh)) 0, #0b0618 62%, #07040f 100%); animation: fade .3s both; }
.mx > * { position: absolute; left: 50%; top: 42%; }
.mx-glow { width: 70vmin; height: 70vmin; margin: -35vmin 0 0 -35vmin; border-radius: 50%; filter: blur(30px); opacity: .5;
  background: radial-gradient(circle, oklch(0.8 0.18 var(--mh)) 0, transparent 65%); transition: opacity .6s, transform 2.2s cubic-bezier(.5,0,1,1); }
.mx.spin .mx-glow { opacity: .95; transform: scale(1.5); }
.mx.born .mx-glow { opacity: .8; transform: scale(1.9); animation: mx-pulse 1.6s ease-in-out infinite; }
@keyframes mx-pulse { 50% { opacity: .55; } }
.mx-rays { width: 180vmax; height: 180vmax; margin: -90vmax 0 0 -90vmax; opacity: 0; transition: opacity .5s;
  background: repeating-conic-gradient(from 0deg, oklch(0.9 0.14 var(--mh) / .35) 0deg 7deg, transparent 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 55%); mask: radial-gradient(circle, #000 0, transparent 55%); }
.mx.born .mx-rays { opacity: 1; animation: mx-rot 14s linear infinite; }
@keyframes mx-rot { to { transform: rotate(360deg); } }
.mx-rings i { position: absolute; left: -110px; top: -110px; width: 220px; height: 220px; border-radius: 50%; border: 2px solid oklch(0.85 0.15 var(--mh) / .7); opacity: 0; }
.mx.spin .mx-rings i { animation: mx-ring 1s ease-in infinite; }
.mx.spin .mx-rings i:nth-child(2) { animation-delay: .33s; }
.mx.spin .mx-rings i:nth-child(3) { animation-delay: .66s; }
.mx.born .mx-rings i { animation: none; opacity: 0; }
@keyframes mx-ring { from { transform: scale(1.8); opacity: 0; } 40% { opacity: .9; } to { transform: scale(.1); opacity: 0; } }
.mx-orbit { width: 0; height: 0; }
.mx-twin { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; transition: transform .45s cubic-bezier(.2,1.4,.5,1); }
.mx-twin .critter { width: 100%; height: 100%; display: block; }
.mx-twin.a { transform: translateX(-60vw); }
.mx-twin.b { transform: translateX(60vw) scaleX(-1); }
.mx.enter .mx-twin.a { transform: translateX(-100px); }
.mx.enter .mx-twin.b { transform: translateX(100px) scaleX(-1); }
.mx.spin .mx-orbit { animation: mx-orbit 2.25s cubic-bezier(.55,0,1,.6) forwards; }
.mx.spin .mx-twin.a { animation: mx-in-a 2.25s cubic-bezier(.5,0,1,.7) forwards; }
.mx.spin .mx-twin.b { animation: mx-in-b 2.25s cubic-bezier(.5,0,1,.7) forwards; }
.mx.spin .mx-spin { animation: mx-rot .5s linear infinite; }
@keyframes mx-orbit { to { transform: rotate(2160deg); } }
@keyframes mx-in-a { from { transform: translateX(-100px); } to { transform: translateX(0) scale(.35); filter: brightness(3); } }
@keyframes mx-in-b { from { transform: translateX(100px) scaleX(-1); } to { transform: translateX(0) scaleX(-.35) scaleY(.35); filter: brightness(3); } }
.mx.spin { animation: mx-shake 2.25s ease-in both; }
@keyframes mx-shake {
  0%, 40% { translate: 0 0; } 50% { translate: -1px 1px; } 60% { translate: 2px -1px; } 70% { translate: -3px 2px; }
  80% { translate: 4px -3px; } 88% { translate: -5px 4px; } 94% { translate: 6px -4px; } 100% { translate: 0 0; }
}
.mx-core { width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: #fff; transform: scale(0);
  box-shadow: 0 0 30px 12px oklch(0.9 0.16 var(--mh)), 0 0 80px 30px oklch(0.75 0.2 var(--mh) / .6); }
.mx.spin .mx-core { animation: mx-core 2.25s cubic-bezier(.6,0,1,.5) forwards; }
@keyframes mx-core { to { transform: scale(2.2); } }
.mx.flash .mx-orbit, .mx.flash .mx-core { display: none; }
.mx-flash { left: 0; top: 0; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.mx.flash .mx-flash { animation: mx-flash .9s ease-out both; }
@keyframes mx-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.mx-wave { width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; border: 6px solid #fff; opacity: 0; }
.mx.born .mx-wave { animation: mx-wave .9s cubic-bezier(.2,.6,.3,1) both; }
@keyframes mx-wave { from { transform: scale(.3); opacity: 1; } to { transform: scale(14); opacity: 0; border-width: 1px; } }
.mx-born { width: 210px; height: 210px; margin: -105px 0 0 -105px; opacity: 0; }
.mx-born .critter { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 18px oklch(0.85 0.17 var(--mh))) drop-shadow(0 0 40px oklch(0.75 0.2 var(--mh) / .7)); }
.mx.born .mx-born { opacity: 1; animation: mx-born .9s cubic-bezier(.3,1.8,.5,1) both; }
.mx.born .mx-born .critter { animation: bob 2s ease-in-out .9s infinite; }
@keyframes mx-born { from { transform: scale(.15) rotate(-30deg); filter: brightness(4); } }
.mx-fx { width: 0; height: 0; }
.mx-fx i { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; animation: mx-spark 1s cubic-bezier(.1,.7,.3,1) forwards; }
.mx-fx i.star { border-radius: 2px; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); width: 16px; height: 16px; }
@keyframes mx-spark { from { transform: translate(0, 0) scale(var(--s)); opacity: 1; } to { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; } }
.mx-text { top: auto; bottom: calc(10vh + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; padding: 0 20px; }
.mx-kicker { font-size: clamp(28px, 11vw, 44px); font-weight: 900; letter-spacing: .04em; line-height: 1; opacity: 0;
  color: oklch(0.93 0.09 var(--mh)); }
.mx.born .mx-kicker { animation: mx-stamp .55s cubic-bezier(.3,1.7,.5,1) .25s both; }
@keyframes mx-stamp { from { transform: scale(2.6) rotate(-8deg); opacity: 0; } to { opacity: 1; } }
.mx-name { font-size: 24px; font-weight: 800; margin-top: 10px; opacity: 0; }
.mx.born .mx-name { animation: fade .5s .5s both; opacity: 1; }
.mx-stars { margin-top: 10px; font-size: 34px; letter-spacing: 6px; opacity: 0; }
.mx.born .mx-stars { opacity: 1; transition: opacity .4s .5s; }
.mx-stars i { font-style: normal; color: rgba(255,255,255,.18); display: inline-block; }
.mx-stars i.lit { color: #ffd60a; animation: mx-star .45s cubic-bezier(.3,1.9,.5,1) both; }
@keyframes mx-star { from { transform: scale(2.4) rotate(-40deg); } }
.mx-tap { margin-top: 22px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .5s; }
.mx.can-close .mx-tap { opacity: .7; animation: mx-pulse 1.4s ease-in-out infinite; }
.mx.reduced *, .mx.reduced .mx-born .critter { animation: none !important; transition: none !important; }
.mx.reduced .mx-orbit, .mx.reduced .mx-core { display: none; }
.mx.reduced .mx-born, .mx.reduced .mx-kicker, .mx.reduced .mx-name, .mx.reduced .mx-stars, .mx.reduced .mx-rays { opacity: 1; }

/* ---------- Settings: Material You grouped lists (Android settings style) ---------- */
.settings-sheet { background: var(--surface-container); }
.settings-sheet .sheet-title { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.01em; margin: 0 4px 4px; }
.m3-section { font-size: 14px; font-weight: 600; color: var(--primary); margin: 22px 16px 8px; letter-spacing: .01em; }
.m3-group { display: grid; gap: 2px; }
.m3-item {
  display: flex; align-items: center; gap: 16px; width: 100%; min-height: 64px; padding: 12px 16px; text-align: left;
  background: var(--group-item); border-radius: 4px; cursor: pointer; color: var(--on-surface);
}
a.m3-item { text-decoration: none; }
.m3-trail { margin-left: auto; color: var(--on-surface-variant); font-size: 20px; }
.m3-item.col { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; cursor: default; }
.m3-group > :first-child { border-top-left-radius: 20px; border-top-right-radius: 20px; }
.m3-group > :last-child { border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; }
.m3-lead { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--primary-container); color: var(--on-primary-container); }
.m3-lead .ms { font-size: 22px; }
.m3-item .li-text b { font-weight: 500; font-size: 16px; }
.m3-item .li-text small { font-size: 14px; line-height: 1.35; display: block; }
.m3-item-label { font-size: 16px; font-weight: 500; }
.m3-item .set-note { margin-top: 0; font-size: 14px; }
.m3-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--on-surface-variant); flex: none; margin-left: auto; position: relative; transition: border-color .2s; }
.m3-radio::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--primary); transform: scale(0); transition: transform .2s cubic-bezier(.2,0,0,1); }
[aria-checked="true"] > .m3-radio { border-color: var(--primary); }
[aria-checked="true"] > .m3-radio::after { transform: scale(1); }
#set-lang .m3-item { min-height: 56px; }
.settings-sheet .lang-note { margin: 10px 16px 0; }
.settings-sheet .sheet-done { margin-top: 28px; }
.settings-sheet .swatches { gap: 10px; }

/* ---------- Display face for headings (body stays Roboto Flex, Material's typeface) ---------- */
.brand-name, .hero-title, .detail-hero h1, .rank-head h2, .col-head h2, .sheet-title, .dialog h2, .fs-name,
.rw-nochest h1, .rw-banner, .mx-kicker, .mx-name, .al-head, .move-name, .rw-card-text b, .rw-level.levelup::after {
  font-family: var(--font-display); font-variation-settings: normal;
}
.rw-banner { font-variation-settings: 'wdth' 75; }
.mx-kicker, .rw-banner, .rw-level.levelup::after { font-weight: 800; }
/* Material Symbols stars instead of text stars */
.stars .ms { font-size: 1.15em; vertical-align: -.15em; margin-right: 1px; }
.mx-stars i { margin: 0 3px; }
.mx-stars .ms { font-size: 1em; }
#set-scale button { flex: 1 1 auto; padding: 0 4px; font-size: 13.5px; letter-spacing: 0; white-space: nowrap; }
#set-scale button[aria-checked="true"]::before { content: none; }

/* Flexibility check answers: same grouped-list look as settings */
.ft-opts { gap: 2px; }
.ft-opts > .fo, .ft-opts > .fo2 { border-radius: 4px; background: var(--group-item); border: 0; }
.ft-opts > :first-child, .ft-opts.two > .fo2:nth-child(2) { border-top-left-radius: 16px; border-top-right-radius: 16px; }
.ft-opts > :last-child { border-bottom-left-radius: 16px; border-bottom-right-radius: 16px; }
.ft-opts > .fo { min-height: 48px; }
.ft-opts > .fo[aria-checked="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }
.ft-opts.two .fo2-head { background: none; padding: 0 4px 4px 12px; }
.flex-sheet, .album-sheet { background: var(--surface-container); }
.flex-sheet .sheet-title, .album-sheet .sheet-title { font-size: 30px; font-weight: 600; margin: 0 4px 8px; }
.rc-meta { display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; row-gap: 2px; }
.rc-cat::after { content: " ·"; color: var(--on-surface-variant); font-weight: 400; }
.rc-n { white-space: nowrap; }

/* Backup code dialog */
.backup-dialog { max-width: min(400px, calc(100vw - 32px)); width: 100%; }
.backup-text { display: block; width: 100%; margin-top: 16px; padding: 12px; border-radius: 12px; resize: none;
  border: 1px solid var(--outline); background: var(--surface-container-highest); color: var(--on-surface);
  font: 12px/1.4 ui-monospace, 'Roboto Mono', monospace; word-break: break-all; }
.backup-text:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.backup-msg { text-align: left; min-height: 1.4em; }
