/* Catppuccin Mocha (Dark) */
:root[data-theme="dark"] {
  --base: #1e1e2e;
  --mantle: #181825;
  --crust: #11111b;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --text: #cdd6f4;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --blue: #89b4fa;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --red: #f38ba8;
  --mauve: #cba6f7;
  --peach: #fab387;
  --teal: #94e2d5;
  --sky: #89dceb;
}

:root[data-theme="space"] {
  --base: #0c0a1e;
  --mantle: #141138;
  --crust: #08061a;
  --surface0: #1c1850;
  --surface1: #2a2478;
  --surface2: #3c3690;
  --overlay0: #5a54a0;
  --overlay1: #8078c0;
  --text: #e0d8ff;
  --subtext0: #a8a0d0;
  --subtext1: #c8c0e8;
  --blue: #6a9aff;
  --green: #7af0d8;
  --yellow: #ffd870;
  --red: #ff7090;
  --mauve: #c890ff;
  --peach: #ffb070;
  --teal: #70e8d0;
  --sky: #80c8ff;
}

:root[data-theme="ocean"] {
  --base: #042835;
  --mantle: #073443;
  --crust: #022028;
  --surface0: #0b4858;
  --surface1: #0f5c74;
  --surface2: #147090;
  --overlay0: #2e98b0;
  --overlay1: #50b8d0;
  --text: #d8f0f8;
  --subtext0: #a0d0e0;
  --subtext1: #c0e0ec;
  --blue: #60c0ff;
  --green: #60e8b0;
  --yellow: #ffe088;
  --red: #ff8080;
  --mauve: #a090ff;
  --peach: #ffb888;
  --teal: #50e8d0;
  --sky: #80d8ff;
}

:root[data-theme="forest"] {
  --base: #0c2014;
  --mantle: #13301e;
  --crust: #081810;
  --surface0: #1a4228;
  --surface1: #225230;
  --surface2: #2c663a;
  --overlay0: #4a8058;
  --overlay1: #70a078;
  --text: #e0f0d8;
  --subtext0: #a8c8a8;
  --subtext1: #c8e0c0;
  --blue: #80d0a0;
  --green: #a0e880;
  --yellow: #e8d868;
  --red: #ff9878;
  --mauve: #c8a0e8;
  --peach: #ffb890;
  --teal: #78d898;
  --sky: #90d8c0;
}

:root[data-theme="candy"] {
  --base: #2a1830;
  --mantle: #3c2244;
  --crust: #201028;
  --surface0: #522c5a;
  --surface1: #6c3c78;
  --surface2: #884a98;
  --overlay0: #a468b8;
  --overlay1: #c488d4;
  --text: #fff0f8;
  --subtext0: #e0b8d0;
  --subtext1: #f0c8e0;
  --blue: #80a8ff;
  --green: #88f0b8;
  --yellow: #ffe088;
  --red: #ff80b0;
  --mauve: #ff90e0;
  --peach: #ffa0c0;
  --teal: #80f0d0;
  --sky: #a0c0ff;
}

/* Catppuccin Latte (Light) */
:root[data-theme="light"] {
  --base: #eff1f5;
  --mantle: #e6e9ef;
  --crust: #dce0e8;
  --surface0: #ccd0da;
  --surface1: #bcc0cc;
  --surface2: #acb0be;
  --overlay0: #9ca0b0;
  --overlay1: #8c8fa1;
  --text: #4c4f69;
  --subtext0: #6c6f85;
  --subtext1: #5c5f77;
  --blue: #1e66f5;
  --green: #40a02b;
  --yellow: #df8e1d;
  --red: #d20f39;
  --mauve: #8839ef;
  --peach: #fe640b;
  --teal: #179299;
  --sky: #04a5e5;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--base);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
  padding: 1.5rem 1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 1100px) {
  body {
    padding: 2rem 1.5rem;
  }
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr) 320px;
    align-items: start;
    gap: 1.5rem;
  }
}

.card {
  background-color: var(--surface0);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--surface1);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

@media (min-width: 1100px) {
  .rail {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
  }
}

.center-stage {
  padding: 1.5rem;
  min-width: 0;
}

.title-block h2 {
  margin: 0;
  font-size: 1.25rem;
}

