/* =========================================================================
   Freestyle Academy — web design system
   Tokens taken verbatim from ui/theme/Color.kt and ui/theme/DesignTokens.kt
   ========================================================================= */

:root {
  /* Core palette — Color.kt */
  --ink: #04050B;
  --bg: #080A12;
  --surface: #181C2B;
  --surface-high: #232839;
  --purple: #7B35FF;
  --purple-soft: #A86CFF;
  --cyan: #23D7F2;
  --magenta: #FF4FD8;
  --gold: #FFC857;
  --text-primary: #F8F8FC;
  --text-secondary: #B7B9C7;
  --text-muted: #777B8D;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);
  --border-accent: rgba(123, 53, 255, 0.5);
  --success: #55D68B;
  --error: #FF5F70;

  /* Per-mode accent, overridden by the active battle/round theme */
  --accent: var(--purple);
  --accent-bright: var(--cyan);
  --on-accent: #FFFFFF;

  /* Spacing — FreestyleSpace */
  --sp-xxs: 4px;
  --sp-xs: 8px;
  --sp-sm: 12px;
  --sp-md: 16px;
  --sp-lg: 20px;
  --sp-xl: 24px;
  --sp-xxl: 32px;

  /* Radius — FreestyleRadii */
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 30px;

  /* Layout — LayoutTokens */
  --gutter: 18px;
  --screen-pad-y: 18px;
  --section-gap: 22px;
  --item-gap: 12px;
  --card-pad: 18px;
  --touch: 48px;
  --nav-h: 76px;
  --hero-min-h: 188px;
  --list-item-min-h: 72px;
  --timer-d: 190px;
  --timer-stroke: 12px;

  --max-w: 560px;
  --motion-fast: 180ms;
  --motion-medium: 320ms;

  --font: "Satoshi", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bebas Neue", "Oswald", var(--font);
}

:root[data-theme="light"] {
  --ink: #FFFFFF;
  --bg: #F5F3FA;
  --surface: #FFFFFF;
  --surface-high: #EDE9F7;
  --text-primary: #11131D;
  --text-secondary: #535769;
  --text-muted: #737789;
  --border-subtle: rgba(4, 5, 11, 0.09);
  --border-strong: rgba(4, 5, 11, 0.19);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; }

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.02em; }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-bright); }

/* App background gradient — DarkFreestyleGradients.appBackground + purpleGlow */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 42% at 80% 8%, color-mix(in srgb, var(--accent) 34%, transparent), transparent 70%),
    radial-gradient(50% 38% at 6% 88%, color-mix(in srgb, var(--accent-bright) 22%, transparent), transparent 72%),
    linear-gradient(180deg, var(--ink), var(--bg) 46%, #0C1020);
  transition: background var(--motion-medium) ease;
}

#app {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  padding: var(--screen-pad-y) var(--gutter) calc(var(--nav-h) + 30px);
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
  animation: fade-in var(--motion-fast) ease-out;
}
.screen--flow { padding-bottom: 30px; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

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

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  min-height: var(--touch);
}
.topbar__title { flex: 1; text-align: center; font-size: 18px; font-weight: 700; }
.topbar__spacer { width: var(--touch); flex: none; }

.iconbtn {
  width: var(--touch); height: var(--touch);
  flex: none;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  display: inline-grid;
  place-items: center;
  color: var(--text-primary);
  transition: background var(--motion-fast) ease;
}
.iconbtn:hover { background: color-mix(in srgb, var(--text-primary) 10%, transparent); }
.iconbtn:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.iconbtn--bordered {
  border-color: var(--border-subtle);
  background: color-mix(in srgb, var(--surface-high) 80%, transparent);
}
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--card-pad);
}
.card--glass {
  background: color-mix(in srgb, var(--surface-high) 88%, transparent);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
  backdrop-filter: blur(12px);
}
.card--flush { padding: 0; overflow: hidden; }

.section { display: flex; flex-direction: column; gap: var(--item-gap); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-sm); }
.section__title { font-size: 18px; font-weight: 700; }

.eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-muted);
}
.muted { color: var(--text-secondary); font-size: 15px; line-height: 1.47; }
.dim { color: var(--text-muted); font-size: 12px; line-height: 1.45; }

.stack { display: flex; flex-direction: column; gap: var(--sp-sm); }
.row { display: flex; align-items: center; gap: var(--sp-sm); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* ---------- Buttons ---------- */

.btn {
  min-height: 54px;
  padding: 0 var(--sp-lg);
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 700; letter-spacing: .02em;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-xs);
  width: 100%;
  transition: transform var(--motion-fast) ease, filter var(--motion-fast) ease;
}
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.btn--primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-bright));
  color: var(--on-accent);
  box-shadow: 0 12px 30px -14px color-mix(in srgb, var(--accent) 90%, transparent);
}
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn--outline { background: transparent; border-color: var(--border-strong); }
.btn--outline:hover:not(:disabled) { background: color-mix(in srgb, var(--text-primary) 8%, transparent); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn--danger { background: transparent; border-color: var(--error); color: var(--error); }
.btn--compact { min-height: 46px; }

.btn-row { display: flex; gap: var(--sp-sm); }
.btn-row .btn { flex: 1; }

/* ---------- Pills / chips / badges ---------- */

.pill {
  display: inline-flex; align-items: center; gap: var(--sp-xs);
  padding: 7px var(--sp-md);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  font-size: 13px; font-weight: 700;
  align-self: flex-start;
}
.pill svg { width: 15px; height: 15px; }
.pill--gold {
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  border-color: color-mix(in srgb, var(--gold) 42%, transparent);
  color: var(--gold);
}
.pill--muted {
  background: color-mix(in srgb, var(--text-muted) 14%, transparent);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-bright) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-bright) 32%, transparent);
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  color: var(--accent-bright);
  white-space: nowrap;
}
.chip-row { display: flex; gap: var(--sp-xs); flex-wrap: wrap; }

.lock {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .05em;
  color: var(--gold);
}
.lock svg { width: 13px; height: 13px; }

/* ---------- Home ---------- */

.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-sm); }
.home-head h1 { font-size: 30px; line-height: 1.07; letter-spacing: -0.5px; }
.home-head p { margin: 5px 0 0; color: var(--text-secondary); font-size: 15px; }

/* Featured hero — DarkFreestyleGradients.featuredCard */
.hero {
  position: relative;
  min-height: var(--hero-min-h);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-accent);
  padding: var(--sp-xl);
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--sp-sm);
  text-align: left; color: inherit; width: 100%;
  background:
    linear-gradient(135deg,
      var(--surface-high),
      color-mix(in srgb, var(--purple) 52%, transparent) 42%,
      color-mix(in srgb, var(--magenta) 20%, transparent) 72%,
      color-mix(in srgb, var(--cyan) 18%, transparent));
  box-shadow: 0 24px 48px -28px color-mix(in srgb, var(--purple) 90%, transparent);
  overflow: hidden;
}
.hero__eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: rgba(255,255,255,.72); }
.hero__title { font-size: 30px; line-height: 1.04; color: #fff; }
.hero__desc { font-size: 14px; line-height: 1.45; color: rgba(255,255,255,.82); margin: 0; }

/* Mode / list rows */
.row-card {
  width: 100%;
  min-height: var(--list-item-min-h);
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  text-align: left; color: inherit;
  transition: border-color var(--motion-fast) ease, transform var(--motion-fast) ease;
}
.row-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.row-card:active { transform: scale(.99); }
.row-card:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.row-card[data-locked="true"] { opacity: .72; }

.row-card__icon {
  width: 44px; height: 44px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: #fff;
}
.row-card__icon svg { width: 22px; height: 22px; }
.row-card__title { font-size: 15px; font-weight: 700; }
.row-card__sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.4; }
.row-card__arrow { color: var(--text-muted); flex: none; }
.row-card__arrow svg { width: 20px; height: 20px; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-sm); }
.tool-card {
  padding: var(--sp-md);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  display: flex; flex-direction: column; gap: 7px;
  text-align: left; color: inherit;
}
.tool-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.tool-card svg { width: 22px; height: 22px; color: var(--accent-bright); }
.tool-card__title { font-weight: 700; font-size: 15px; }

