:root {
  --font-display: 'Fredoka', 'Baloo 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --ink: #1e1b4b;
  --ink-soft: #56527d;
  --ink-mute: #8b88ad;

  --bg: #eef2ff;
  --bg-2: #f8faff;
  --card: #ffffff;
  --line: #e0e6fb;

  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-soft: #e0e7ff;
  --on-primary: #ffffff;

  --accent: #f59e0b;
  --pink: #ec4899;
  --ring: #0ea5e9;

  --good: #16a34a;
  --bad: #e11d48;

  --r-lg: 30px;
  --r-md: 22px;
  --r-sm: 16px;
  --r-xs: 12px;

  --edge: 3px;

  --shadow-clay:
    0 18px 32px -14px rgba(30, 27, 75, 0.34),
    0 8px 16px -8px rgba(30, 27, 75, 0.2);
  --shadow-clay-sm:
    0 10px 18px -10px rgba(30, 27, 75, 0.3),
    0 4px 8px -4px rgba(30, 27, 75, 0.16);
  --shadow-clay-inset:
    inset 0 -7px 12px -6px rgba(30, 27, 75, 0.22),
    inset 0 7px 10px -6px rgba(255, 255, 255, 0.95);

  --shadow-press:
    inset 0 6px 12px -4px rgba(30, 27, 75, 0.3),
    inset 0 -4px 8px -6px rgba(255, 255, 255, 0.7);

  --theme: #4f46e5;
  --theme-dark: #3730a3;
  --theme-deep: #312e81;
  --theme-soft: #e0e7ff;
  --theme-ink: #312e81;
}