/* ---------- Profile chip ---------- */

.profile-chip {
  width: 100%;
  margin-top: 0.75rem;
  margin-bottom: 0;
  background-color: var(--mantle);
  color: var(--text);
  border: 1px solid var(--surface1);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
  font-weight: 500;
}

.profile-chip:hover {
  background-color: var(--surface1);
  border-color: var(--blue);
  transform: none;
  box-shadow: none;
}

.profile-chip-avatar {
  font-size: 1.6rem;
  line-height: 1;
}

.profile-chip-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.profile-chip-label {
  font-size: 0.7rem;
  color: var(--subtext0);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-chip-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chip-icon {
  color: var(--subtext0);
  font-size: 0.8rem;
}

/* ---------- Profile picker overlay ---------- */

.profile-picker {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
  backdrop-filter: blur(6px);
}

.profile-picker[hidden],
.profile-grid[hidden],
.profile-create[hidden] {
  display: none;
}

.profile-picker-inner {
  background-color: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 16px;
  padding: 1.75rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.profile-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.profile-picker-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--text);
}

.profile-picker-close {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.7rem;
  background-color: transparent;
  color: var(--subtext0);
  font-size: 1rem;
  border-radius: 8px;
}

.profile-picker-close:hover {
  background-color: var(--surface1);
  color: var(--text);
  transform: none;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.profile-card {
  position: relative;
  background-color: var(--mantle);
  border: 2px solid var(--surface1);
  border-radius: 12px;
  padding: 1rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, background-color 0.2s;
  width: 100%;
  font: inherit;
  color: var(--text);
}

.profile-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  background-color: var(--surface0);
}

.profile-card.active {
  border-color: var(--green);
  background-color: color-mix(in srgb, var(--green) 12%, var(--mantle));
}

.profile-card-avatar {
  font-size: 2.6rem;
  line-height: 1;
}

.profile-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
}

.profile-card-add {
  border-style: dashed;
  background-color: transparent;
  color: var(--subtext0);
}

.profile-card-add .profile-card-avatar {
  font-size: 2rem;
  color: var(--subtext0);
}

.profile-create {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-avatar-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
}

.avatar-pick {
  width: auto;
  margin: 0;
  padding: 0.5rem;
  background-color: var(--mantle);
  border: 2px solid var(--surface1);
  border-radius: 10px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.avatar-pick:hover {
  border-color: var(--blue);
  transform: none;
}

.avatar-pick.selected {
  border-color: var(--green);
  background-color: color-mix(in srgb, var(--green) 15%, var(--mantle));
  transform: none;
}

#profileNameInput {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border: 2px solid var(--surface2);
  border-radius: 8px;
  background-color: var(--mantle);
  color: var(--text);
}

#profileNameInput:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.2);
}

.profile-create-actions {
  display: flex;
  gap: 0.6rem;
}

.profile-create-actions button {
  flex: 1;
  margin: 0;
}

.header-section {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.mascot {
  width: 72px;
  height: 72px;
}

.mascot-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mascot {
  width: 100px;
  height: 100px;
  animation: float 3s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.mascot.mood-happy {
  animation: mascotBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mascot.mood-sad {
  animation: mascotSad 0.7s ease;
}
.mascot.mood-cheer {
  animation: mascotCheer 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes mascotBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-18px) scale(1.1); }
  55% { transform: translateY(0) scale(1.05); }
  75% { transform: translateY(-8px) scale(1.02); }
}
@keyframes mascotSad {
  0%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(6px) rotate(-6deg); }
  45% { transform: translateY(6px) rotate(6deg); }
  70% { transform: translateY(4px) rotate(-3deg); }
}
@keyframes mascotCheer {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-15deg) scale(1.1) translateY(-12px); }
  50% { transform: rotate(15deg) scale(1.2) translateY(-18px); }
  75% { transform: rotate(-10deg) scale(1.1) translateY(-8px); }
  100% { transform: rotate(0) scale(1); }
}

.mascot-name {
  color: var(--mauve);
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

h2 {
  color: var(--blue);
  margin-bottom: 0.5rem;
  text-align: center;
  font-size: 1.8rem;
}

h3 {
  color: var(--mauve);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.stats-row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 1rem;
  margin-top: 1rem;
  gap: 0.75rem;
}

.stat-item {
  background-color: var(--mantle);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  text-align: center;
  flex: 1;
}

.stat-label {
  color: var(--subtext1);
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.3rem;
}

.stat-value {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: bold;
}

.star-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0;
}