/* ---------- Selectable options ---------- */

.option {
  width: 100%;
  min-height: 62px;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-high) 42%, transparent);
  display: flex; align-items: center; gap: var(--sp-sm);
  text-align: left; color: inherit;
  transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease;
}
.option:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.option:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.option[aria-pressed="true"], .option[aria-checked="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}
.option__title { font-size: 15px; font-weight: 700; }
.option__sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; line-height: 1.4; }
.option__mark { flex: none; color: var(--accent); opacity: 0; }
.option[aria-pressed="true"] .option__mark,
.option[aria-checked="true"] .option__mark { opacity: 1; }
.option__mark svg { width: 22px; height: 22px; }
.option__order {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  font-size: 12px; font-weight: 800;
}

.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-sm); }

/* Drag-to-reorder handle */
.drag-handle { flex: none; color: var(--text-muted); cursor: grab; touch-action: none; }
.drag-handle svg { width: 20px; height: 20px; }
.option[data-dragging="true"] { opacity: .5; }

/* ---------- Inputs ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.input, .select, .textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 11px var(--sp-md);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 15px;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 2px solid var(--accent-bright); outline-offset: 2px;
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

.searchbar { position: relative; }
.searchbar .input { padding-left: 44px; }
.searchbar__icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.searchbar__icon svg { width: 20px; height: 20px; }

/* ---------- Live turn screen ---------- */

.turn-head { text-align: center; }
.turn-head__mode { font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--accent-bright); }
.turn-head__round { font-size: 26px; font-weight: 800; margin-top: 3px; }
.turn-head__meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: var(--sp-sm); font-size: 13px; font-weight: 700;
}
.turn-head__live { color: var(--error); display: inline-flex; align-items: center; gap: 6px; }
.turn-head__live::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--error); animation: rec-pulse 1.4s ease-in-out infinite;
}
@keyframes rec-pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.round-progress { display: flex; gap: 7px; }
.round-progress span {
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--surface-high);
  transition: background var(--motion-medium) ease;
}
.round-progress span[data-done="true"] { background: var(--accent); }

/* Count-UP timer ring */
.timer {
  width: var(--timer-d); height: var(--timer-d);
  margin: 0 auto;
  display: grid; place-items: center;
  position: relative;
}
.timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer__glow {
  position: absolute; inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 45%, transparent), transparent 68%);
  opacity: 0;
  transition: opacity 110ms linear, transform 110ms linear;
  pointer-events: none;
}
.timer__inner { position: relative; text-align: center; }
.timer__label { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--text-secondary); }
.timer__value {
  font-size: 50px; line-height: 1.08; font-weight: 800; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.timer__role {
  margin-top: 3px;
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  color: var(--accent-bright);
}

/* Stimulus panels */
.stimulus {
  border-radius: var(--r-xl);
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-high) 88%, transparent);
  padding: var(--sp-lg);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-sm);
  text-align: center;
}
.stimulus__label { font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--accent-bright); }
.stimulus__word {
  font-size: 40px; line-height: 1.05; font-weight: 800; letter-spacing: -1px;
  word-break: break-word;
}
.stimulus__word[data-long="true"] { font-size: 28px; }
.stimulus__key { font-size: 14px; font-weight: 700; color: var(--text-secondary); }
.stimulus__hint { font-size: 12.5px; color: var(--text-muted); margin: 0; }

.stimulus__scene {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 46vh;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.stimulus__scene img { width: 100%; height: 100%; object-fit: cover; display: block; }

.object-set { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-sm); width: 100%; }
.object-set figure {
  margin: 0; display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.object-set__art {
  width: 100%; aspect-ratio: 1;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--border-subtle);
  display: grid; place-items: center;
  padding: 9px;
}
.object-set__art img { width: 100%; height: 100%; object-fit: contain; }
.object-set figcaption { font-size: 12px; font-weight: 700; text-align: center; line-height: 1.25; }