[data-theme='green'] { --theme: #22c55e; --theme-dark: #15803d; --theme-deep: #14532d; --theme-soft: #dcfce7; --theme-ink: #14532d; }
[data-theme='rose'] { --theme: #f43f5e; --theme-dark: #be123c; --theme-deep: #9f1239; --theme-soft: #ffe4e6; --theme-ink: #881337; }
[data-theme='blue'] { --theme: #3b82f6; --theme-dark: #1d4ed8; --theme-deep: #1e3a8a; --theme-soft: #dbeafe; --theme-ink: #1e3a8a; }
[data-theme='orange'] { --theme: #f97316; --theme-dark: #c2410c; --theme-deep: #7c2d12; --theme-soft: #ffedd5; --theme-ink: #7c2d12; }
[data-theme='gold'] { --theme: #f59e0b; --theme-dark: #b45309; --theme-deep: #78350f; --theme-soft: #fef3c7; --theme-ink: #78350f; }
[data-theme='indigo'] { --theme: #6366f1; --theme-dark: #4338ca; --theme-deep: #312e81; --theme-soft: #e0e7ff; --theme-ink: #312e81; }

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 12% -8%, #e0e7ff 0%, rgba(224, 231, 255, 0) 62%),
    radial-gradient(900px 560px at 92% 4%, #fce7f3 0%, rgba(252, 231, 243, 0) 58%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 55%, #e9eefd 100%);
  background-attachment: fixed;
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

p { margin: 0; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:disabled { cursor: not-allowed; opacity: 0.55; }

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
  border-radius: 8px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm { width: 17px; height: 17px; }

.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;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(14px, env(safe-area-inset-top))
    max(0px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(0px, env(safe-area-inset-left));
}

.screen {
  display: none;
  width: 100%;
  max-width: 740px;
  flex: 1;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
  animation: screen-in 0.34s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.screen__inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 18px 4px;
}

.screen__inner--center {
  align-items: center;
  text-align: center;
  gap: 16px;
  padding-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 12px 22px;
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  transition: transform 0.16s ease-out, box-shadow 0.16s ease-out, filter 0.16s ease-out;
}

.btn:hover { transform: translateY(-2px); filter: brightness(1.02); }
.btn:active { transform: translateY(1px) scale(0.99); box-shadow: var(--shadow-press); }

.btn--block { width: 100%; }

.btn--primary {
  color: var(--on-primary);
  background: linear-gradient(180deg, #4f46e5 0%, var(--primary-dark) 100%);
  border-color: rgba(255, 255, 255, 0.42);
  text-shadow: 0 1px 1px rgba(30, 27, 75, 0.28);
}

.btn--soft {
  color: var(--theme-ink);
  background: linear-gradient(180deg, #ffffff 0%, var(--theme-soft) 100%);
}

.btn--ghost {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.72);
}

.btn--danger {
  color: #fff;
  background: linear-gradient(180deg, #e11d48 0%, #9f1239 100%);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn--skip {
  min-height: 46px;
  font-size: 0.95rem;
  padding: 8px 18px;
  align-self: center;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 50px;
  height: 50px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #f2f5ff 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  transition: transform 0.16s ease-out, box-shadow 0.16s ease-out;
}

.icon-btn:hover { transform: translateY(-2px); }
.icon-btn:active { transform: translateY(1px); box-shadow: var(--shadow-press); }

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  margin-bottom: 6px;
  color: #fff;
  background: linear-gradient(160deg, #6366f1 0%, var(--primary) 58%, var(--primary-dark) 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  box-shadow: var(--shadow-clay), var(--shadow-clay-inset);
}

.brand__mark .icon { width: 32px; height: 32px; }

.brand__title {
  font-size: clamp(2rem, 9vw, 2.6rem);
  color: var(--primary-dark);
}

.brand__tag {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.section-title {
  font-size: 1.18rem;
  color: var(--ink);
  padding-left: 4px;
}

.section-title--center { text-align: center; padding: 0; }

.section-sub {
  margin-top: -10px;
  font-size: 1rem;
  color: var(--ink-soft);
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-item {
  position: relative;
  display: flex;
  align-items: stretch;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 10px 58px 10px 12px;
  text-align: left;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7ff 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  transition: transform 0.16s ease-out, box-shadow 0.16s ease-out;
}

.profile-chip:hover { transform: translateY(-2px); }
.profile-chip.is-current { border-color: var(--primary); }

.profile-chip__name {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.14rem;
  color: var(--ink);
}

.profile-chip__stars {
  font-weight: 800;
  font-size: 0.9rem;
  color: #b45309;
  white-space: nowrap;
}

.profile-item__delete {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--bad);
  border-radius: 14px;
  transition: background 0.16s ease-out;
}

.profile-item__delete:hover { background: #ffe4e6; }

.avatar-badge {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  font-size: 1.4rem;
  line-height: 1;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow-clay-sm);
}

.player-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
}

.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }

.field__label {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0;
}

.field__input {
  width: 100%;
  min-height: 54px;
  padding: 10px 16px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--ink);
  background: #fff;
  border: var(--edge) solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: inset 0 3px 8px -4px rgba(30, 27, 75, 0.24);
  transition: border-color 0.16s ease-out;
}

.field__input::placeholder { color: var(--ink-mute); }
.field__input:focus { border-color: var(--primary); }

.field__hint { font-size: 0.82rem; color: var(--ink-mute); }

.avatar-field { gap: 10px; }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
}

.avatar-option {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 50px;
  font-size: 1.5rem;
  background: #fff;
  border: var(--edge) solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-clay-sm);
  transition: transform 0.14s ease-out, border-color 0.14s ease-out;
}

.avatar-option:hover { transform: translateY(-2px) scale(1.03); }

.avatar-option[aria-checked='true'] {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.22), var(--shadow-clay-sm);
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px 0;
}

.hud__actions { display: flex; align-items: center; gap: 8px; }

.hud__title {
  font-size: 1.22rem;
  color: var(--primary-dark);
}

.hud__player {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 5px 14px 5px 6px;
  background: linear-gradient(180deg, #ffffff 0%, #f2f5ff 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  transition: transform 0.16s ease-out;
}

.hud__player:hover { transform: translateY(-2px); }

.hud__player-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.greeting {
  font-size: clamp(1.7rem, 7vw, 2.15rem);
  color: var(--primary-dark);
}

.op-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.op-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-align: left;
  background: linear-gradient(165deg, #ffffff 0%, var(--theme-soft) 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
}

.op-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-clay), var(--shadow-clay-inset); }
.op-card:active { transform: translateY(1px) scale(0.995); box-shadow: var(--shadow-press); }

.op-card__symbol {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: none;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(165deg, var(--theme-dark) 0%, var(--theme-deep) 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.55);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  text-shadow: 0 2px 3px rgba(30, 27, 75, 0.25);
}

.op-card__body { display: flex; flex-direction: column; gap: 2px; }

.op-card__title {
  font-family: var(--font-display);
  font-size: 1.16rem;
  font-weight: 600;
  color: var(--theme-ink);
}

.op-card__blurb { font-size: 0.85rem; color: var(--ink-soft); }

.op-card__go { margin-left: auto; color: var(--theme); }

.difficulty {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.difficulty__label {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.chips { display: flex; gap: 8px; flex: 1; }

.chip {
  flex: 1;
  min-height: 48px;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.82);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-clay-sm);
  transition: transform 0.16s ease-out, color 0.16s ease-out, background 0.16s ease-out;
}

.chip:hover { transform: translateY(-2px); }

.chip[aria-checked='true'] {
  color: #fff;
  background: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow-clay-sm), inset 0 -5px 10px -6px rgba(30, 27, 75, 0.5);
}

.home-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.starbar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 8px 18px;
  font-family: var(--font-display);
  color: #78350f;
  background: linear-gradient(180deg, #fffbeb 0%, #fde68a 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
}

.starbar__icon { display: inline-grid; place-items: center; color: #d97706; }
.starbar__icon .icon { fill: currentColor; stroke: currentColor; }
.starbar__value { font-size: 1.2rem; font-weight: 700; }
.starbar__label { font-size: 0.85rem; font-weight: 600; opacity: 0.75; }

.op-pill {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--theme-ink);
  padding: 10px 14px;
  background: linear-gradient(180deg, #ffffff 0%, var(--theme-soft) 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow: var(--shadow-clay-sm);
}

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 50px;
  padding: 0 15px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-mute);
  background: linear-gradient(180deg, #ffffff 0%, #f2f5ff 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  transition: transform 0.2s ease-out, color 0.2s ease-out, background 0.2s ease-out;
}

.streak-chip.is-hot {
  color: #fff;
  background: linear-gradient(180deg, #fb923c 0%, #ea580c 100%);
  transform: scale(1.06);
}

.star-track {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  padding: 4px 0;
}

.star-track__slot {
  display: grid;
  place-items: center;
  width: clamp(20px, 6.4vw, 28px);
  aspect-ratio: 1;
  color: var(--ink-mute);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 9px;
  box-shadow: inset 0 2px 5px -2px rgba(30, 27, 75, 0.3);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.24s ease-out, background 0.24s ease-out;
}

.star-track__slot .icon { width: 62%; height: 62%; }

.star-track__slot.is-correct {
  color: #fff;
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
  transform: scale(1.12);
}

.star-track__slot.is-correct .icon { fill: currentColor; }

.star-track__slot.is-missed {
  color: #fff;
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
}

.star-track__slot.is-current {
  color: var(--theme);
  background: #fff;
  box-shadow: 0 0 0 3px var(--theme-soft), inset 0 2px 5px -2px rgba(30, 27, 75, 0.2);
}

.question-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 18px 24px;
  background: linear-gradient(170deg, #ffffff 0%, var(--theme-soft) 130%);
  border: var(--edge) solid rgba(255, 255, 255, 0.92);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-clay), var(--shadow-clay-inset);
  transition: box-shadow 0.24s ease-out, background 0.24s ease-out;
}

.question-card.is-correct {
  background: linear-gradient(170deg, #ffffff 0%, #bbf7d0 140%);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.35), var(--shadow-clay);
}

.question-card.is-wrong {
  background: linear-gradient(170deg, #ffffff 0%, #fecdd3 140%);
  box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.28), var(--shadow-clay);
  animation: wobble 0.4s ease-in-out;
}

.question-card__equation {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 10vw, 3.1rem);
  font-weight: 600;
  color: var(--theme-ink);
  line-height: 1.15;
}

.answer-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 58px;
  padding: 2px 20px;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--theme-ink);
  background: #fff;
  border: var(--edge) solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: inset 0 4px 10px -6px rgba(30, 27, 75, 0.34);
  transition: border-color 0.2s ease-out, transform 0.2s ease-out, color 0.2s ease-out;
}

.answer-display.is-empty { color: var(--ink-mute); }

.answer-display.is-correct {
  color: var(--good);
  border-color: var(--good);
  animation: pop 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.answer-display.is-wrong { color: var(--bad); border-color: var(--bad); }

.feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 8px 14px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: transparent;
  border-radius: var(--r-md);
  transition: color 0.2s ease-out, background 0.2s ease-out;
}

.feedback--correct { color: #14532d; background: #dcfce7; }
.feedback--wrong { color: #881337; background: #ffe4e6; }
.feedback--hint { color: #1e3a8a; background: #dbeafe; }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 2px;
}

.key {
  display: grid;
  place-items: center;
  min-height: 62px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #f3f5ff 100%);
  border: var(--edge) solid rgba(255, 255, 255, 0.92);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
  user-select: none;
}

.key:hover { transform: translateY(-2px); }
.key:active { transform: translateY(1px) scale(0.97); box-shadow: var(--shadow-press); }

.key .icon { width: 27px; height: 27px; }

.key--primary {
  color: #fff;
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  border-color: rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 2px rgba(30, 27, 75, 0.3);
}

.results-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.result-star {
  display: grid;
  place-items: center;
  width: clamp(62px, 19vw, 84px);
  aspect-ratio: 1;
  color: #d7dcf0;
  background: linear-gradient(180deg, #ffffff 0%, #eef1fb 100%);
  border: var(--edge) solid #fff;
  border-radius: 26px;
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
}

.result-star .icon { width: 46%; height: 46%; }

.result-star.is-earned {
  color: #fff;
  background: linear-gradient(180deg, #fcd34d 0%, #f59e0b 72%, #d97706 100%);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-clay), inset 0 -8px 14px -8px rgba(120, 53, 15, 0.5);
  animation: star-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: var(--delay, 0ms);
}

.result-star.is-earned .icon { fill: currentColor; }

.results-title {
  font-size: clamp(1.75rem, 8vw, 2.3rem);
  color: var(--primary-dark);
}

.results-sub {
  font-family: var(--font-display);
  font-size: 1.06rem;
  color: var(--ink-soft);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  margin: 4px 0 0;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
}

.stat__label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.stat__value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  background: linear-gradient(170deg, #ffffff 0%, var(--theme-soft) 130%);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
}

.summary-card__icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
  color: #fff;
  background: linear-gradient(170deg, var(--theme-dark) 0%, var(--theme-deep) 100%);
  border-radius: 12px;
}

.summary-card__icon .icon { width: 18px; height: 18px; }

.summary-card__value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--theme-ink);
}

.summary-card__label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.op-stats { display: flex; flex-direction: column; gap: 10px; }

.op-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-clay-sm), var(--shadow-clay-inset);
}