.star-badge {
  font-size: 2rem;
  opacity: 0.3;
  transition: all 0.3s ease;
  cursor: help;
}

.star-badge.earned {
  opacity: 1;
  transform: scale(1.1);
  animation: starEarn 0.6s ease;
}

@keyframes starEarn {
  0% { transform: scale(1); }
  50% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1.1); }
}

.question-box {
  background-color: var(--mantle);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--surface2);
}

.question-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.question-text {
  font-size: 1.8rem;
  color: var(--text);
  text-align: center;
  font-weight: 600;
}

.question-text.word-problem {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.45;
  max-width: 34rem;
}

.speak-btn {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.55rem;
  font-size: 1.2rem;
  line-height: 1;
  background-color: var(--surface0);
  border: 1px solid var(--surface2);
}

.speak-btn:hover {
  background-color: var(--surface1);
}

.viz-card {
  position: relative;
}

.viz-speak-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 1rem;
}

.settings-note {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--overlay1);
}

.compare-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.compare-buttons[hidden] {
  display: none;
}

.compare-btn {
  width: 5rem;
  height: 4rem;
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  background-color: var(--surface0);
  color: var(--text);
  border: 2px solid var(--surface2);
  touch-action: manipulation;
}

.compare-btn:hover,
.compare-btn:focus-visible {
  border-color: var(--blue);
  background-color: var(--surface1);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 300px;
  margin: 1rem auto 0;
}

.keypad[hidden] {
  display: none;
}

.keypad-key {
  margin: 0;
  padding: 0;
  height: 3.4rem;
  font-size: 1.5rem;
  font-weight: 700;
  background-color: var(--surface0);
  color: var(--text);
  border: 1px solid var(--surface2);
  touch-action: manipulation;
}

.keypad-key:active {
  background-color: var(--surface1);
  transform: scale(0.96);
}

.keypad-back {
  color: var(--peach);
}

.keypad-enter {
  background-color: var(--green);
  color: var(--crust);
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.danger-btn {
  background-color: var(--red);
  color: var(--crust);
}

.danger-btn:hover {
  background-color: var(--peach);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(243, 139, 168, 0.4);
}

#themeBtn {
  background-color: var(--surface1);
  color: var(--text);
}

#themeBtn:hover {
  background-color: var(--surface2);
  transform: translateY(-2px);
}

.feedback {
  text-align: center;
  padding: 0.8rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 600;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.feedback.correct {
  background-color: var(--green);
  color: var(--crust);
}

.feedback.wrong {
  background-color: var(--red);
  color: var(--crust);
}

input[type="number"] {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid var(--surface2);
  border-radius: 8px;
  background-color: var(--mantle);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.2);
}

button {
  width: 100%;
  padding: 0.8rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 0.5rem;
}

#submitBtn {
  background-color: var(--blue);
  color: var(--crust);
}

#submitBtn:hover:not(:disabled) {
  background-color: var(--sky);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(137, 180, 250, 0.4);
}

#submitBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#startBtn {
  background-color: var(--green);
  color: var(--crust);
}

#startBtn:hover:not(:disabled) {
  background-color: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(166, 227, 161, 0.4);
}

#startBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.level-badge {
  background-color: var(--mauve);
  color: var(--crust);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(203, 166, 247, 0.35);
}

.level-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.level-value {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.xp-bar-wrap {
  flex: 1;
  position: relative;
  background-color: var(--mantle);
  border: 1px solid var(--surface2);
  border-radius: 999px;
  height: 28px;
  overflow: hidden;
}

.xp-bar-fill {
  background: linear-gradient(90deg, var(--green), var(--teal));
  height: 100%;
  width: 0%;
  transition: width 0.5s ease;
}

.xp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.settings-panel {
  margin-bottom: 0;
}

.settings-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--subtext1);
  padding: 0.3rem 0;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-top: 0.75rem;
}

.settings-group {
  border: 1px solid var(--surface2);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}

.settings-group legend {
  padding: 0 0.4rem;
  color: var(--blue);
  font-weight: 600;
  font-size: 0.9rem;
}