/* Rotating word / word grid */
.word-solo {
  font-size: 44px; line-height: 1.04; font-weight: 800; letter-spacing: -1.2px;
  text-align: center; word-break: break-word;
}
.word-grid { display: flex; flex-wrap: wrap; gap: var(--sp-xs); justify-content: center; }
.word-chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-high) 55%, transparent);
  font-size: 15px; font-weight: 600;
  transition: transform var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
.word-chip:hover { border-color: var(--accent-bright); }
.word-chip:active { transform: scale(.94); }

/* Beat transport: [track name] [REC] [play/pause] [next] [mute] */
.transport {
  display: flex; align-items: center; gap: var(--sp-xs);
  padding: 10px var(--sp-sm);
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.transport__track {
  flex: 1; min-width: 0;
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.transport__rec {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--error);
  animation: rec-pulse 1.4s ease-in-out infinite;
}
.transport__rec[data-paused="true"] { opacity: .3; animation: none; }
.transport__btn {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%; border: none;
  background: transparent; color: var(--text-primary);
  display: grid; place-items: center;
}
.transport__btn svg { width: 19px; height: 19px; }
.transport__btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: var(--on-accent);
}
.transport__btn:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

/* ---------- Progress bars & stats ---------- */

.bar { height: 10px; border-radius: 999px; background: var(--surface-high); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width var(--motion-medium) ease;
}
.bar--thin { height: 7px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-sm); }
.stat-grid--3 { grid-template-columns: repeat(3, 1fr); }
.stat-tile {
  padding: var(--sp-md);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.stat-tile svg { width: 22px; height: 22px; }
.stat-tile__value { font-size: 20px; font-weight: 800; }
.stat-tile__label { font-size: 12px; color: var(--text-secondary); }

/* Weekly line graph */
.week-graph { width: 100%; height: 128px; display: block; }
.week-graph__labels {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  margin-top: 5px;
}

/* Achievements */
.achv {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: var(--sp-sm);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
}
.achv[data-locked="true"] { opacity: .55; }
.achv__badge {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--gold) 15%, transparent);
  color: var(--gold);
}
.achv__badge svg { width: 21px; height: 21px; }
.achv[data-locked="true"] .achv__badge {
  background: color-mix(in srgb, var(--text-muted) 15%, transparent);
  color: var(--text-muted);
}
.achv__title { font-weight: 700; font-size: 14.5px; }
.achv__desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.achv__state { font-size: 11px; font-weight: 800; color: var(--text-muted); flex: none; }

/* ---------- Avatar ---------- */

.avatar {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--purple), var(--purple-soft), var(--cyan));
  font-size: 32px; font-weight: 800; color: #fff;
  overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 48px; height: 48px; font-size: 17px; }

/* ---------- Lists ---------- */

.list { display: flex; flex-direction: column; gap: var(--sp-xs); }
.list--roomy { gap: var(--sp-sm); }

.line-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-sm);
  min-height: var(--touch);
  padding: 10px var(--sp-md);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  font-size: 15px;
  width: 100%; text-align: left; color: inherit;
}
.line-row:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---------- Empty / notice ---------- */

.empty {
  border-radius: var(--r-lg);
  border: 1px dashed var(--border-strong);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  padding: var(--sp-xxl) var(--sp-lg);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-xs);
}
.empty__title { font-size: 17px; font-weight: 700; }
.empty__msg { font-size: 14px; color: var(--text-secondary); line-height: 1.5; max-width: 42ch; }

.notice {
  display: flex; gap: var(--sp-sm); align-items: flex-start;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-sm);
  border: 1px solid color-mix(in srgb, var(--gold) 38%, transparent);
  background: color-mix(in srgb, var(--gold) 9%, transparent);
  font-size: 13px; line-height: 1.5;
}
.notice svg { width: 17px; height: 17px; color: var(--gold); flex: none; margin-top: 2px; }
.notice--error { border-color: color-mix(in srgb, var(--error) 38%, transparent); background: color-mix(in srgb, var(--error) 9%, transparent); }
.notice--error svg { color: var(--error); }