.op-stat__symbol {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(165deg, var(--theme-dark) 0%, var(--theme-deep) 100%);
  border-radius: 14px;
  text-shadow: 0 1px 2px rgba(30, 27, 75, 0.28);
}

.op-stat__body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.op-stat__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }

.op-stat__name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.op-stat__value { font-size: 0.82rem; font-weight: 700; color: var(--ink-mute); white-space: nowrap; }

.op-stat__bar {
  height: 10px;
  background: #e8ecfb;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px -2px rgba(30, 27, 75, 0.3);
}

.op-stat__fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--theme) 0%, var(--theme-dark) 100%);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 0.9, 0.3, 1);
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.86);
  border: var(--edge) solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-clay-sm);
}

.history__symbol {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(165deg, var(--theme-dark) 0%, var(--theme-deep) 100%);
  border-radius: 12px;
}

.history__body { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.history__title {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}

.history__meta { font-size: 0.78rem; color: var(--ink-mute); }

.history__score {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--theme-ink);
}

.history__empty {
  padding: 18px;
  text-align: center;
  font-size: 0.94rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.7);
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 27, 75, 0.42);
  backdrop-filter: blur(3px);
  animation: fade-in 0.24s ease-out both;
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
  border: var(--edge) solid #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-clay);
  animation: sheet-in 0.3s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.modal__head { display: flex; align-items: center; justify-content: space-between; }