.settings-group label {
  display: block;
  padding: 0.2rem 0;
  cursor: pointer;
  color: var(--subtext1);
  font-size: 0.95rem;
}

.settings-group input {
  margin-right: 0.5rem;
  accent-color: var(--blue);
}

.block-viz {
  margin-bottom: 1rem;
}

.block-viz:empty {
  display: none;
}

.viz-card {
  background-color: var(--mantle);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  padding: 1rem;
  animation: fadeIn 0.4s ease;
}

.viz-title {
  color: var(--mauve);
  font-weight: 600;
  margin-bottom: 0.8rem;
  text-align: center;
  font-size: 1rem;
}

.viz-step {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.viz-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, 24px);
  gap: 3px;
  padding: 0.4rem;
  border-radius: 6px;
  background-color: var(--surface0);
  min-width: 32px;
  justify-content: center;
}

.viz-group.group-a { border: 2px solid var(--blue); }
.viz-group.group-b { border: 2px solid var(--peach); }
.viz-group.group-sum { border: 2px solid var(--green); }
.viz-group.group-array { border: 2px solid var(--mauve); }
.viz-group.group-remove { border: 2px solid var(--red); }

.viz-area {
  display: grid;
  gap: 6px;
  justify-content: center;
  align-items: start;
}

.viz-part {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.viz-part-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--subtext1);
  font-variant-numeric: tabular-nums;
}

.viz-ten-frame-wrap { align-items: center; }

.viz-ten-frame {
  display: grid;
  grid-template-columns: repeat(5, 28px);
  grid-template-rows: repeat(2, 28px);
  border: 2px solid var(--green);
  border-radius: 6px;
  background-color: var(--surface0);
  overflow: hidden;
}

.viz-ten-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--surface2);
  border-bottom: 1px solid var(--surface2);
}

.viz-ten-cell:nth-child(5n) { border-right: none; }
.viz-ten-cell:nth-child(n + 6) { border-bottom: none; }