/* Upgrade prompt that replaces gated content */
.upsell {
  border-radius: var(--r-lg);
  border: 1px solid color-mix(in srgb, var(--gold) 34%, transparent);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--gold) 10%, transparent),
    color-mix(in srgb, var(--purple) 12%, transparent));
  padding: var(--sp-lg);
  display: flex; flex-direction: column; gap: var(--sp-sm);
}
.upsell__title { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.upsell__title svg { width: 17px; height: 17px; color: var(--gold); }

/* ---------- Results ---------- */

.result-xp { font-size: 56px; font-weight: 800; letter-spacing: -2px; color: var(--gold); text-align: center; }
.result-title { font-size: 28px; font-weight: 800; text-align: center; line-height: 1.1; }

.summary-row { display: flex; justify-content: space-between; gap: var(--sp-md); padding: 9px 0; font-size: 14px; }
.summary-row + .summary-row { border-top: 1px solid var(--border-subtle); }
.summary-row dt { color: var(--text-secondary); margin: 0; }
.summary-row dd { margin: 0; font-weight: 700; text-align: right; }

.transcript {
  font-size: 14px; line-height: 1.6; color: var(--text-secondary);
  background: color-mix(in srgb, var(--surface-high) 45%, transparent);
  border-radius: var(--r-sm);
  padding: var(--sp-sm);
  max-height: 240px; overflow-y: auto; white-space: pre-wrap;
}

/* ---------- Liga ---------- */

.tabs { display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-subtle); }
.tabs button {
  flex: 1; min-height: 40px; border: none; border-radius: 999px; background: transparent;
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }

.rank-row {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: 10px var(--sp-sm);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  width: 100%; text-align: left; color: inherit;
}
.rank-row[data-self="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.rank-row__pos { width: 26px; flex: none; font-size: 14px; font-weight: 800; color: var(--text-muted); text-align: center; }
.rank-row__name { font-size: 14.5px; font-weight: 700; }
.rank-row__meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.rank-row__pts { font-size: 14px; font-weight: 800; color: var(--accent-bright); flex: none; }

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--max-w);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-subtle);
  z-index: 40;
}
.bottom-nav[hidden] { display: none; }
.bottom-nav__item {
  flex: 1; border: none; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  position: relative;
  transition: color var(--motion-fast) ease;
}
.bottom-nav__item svg { width: 22px; height: 22px; }
.bottom-nav__item[aria-current="page"] { color: var(--purple-soft); }
.bottom-nav__item[data-locked="true"] .bottom-nav__lock {
  position: absolute; top: 9px; right: 50%; margin-right: -18px;
  width: 12px; height: 12px; color: var(--gold);
}
.bottom-nav__item:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -4px; }

/* ---------- Toast / dialog / spinner ---------- */

.toast-host {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: var(--sp-xs);
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  background: var(--surface-high);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: var(--sp-sm) var(--sp-md);
  font-size: 14px;
  box-shadow: 0 16px 40px -18px rgba(0,0,0,.9);
  animation: toast-in var(--motion-fast) ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4,5,11,.76);
  backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: var(--gutter);
}
.dialog {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  display: flex; flex-direction: column; gap: var(--sp-md);
}
.dialog__title { font-size: 19px; font-weight: 800; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, var(--text-primary) 20%, transparent);
  border-top-color: var(--accent-bright);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Utilities ---------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Compact phones (Galaxy A10 ≈ 360px) */
@media (max-width: 380px) {
  :root { --gutter: 14px; --timer-d: 164px; }
  .home-head h1 { font-size: 26px; }
  .hero__title { font-size: 26px; }
  .timer__value { font-size: 42px; }
  .stimulus__word { font-size: 34px; }
  .word-solo { font-size: 36px; }
  .stat-grid--3 { grid-template-columns: 1fr 1fr; }
}