.modal__title { font-size: 1.3rem; color: var(--primary-dark); }

.toggle-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 6px 2px;
  border-bottom: 2px solid var(--line);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-row__label {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink);
}

.switch {
  position: relative;
  width: 62px;
  height: 36px;
  flex: none;
  background: #d7dcf0;
  border-radius: 999px;
  box-shadow: inset 0 3px 7px -3px rgba(30, 27, 75, 0.42);
  transition: background 0.22s ease-out;
}

.switch__dot {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 3px 7px -2px rgba(30, 27, 75, 0.45);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch[aria-checked='true'] { background: linear-gradient(180deg, #34d399 0%, #16a34a 100%); }
.switch[aria-checked='true'] .switch__dot { transform: translateX(26px); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 80;
  max-width: min(92vw, 440px);
  padding: 12px 20px;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 500;
  color: #fff;
  text-align: center;
  background: linear-gradient(180deg, #4c486f 0%, #1e1b4b 100%);
  border-radius: 999px;
  box-shadow: var(--shadow-clay);
  opacity: 0;
  transform: translate(-50%, 18px);
  pointer-events: none;
  transition: opacity 0.26s ease-out, transform 0.26s cubic-bezier(0.22, 0.9, 0.3, 1);
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

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

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes wobble {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-7px); }
  46% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
}

@keyframes star-pop {
  0% { opacity: 0; transform: scale(0.4) rotate(-22deg); }
  62% { opacity: 1; transform: scale(1.14) rotate(6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@media (min-width: 560px) {
  .op-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }

  .screen__inner { padding: 10px 24px 6px; }

  .keypad { gap: 12px; }
}

@media (min-width: 860px) {
  .screen__inner { gap: 20px; }

  .key { min-height: 66px; }
}

@media (max-width: 380px) {
  .screen__inner { padding: 6px 12px 4px; gap: 14px; }
  .key { min-height: 56px; font-size: 1.5rem; }
  .avatar-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