.viz-bond {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.viz-bond-lines {
  width: 60px;
  height: 16px;
  stroke: var(--surface2);
  stroke-width: 2;
}

.viz-bond-parts {
  display: flex;
  gap: 12px;
}

.viz-bond-node {
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid var(--peach);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.viz-bond-whole { border-color: var(--surface2); }
.viz-bond-node.bond-block-a { border-color: var(--blue); }

.viz-group.viz-part-blocks {
  border: 2px dashed var(--surface2);
  justify-content: start;
}

.viz-div-array {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.viz-col-numbers {
  display: grid;
  gap: 3px;
  padding: 0 calc(0.4rem + 2px);
  font-size: 0.65rem;
  color: var(--subtext1);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.viz-fact-family {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.viz-fact-family-label {
  font-size: 0.8rem;
  color: var(--subtext1);
}

.viz-fact-chip {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background-color: var(--surface0);
  border: 1px solid var(--surface2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.viz-block.removed {
  background-color: var(--surface2) !important;
  position: relative;
  opacity: 0.55;
}

.viz-block.removed::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 0;
  border-top: 3px solid var(--red);
  transform: rotate(-45deg);
  transform-origin: center;
}

.viz-block.block-mul { background-color: var(--mauve); }
.viz-block.block-div-0 { background-color: var(--blue); }
.viz-block.block-div-1 { background-color: var(--peach); }
.viz-block.block-div-2 { background-color: var(--green); }
.viz-block.block-div-3 { background-color: var(--yellow); }
.viz-block.block-div-4 { background-color: var(--mauve); }
.viz-block.block-div-5 { background-color: var(--teal); }
.viz-block.block-div-6 { background-color: var(--red); }
.viz-block.block-div-7 { background-color: var(--sky); }

/* Place-value columns: ones = small squares, tens = rods, hundreds = flats */

.viz-place-mat {
  display: grid;
  gap: 4px 10px;
  justify-content: center;
  align-items: end;
  margin-bottom: 0.8rem;
}

.viz-place-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--subtext1);
  text-align: center;
  border-bottom: 1px solid var(--surface2);
  padding-bottom: 2px;
}

.viz-place-label {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  align-self: center;
  white-space: nowrap;
}

.viz-place-cell {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 20px;
  padding: 3px;
  border-radius: 4px;
  background-color: var(--surface0);
}

.viz-place-run {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: flex-end;
  max-width: 340px;
}

.viz-place-run.place-0 { max-width: 80px; }

.viz-bundle {
  padding: 3px;
  border: 2px dashed var(--green);
  border-radius: 6px;
}

.viz-carried .viz-pu,
.viz-broken .viz-pu {
  outline: 2px solid var(--yellow);
  outline-offset: 1px;
}

.viz-broken .viz-pu {
  opacity: 0.5;
}

.viz-col-step {
  border-top: 1px dashed var(--surface2);
  padding: 0.6rem 0;
  animation: fadeIn 0.4s ease backwards;
}

.viz-col-step-heading {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
  font-variant-numeric: tabular-nums;
}

.viz-col-step-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.viz-col-step-text {
  font-size: 0.9rem;
  color: var(--subtext1);
}

.viz-flat {
  width: 48px;
  height: 48px;
  border-radius: 3px;
  background-image:
    linear-gradient(var(--mantle) 1px, transparent 1px),
    linear-gradient(90deg, var(--mantle) 1px, transparent 1px);
  background-size: 4.8px 4.8px;
  animation: blockPop 0.3s ease backwards;
}

.viz-flat.unit-a { background-color: var(--blue); }
.viz-flat.unit-b { background-color: var(--peach); }
.viz-flat.unit-carry { background-color: var(--green); }
.viz-unit-sm.unit-carry { background-color: var(--green); }

.viz-pu { position: relative; }

/* Column viz shows many units at once; shrink them so the card stays a sensible height. */
.viz-compact .viz-unit-sm { width: 9px; height: 9px; }
.viz-compact .viz-rod { grid-template-columns: 9px; grid-auto-rows: 9px; padding: 1px; }
.viz-compact .viz-flat { width: 34px; height: 34px; background-size: 3.4px 3.4px; }
.viz-compact .viz-place-run.place-0 { max-width: 60px; }

.viz-rod.removed,
.viz-flat.removed {
  opacity: 0.4;
}

.viz-rod.removed::after,
.viz-flat.removed::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -2px;
  right: -2px;
  border-top: 3px solid var(--red);
  transform: rotate(-60deg);
}

.viz-rod {
  display: grid;
  grid-template-columns: 14px;
  grid-auto-rows: 14px;
  gap: 1px;
  padding: 2px;
  border-radius: 4px;
  background-color: var(--mantle);
  border: 1px solid var(--surface2);
}

.viz-unit-sm {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  animation: blockPop 0.3s ease backwards;
  position: relative;
}

.viz-unit-sm.unit-a { background-color: var(--blue); }
.viz-unit-sm.unit-b { background-color: var(--peach); }
.viz-unit-sm.unit-sum-a { background-color: var(--blue); }
.viz-unit-sm.unit-sum-b { background-color: var(--peach); }

.viz-unit-sm.removed {
  background-color: var(--surface2) !important;
  opacity: 0.55;
}

.viz-unit-sm.removed::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--red);
  transform: rotate(-45deg);
  transform-origin: center;
}

.viz-step-stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
}

/* Daily streak chip */
.daily-streak {
  background-color: var(--mantle);
  border: 1px solid var(--surface2);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  flex-shrink: 0;
}

.daily-streak-icon {
  font-size: 1.1rem;
}

.daily-streak-value {
  color: var(--peach);
  font-size: 1.1rem;
}

/* Quest panel */
.quest-panel {
  margin-bottom: 0;
}

.quest-title {
  color: var(--mauve);
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.quest-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--subtext1);
}

.quest-item.done {
  color: var(--green);
  text-decoration: line-through;
  opacity: 0.7;
}

.quest-progress-wrap {
  flex: 1;
  height: 10px;
  background-color: var(--surface0);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.quest-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mauve), var(--blue));
  transition: width 0.4s ease;
}

.quest-item.done .quest-progress-fill {
  background: var(--green);
}

.quest-count {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  min-width: 3em;
  text-align: right;
}

.quest-reward {
  color: var(--yellow);
  font-weight: 600;
  font-size: 0.8rem;
}