/* =========================================================================
   Screens added in the second pass: perfil, progreso, librería, planes,
   ajustes, login, onboarding, studio, el tablero personalizado.
   ========================================================================= */

.view { display: flex; flex-direction: column; min-height: 100dvh; }

/* A bottom-tab screen renders its sections straight into the view, so the
   view itself carries the gutter, the rhythm and the clearance the stacked
   `.screen` wrapper provides everywhere else. The extra bottom room is for
   the floating "Sobre la app" link, which sits above the bar. */
.view--tab {
  padding: var(--screen-pad-y) var(--gutter) calc(var(--nav-h) + 62px);
  gap: var(--section-gap);
  animation: fade-in var(--motion-fast) ease-out;
}

/* ---------- Avatars ---------- */

.avatar--md { width: 64px; height: 64px; font-size: 22px; }
.avatar--lg { width: 96px; height: 96px; }
.avatar--art { background: var(--surface-high); }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: var(--sp-sm);
}
.avatar-pick {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-secondary);
  min-height: var(--touch);
}
.avatar-pick[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--text-primary);
}
.avatar-pick[data-locked="true"] { opacity: .55; }
.avatar-pick__label { font-size: 11px; font-weight: 700; }
.avatar-pick__lock {
  position: absolute; top: 6px; right: 6px; color: var(--gold);
  display: grid; place-items: center;
}

/* ---------- Perfil ---------- */

.profile-card {
  display: flex; align-items: center; gap: var(--sp-md);
  padding: var(--card-pad);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
/* At 360px an avatar, a name block and a button do not share one row: the
   middle column collapses and the punchline wraps a word per line. The name
   block is allowed to shrink and the button takes a row of its own. */
.profile-card > .grow { min-width: 0; flex: 1 1 130px; }
.profile-card > .btn { flex: 1 0 100%; }
.profile-card__avatar { border: none; background: none; padding: 0; }
.profile-card__alias { margin: 0; font-size: 21px; font-weight: 800; }
.profile-card__meta { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }
.profile-card__punch {
  margin: 8px 0 0; font-size: 13px; font-style: italic; color: var(--text-secondary);
}

/* ---------- Progreso ---------- */

.level-card {
  display: flex; flex-direction: column; gap: var(--sp-sm);
  padding: var(--card-pad);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-accent);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 60%),
    var(--surface);
}
.level-card__level { display: block; font-family: var(--font-display); font-size: 32px; letter-spacing: .02em; }
.level-card__xp { font-weight: 700; color: var(--accent-bright); font-size: 14px; }

/* ---------- Librería ---------- */

.rhyme-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--sp-sm);
}
.rhyme-tile {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  min-height: var(--touch);
  padding: 13px var(--sp-sm);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-primary);
}
.rhyme-tile:hover, .rhyme-tile:focus-visible { border-color: var(--accent); }
.rhyme-tile__key { font-family: var(--font-display); font-size: 21px; letter-spacing: .04em; }
.rhyme-tile__count { font-size: 11px; color: var(--text-muted); }

.word-list { display: flex; flex-direction: column; gap: 6px; }
.word-row {
  display: flex; align-items: center; gap: 6px;
  min-height: var(--touch);
  padding: 6px 8px 6px var(--sp-md);
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  font-size: 15px;
}

/* ---------- Chips picker (tablero personalizado) ---------- */

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-grid .chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 13px;
  background: var(--surface); border-color: var(--border-subtle); color: var(--text-secondary);
  font-family: var(--font-display); font-size: 17px; letter-spacing: .04em;
}
.chip-grid .chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color: var(--accent); color: var(--text-primary);
}
.chip-grid .chip:disabled { opacity: .4; }
.chip__order {
  display: grid; place-items: center;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font); font-size: 11px; font-weight: 800;
}
.chip__count { font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--text-muted); }