/* Mastery panel */
.mastery-panel {
  margin-bottom: 0;
}

.mastery-title {
  color: var(--mauve);
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.mastery-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}

.mastery-op {
  width: 1.6rem;
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
  text-align: center;
}

.mastery-bar-wrap {
  flex: 1;
  height: 10px;
  background-color: var(--surface0);
  border-radius: 999px;
  overflow: hidden;
}

.mastery-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sky), var(--mauve));
  transition: width 0.4s ease;
}

.mastery-level {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--subtext1);
  min-width: 3.5em;
  text-align: right;
}

.mastery-stats {
  font-size: 0.75rem;
  color: var(--overlay1);
  min-width: 3.5em;
  text-align: right;
}

.fact-panel {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--surface1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fact-grid-title {
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--mauve);
}

.fact-grid-sub {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--overlay1);
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  width: min(100%, 300px);
}

.fact-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background-color: var(--base);
  border: 1px solid var(--surface1);
}

/* One hue, rising strength: readable without relying on red/green contrast. */
.fact-cell[data-box="1"] { background-color: color-mix(in srgb, var(--green) 20%, var(--base)); }
.fact-cell[data-box="2"] { background-color: color-mix(in srgb, var(--green) 40%, var(--base)); }
.fact-cell[data-box="3"] { background-color: color-mix(in srgb, var(--green) 60%, var(--base)); }
.fact-cell[data-box="4"] { background-color: color-mix(in srgb, var(--green) 80%, var(--base)); }
.fact-cell[data-box="5"] { background-color: var(--green); }

.fact-legend {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--overlay1);
}

.fact-legend .fact-cell {
  width: 10px;
}

.fact-legend span:first-child { margin-right: 3px; }
.fact-legend span:last-child { margin-left: 3px; }

/* My Progress tab */
.progress-section {
  background-color: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 12px;
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 1rem;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.progress-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--mauve);
}

.count-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background-color: var(--surface0);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.week-dot {
  width: 100%;
  max-width: 48px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.week-day.played .week-dot {
  border: 2px solid var(--yellow);
  background-color: color-mix(in srgb, var(--yellow) 20%, var(--base));
}

.week-day.today .week-dot { box-shadow: 0 0 0 3px var(--blue); }

.week-label {
  font-size: 0.75rem;
  color: var(--subtext0);
}

.week-day.today .week-label {
  color: var(--blue);
  font-weight: 700;
}

.week-streak { margin-top: 0.7rem; }

.garden-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.garden {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.8rem;
}

.garden-card {
  background-color: var(--base);
  border: 1px solid var(--surface1);
  border-radius: 10px;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.garden-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.garden-op {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--crust);
}

.garden-op-add { background-color: var(--blue); }
.garden-op-sub { background-color: var(--peach); }
.garden-op-mul { background-color: var(--mauve); }
.garden-op-div { background-color: var(--teal); }

.garden-name {
  font-weight: 700;
  color: var(--text);
}

.garden-grid { width: 100%; }

.garden-counts {
  display: flex;
  gap: 0.4rem;
}

.skill-badges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.practice-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem 0.5rem 0.9rem;
  margin-bottom: 0.8rem;
  border-radius: 10px;
  border: 2px solid var(--green);
  background-color: color-mix(in srgb, var(--green) 15%, var(--mantle));
}

.practice-banner[hidden] { display: none; }

.practice-banner-icon { font-size: 1.4rem; }

.practice-banner-text {
  flex: 1;
  font-weight: 700;
  color: var(--text);
}

.practice-stop-btn {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background-color: var(--surface1);
  color: var(--text);
  font-size: 0.9rem;
}

.practice-stop-btn:hover { background-color: var(--surface2); }

.question-box.practicing { border: 2px solid var(--green); }