.board-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--sp-md); }
.board-group__key {
  margin: 0; font-family: var(--font-display); font-size: 19px;
  letter-spacing: .06em; color: var(--accent-bright);
}
.board-clock {
  margin: 0; text-align: center;
  font-family: var(--font-display); font-size: 46px; letter-spacing: .02em;
}

/* ---------- Planes ---------- */

.plan-list { display: flex; flex-direction: column; gap: var(--sp-md); }
.plan-card {
  display: flex; flex-direction: column; gap: var(--sp-sm);
  padding: var(--card-pad);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
}
.plan-card[data-featured="true"] { border-color: var(--border-accent); }
.plan-card[data-current="true"] { border-color: var(--gold); }
.plan-card__name { font-family: var(--font-display); font-size: 27px; letter-spacing: .03em; }
.plan-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plan-features li {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13px; color: var(--text-secondary);
}
.plan-features li[data-on="true"] { color: var(--text-primary); }
.plan-features li[data-on="true"] svg { color: var(--success); flex: none; }
.plan-features li[data-on="false"] { opacity: .5; }
.plan-features li[data-on="false"] svg { color: var(--text-muted); flex: none; }

/* ---------- Ajustes ---------- */

.switch {
  width: 46px; height: 27px; flex: none;
  border-radius: 999px; background: var(--surface-high);
  border: 1px solid var(--border-subtle);
  display: flex; align-items: center; padding: 2px;
  transition: background var(--motion-fast) ease;
}
.switch i {
  width: 21px; height: 21px; border-radius: 50%; background: var(--text-muted);
  transition: transform var(--motion-fast) ease, background var(--motion-fast) ease;
}
.switch[data-on="true"] { background: color-mix(in srgb, var(--accent) 45%, var(--surface-high)); }
.switch[data-on="true"] i { transform: translateX(19px); background: #fff; }

.row-card--danger .row-card__title { color: var(--error); }
.row-card--danger .row-card__icon { color: var(--error); }

.iconbtn--sm { width: 38px; height: 38px; flex: none; }

/* ---------- Login / onboarding ---------- */

.screen--auth, .screen--onboarding { justify-content: center; padding-bottom: 30px; }

.brand-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  color: #fff;
}

.divider {
  display: flex; align-items: center; gap: var(--sp-sm);
  color: var(--text-muted); font-size: 12px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border-subtle);
}

.btn--google {
  background: #fff; color: #1F1F1F; border: 1px solid var(--border-strong);
}
.btn--google:hover { background: #F1F1F4; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); flex: none; }
.check a { color: var(--accent-bright); }

.field__hint { margin: 0; font-size: 12px; color: var(--text-muted); }
.input--area { min-height: 132px; padding-top: 13px; resize: vertical; line-height: 1.55; }

.onboard {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-md); padding: var(--sp-xl) 0;
}
.onboard__art {
  display: grid; place-items: center;
  width: 96px; height: 96px; border-radius: var(--r-xl);
  background:
    radial-gradient(120% 120% at 20% 10%, color-mix(in srgb, var(--purple) 55%, transparent), transparent 65%),
    var(--surface);
  border: 1px solid var(--border-accent);
  color: var(--accent-bright);
}
.onboard__title { margin: 0; font-family: var(--font-display); font-size: 33px; line-height: 1.05; letter-spacing: .01em; }
.onboard__body { margin: 0; color: var(--text-secondary); font-size: 15px; line-height: 1.6; max-width: 34ch; }

.dots { display: flex; gap: 7px; justify-content: center; }
.dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong);
  transition: width var(--motion-fast) ease, background var(--motion-fast) ease;
}
.dots span[data-on="true"] { width: 22px; border-radius: 999px; background: var(--accent); }

/* ---------- Audio ---------- */

audio { width: 100%; height: 38px; border-radius: 999px; }

/* Compact phones */
@media (max-width: 380px) {
  .onboard__title { font-size: 28px; }
  .level-card__level { font-size: 28px; }
  .board-clock { font-size: 38px; }
  .avatar-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .rhyme-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}