.practice-btn {
  width: auto;
  margin: 0 0 0 auto;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background-color: var(--green);
  color: var(--crust);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.practice-btn:hover:not(:disabled),
.skill-badge:hover:not(:disabled) { filter: brightness(1.1); }

.practice-btn:disabled,
.skill-badge:disabled { cursor: not-allowed; }

.skill-badge {
  width: auto;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.3rem;
  border-radius: 8px;
  border: 2px solid var(--surface2);
  background-color: var(--surface0);
}

.skill-badge.untried { opacity: 0.55; border-style: dashed; }

.skill-icon { font-size: 1.5rem; line-height: 1; }

.skill-example {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--subtext1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.best-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
}

.best-tile {
  background-color: var(--base);
  border: 1px solid var(--surface1);
  border-radius: 10px;
  padding: 0.7rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
}

.best-icon { font-size: 1.6rem; line-height: 1.2; }

.best-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.best-label {
  font-size: 0.75rem;
  color: var(--subtext0);
}

.learned-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.progress-empty {
  font-size: 1.8rem;
  letter-spacing: 0.2rem;
}

/* Round progress + summary */
.round-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.round-progress[hidden] {
  display: none;
}

.round-dots {
  display: flex;
  gap: 6px;
}

.round-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--surface1);
  transition: background-color 0.3s, transform 0.3s;
}

.round-dot.dot-current {
  background-color: transparent;
  border: 2px solid var(--blue);
  transform: scale(1.15);
}

.round-dot.dot-first { background-color: var(--green); }
.round-dot.dot-retry { background-color: var(--yellow); }
.round-dot.dot-missed { background-color: var(--peach); }

.round-label {
  font-size: 0.8rem;
  color: var(--subtext1);
  font-variant-numeric: tabular-nums;
}

.round-summary {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.round-summary[hidden] {
  display: none;
}

.round-summary-inner {
  width: min(100%, 420px);
  background-color: var(--base);
  border: 1px solid var(--surface2);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: splashPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.round-stars {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  font-size: 2.6rem;
}

.round-star {
  filter: grayscale(1);
  opacity: 0.3;
}

.round-star.earned {
  filter: none;
  opacity: 1;
  animation: splashPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.round-summary-title {
  margin: 0.5rem 0 1rem;
  color: var(--mauve);
  font-size: 1.4rem;
}

.round-stats {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.round-stat {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  background-color: var(--surface0);
}

.round-learned-block {
  margin-bottom: 0.8rem;
}

.round-learned-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.round-learned-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.round-summary-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.round-summary-actions button {
  margin: 0;
}

.round-close-btn {
  background-color: var(--surface1);
  color: var(--text);
}

.round-again-btn {
  background-color: var(--green);
  color: var(--crust);
}

/* Level-up splash */
.level-up-splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: none;
  background-color: rgba(0, 0, 0, 0.35);
  animation: splashFade 0.25s ease;
}

.level-up-splash[hidden] {
  display: none;
}

.level-up-inner {
  background: linear-gradient(135deg, var(--mauve), var(--blue));
  color: var(--crust);
  padding: 2rem 3rem;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: splashPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.level-up-label {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.level-up-num {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  margin: 0.5rem 0;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.level-up-sub {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.9;
}

@keyframes splashFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes splashPop {
  0% { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Confetti */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 150;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  will-change: transform, opacity;
  animation: confettiFall 1800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes confettiFall {
  0% { transform: translate3d(0, 0, 0) rotate(0); opacity: 1; }
  100% {
    transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 720deg));
    opacity: 0;
  }
}

.viz-block {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  animation: blockPop 0.3s ease backwards;
  position: relative;
}

.viz-block.block-a { background-color: var(--blue); }
.viz-block.block-b { background-color: var(--peach); }

.viz-op {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.viz-caption {
  text-align: center;
  color: var(--subtext1);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

@keyframes blockPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.grownups-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin: 0.6rem 0 0;
  padding: 0.4rem 0.8rem;
  background-color: transparent;
  border: 1px dashed var(--surface2);
  color: var(--overlay1);
  font-size: 0.8rem;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.grownups-btn:hover {
  color: var(--subtext1);
  transform: none;
}

.grownups-fill {
  position: absolute;
  inset: 0;
  background-color: color-mix(in srgb, var(--blue) 35%, transparent);
  transform: scaleX(0);
  transform-origin: left;
}

.grownups-btn.holding .grownups-fill {
  transform: scaleX(1);
  transition: transform var(--hold-ms, 2s) linear;
}

.grownups-text { position: relative; }

#pickerGrownupsBtn { margin-top: 1.25rem; }

.grownups {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.grownups[hidden] { display: none; }

.grownups-inner {
  width: 100%;
  max-width: 820px;
  background-color: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.grownups-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.grownups-header h2 {
  margin: 0;
  margin-right: auto;
  font-size: 1.4rem;
  color: var(--text);
}

.grownups-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--subtext1);
  font-size: 0.9rem;
}

.grownups-player select {
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background-color: var(--mantle);
  color: var(--text);
  font-size: 0.95rem;
}

.grownups-note {
  margin: 0.4rem 0 1rem;
  font-size: 0.8rem;
  color: var(--overlay1);
}

.grownups-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.grownups-section h3 {
  margin: 0 0 0.5rem;
  color: var(--mauve);
  font-size: 1rem;
}

.grownups-section .settings-body { padding-top: 0; margin-bottom: 1.25rem; }

.grownups-section .danger-btn + .danger-btn { margin-top: 0.25rem; }

.parent-stats {
  padding: 0.5rem 0 0.8rem;
}

.parent-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--surface2);
  font-size: 0.9rem;
  gap: 1rem;
}

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

.parent-stat-label {
  color: var(--subtext1);
}

.parent-stat-value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.parent-section-title {
  color: var(--mauve);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.8rem;
  margin-bottom: 0.3rem;
}

/* ---------- Tab bar + Times Table view ---------- */

.tab-bar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  background-color: var(--mantle);
  padding: 0.3rem;
  border-radius: 10px;
  border: 1px solid var(--surface1);
}

.tab-btn {
  flex: 1;
  width: auto;
  margin-bottom: 0;
  padding: 0.55rem 0.8rem;
  background-color: transparent;
  color: var(--subtext0);
  border-radius: 7px;
  font-size: 0.95rem;
  transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.tab-btn:hover {
  background-color: var(--surface0);
  color: var(--text);
  transform: none;
}

.tab-btn.active {
  background-color: var(--blue);
  color: var(--crust);
  box-shadow: 0 2px 8px rgba(137, 180, 250, 0.25);
}

.table-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.table-title {
  font-weight: 600;
  color: var(--text);
}

.table-progress-label {
  font-size: 0.85rem;
  color: var(--subtext0);
}

.table-progress-bar {
  height: 6px;
  background-color: var(--surface1);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.8rem;
}

.table-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--teal));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.mult-grid {
  display: grid;
  gap: 3px;
  margin-bottom: 1rem;
  width: 100%;
  /* --n is set by JS to the side length (3, 5, or 12). Total columns = n + 1 (header col). */
  grid-template-columns: repeat(calc(var(--n, 5) + 1), minmax(0, 1fr));
  font-size: clamp(0.6rem, 2.6vw, 1rem);
}

.mult-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--mantle);
  border: 2px solid var(--surface1);
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.18s, border-color 0.18s, transform 0.18s;
  position: relative;
  overflow: hidden;
}

.mult-cell.mult-header {
  background-color: var(--surface1);
  color: var(--subtext0);
  border-color: var(--surface2);
  cursor: default;
  font-weight: 700;
}

.mult-cell.mult-corner {
  background-color: var(--surface2);
  color: var(--text);
  font-size: 0.85em;
}

.mult-cell.empty:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.mult-cell.focused {
  border-color: var(--blue);
  background-color: var(--surface0);
  box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.25);
  z-index: 2;
}

.mult-cell.correct {
  background-color: var(--green);
  color: var(--crust);
  border-color: var(--green);
  cursor: default;
}

.mult-cell.just-correct {
  animation: cellPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 1;
}

.mult-cell.wrong-shake {
  animation: cellShake 0.45s ease 1;
  border-color: var(--red);
  background-color: color-mix(in srgb, var(--red) 25%, var(--mantle));
}

.mult-cell-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  padding: 0;
  margin: 0;
  outline: none;
  -moz-appearance: textfield;
}

.mult-cell-input::-webkit-outer-spin-button,
.mult-cell-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cell-spark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, var(--yellow) 0%, transparent 60%);
  opacity: 0;
  animation: cellSpark 0.6s ease-out 1;
}

@keyframes cellPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes cellShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(3px); }
}

@keyframes cellSpark {
  0%   { opacity: 0.85; transform: scale(0.6); }
  100% { opacity: 0;    transform: scale(1.6); }
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--mantle);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--surface2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--overlay0);
}