:root {
  --bg: #f7fbef;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --text: #20242d;
  --muted: #707784;
  --line: rgba(31, 36, 48, 0.1);
  --accent: #58cc02;
  --accent-dark: #3ca100;
  --accent-soft: rgba(88, 204, 2, 0.12);
  --blue: #1cb0f6;
  --yellow: #ffc800;
  --ok: #1f9d73;
  --warn: #d89b2b;
  --bad: #cc5a63;
  --shadow: 0 18px 48px rgba(57, 38, 20, 0.12);
  --shadow-soft: 0 10px 28px rgba(57, 38, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(88, 204, 2, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(28, 176, 246, 0.14), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.panel-heading,
.study-toolbar,
.action-row,
.deck-meta,
.inline-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: clamp(96px, 13vw, 132px);
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.16));
}

#installBtn {
  border-color: rgba(88, 204, 2, 0.3);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.topbar {
  margin-bottom: 28px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: clamp(20px, 2.6vw, 28px);
}

.eyebrow {
  color: var(--accent-dark);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.hero {
  padding: clamp(24px, 5vw, 64px) 0;
}

.home-hero {
  display: grid;
  gap: 22px;
}

.hero-copy {
  max-width: 720px;
  display: grid;
  gap: 10px;
}

.hero-copy > p:last-child {
  color: var(--muted);
}

.language-grid,
.dashboard-grid,
.deck-grid,
.stats-grid {
  display: grid;
  gap: 18px;
}

.gate-shell {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 18px;
  padding: clamp(28px, 5vw, 56px);
}

.gate-copy {
  display: grid;
  gap: 10px;
  max-width: 520px;
}

.language-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.language-card,
.deck-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 28px;
  padding: 28px;
  text-align: left;
  box-shadow: var(--shadow);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.language-card {
  display: grid;
  gap: 8px;
}

.language-card[data-language="en"] {
  background:
    radial-gradient(circle at top right, rgba(28, 176, 246, 0.18), transparent 32%),
    var(--panel);
}

.language-card[data-language="zh"] {
  background:
    radial-gradient(circle at top right, rgba(255, 200, 0, 0.2), transparent 32%),
    var(--panel);
}

.language-card:hover,
.deck-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 60px rgba(57, 38, 20, 0.16);
  border-color: rgba(88, 204, 2, 0.28);
}

.language-card span {
  font-size: 34px;
}

.language-card strong {
  font-size: 24px;
}

.language-card small,
.muted {
  color: var(--muted);
}

.dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.daily-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  overflow: hidden;
  position: relative;
}

.daily-hero::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  right: -90px;
  top: -110px;
  border-radius: 50%;
  background: rgba(88, 204, 2, 0.08);
}

.daily-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
}

.daily-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.daily-metrics {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.goal-orb {
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, white 57%, transparent 58%),
    conic-gradient(var(--accent) var(--goal-progress, 0%), rgba(88, 204, 2, 0.14) 0);
  display: grid;
  place-items: center;
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.goal-orb strong,
.streak-card strong {
  font-size: 24px;
}

.goal-orb span,
.streak-card span {
  color: var(--muted);
  font-size: 13px;
}

.streak-card {
  min-width: 112px;
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stats-grid.compact {
  flex: 1;
}

.stat-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: var(--panel-strong);
  box-shadow: var(--shadow-soft);
}

.stat-card strong {
  font-size: 28px;
}

.stat-card span {
  color: var(--muted);
  font-size: 14px;
}

.wide {
  grid-column: 1 / -1;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.deck-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 18px;
}

.deck-card {
  display: grid;
  gap: 14px;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31, 36, 48, 0.08);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8ee000);
}

.deck-meta {
  color: var(--muted);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(31, 157, 115, 0.14);
  color: var(--ok);
}

.primary-btn,
.ghost-btn,
.mode-tabs button,
.mini-btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 10px 14px;
  background: white;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

.xl-btn {
  padding: 14px 20px;
  font-size: 16px;
}

.primary-btn:hover,
.ghost-btn:hover,
.mode-tabs button:hover,
.mini-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
  box-shadow: none !important;
}

.study-layout {
  display: grid;
  gap: 18px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

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

.card-zone,
.mode-host {
  display: grid;
  gap: 18px;
}

.study-progress {
  color: var(--muted);
}

.flashcard {
  min-height: 340px;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  perspective: 1200px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 180ms ease;
}

.flashcard.is-dragging {
  transition: none;
}

.flashcard-shell {
  position: relative;
  min-height: 340px;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.flashcard.is-flipped .flashcard-shell {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 28px;
  padding: clamp(22px, 5vw, 42px);
  text-align: center;
  background:
    radial-gradient(circle at top left, rgba(88, 204, 2, 0.16), transparent 34%),
    linear-gradient(135deg, #fffaf4, #ffffff);
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 18px 36px rgba(57, 38, 20, 0.08);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at bottom right, rgba(28, 176, 246, 0.14), transparent 34%),
    linear-gradient(135deg, #ffffff, #f8fff2);
}

.keyboard-hint {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.flashcard-inner {
  display: grid;
  gap: 12px;
}

.flashcard-word {
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 700;
}

.flashcard-detail {
  color: var(--muted);
}

.flashcard-meaning {
  font-size: 24px;
}

.action-row {
  flex-wrap: wrap;
}

.action-row button {
  flex: 1;
  min-width: 140px;
}

.mini-btn {
  padding: 8px 10px;
}

.danger {
  color: var(--bad);
}

.danger-btn {
  background: var(--bad);
  border-color: var(--bad);
  color: white;
}

.warn {
  color: var(--warn);
}

.success {
  color: var(--ok);
}

.my-deck-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.my-deck-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.review-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 255, 240, 0.92));
}

.search-field {
  min-width: min(280px, 100%);
}

.search-field input {
  width: 100%;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-tabs button.active {
  background: var(--text);
  color: white;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-options button,
.dictation-form input,
.manual-form input,
.manual-form textarea {
  width: 100%;
}

.quiz-options button {
  text-align: left;
}

.feedback {
  border-radius: 18px;
  padding: 14px;
  background: rgba(31, 157, 115, 0.12);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 36, 48, 0.35);
}

.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
}

.manual-form,
.stack {
  display: grid;
  gap: 14px;
}

.install-welcome {
  text-align: center;
}

.install-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--accent-soft);
  font-size: 32px;
}

.inline-form {
  align-items: end;
}

.inline-form > * {
  flex: 1;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  padding: 11px 13px;
}

@media (max-width: 760px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .study-toolbar,
  .panel-heading,
  .inline-form,
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .flashcard {
    min-height: 280px;
  }

  .flashcard-shell {
    min-height: 280px;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brand-logo {
    width: 104px;
    height: 58px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .daily-hero {
    grid-template-columns: 1fr;
  }

  .daily-metrics {
    justify-content: space-between;
  }
}


/* Premium progression + game layer */
.profile-panel,
.mission-panel,
.game-panel {
  align-self: stretch;
}

.level-pill {
  border-radius: 999px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #58cc02, #89e219);
  color: #1d3508;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(88, 204, 2, 0.22);
}

.reward-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.reward-stats div {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.reward-stats strong {
  display: block;
  font-size: 22px;
}

.reward-stats span,
.mission-item span {
  color: var(--muted);
  font-size: 13px;
}

.xp-track {
  height: 12px;
}

.badge-shelf,
.mission-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.mission-item {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(250,255,244,0.8));
}

.mission-item.is-done {
  border-color: rgba(88, 204, 2, 0.55);
  background: linear-gradient(135deg, rgba(236, 255, 223, 0.95), rgba(255,255,255,0.86));
}

.mini-track {
  height: 7px;
  border-radius: 999px;
  background: #ecf0e8;
  overflow: hidden;
  margin-top: 9px;
}

.mini-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #58cc02, #1cb0f6);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.game-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  text-align: left;
  background: linear-gradient(135deg, #ffffff, #fff8ec);
  box-shadow: 0 14px 30px rgba(57, 38, 20, 0.08);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 36px rgba(57, 38, 20, 0.12);
}

.game-card span {
  display: block;
  font-size: 30px;
  margin-bottom: 10px;
}

.game-card strong,
.game-card small {
  display: block;
}

.game-card small {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
}

.game-card em {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(88, 204, 2, 0.12);
  color: #347a05;
  font-style: normal;
  font-weight: 800;
  font-size: 12px;
}


.game-mode-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}

.game-mode-btn {
  width: 100%;
  border: 1px solid rgba(88, 204, 2, 0.22);
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(57, 38, 20, 0.06);
}

.game-mode-btn.primary {
  background: linear-gradient(135deg, #58cc02, #1cb0f6);
  color: #fff;
  border-color: transparent;
}

.game-mode-btn:hover {
  transform: translateY(-1px);
}

.avatar-economy {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.avatar-card {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 14px;
  background: linear-gradient(135deg, #fff9ec, #f0fff1);
}

.avatar-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  border-radius: 26px;
  background: radial-gradient(circle at 50% 25%, #fff, #c9f3ff 55%, #87d7ff);
  overflow: hidden;
}

.avatar-aura {
  position: absolute;
  width: 105px;
  height: 105px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  animation: avatarPulse 2.8s ease-in-out infinite;
}

.avatar-body {
  position: relative;
  z-index: 1;
  text-align: center;
  transform: translateY(8px);
}

.avatar-face {
  font-size: 66px;
  filter: drop-shadow(0 12px 14px rgba(31, 20, 10, 0.18));
}

.avatar-hat,
.avatar-facewear,
.avatar-neck,
.avatar-bodywear {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 25px;
  white-space: nowrap;
  pointer-events: none;
}

.avatar-hat { top: -28px; }
.avatar-facewear { top: 28px; }
.avatar-neck { top: 68px; }
.avatar-bodywear { top: 94px; font-size: 22px; }

@keyframes avatarPulse {
  0%, 100% { transform: scale(0.94); opacity: 0.72; }
  50% { transform: scale(1.06); opacity: 1; }
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 10px;
}

.shop-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  text-align: left;
}

.shop-item:hover,
.shop-item.is-equipped {
  border-color: rgba(88, 204, 2, 0.62);
  box-shadow: 0 10px 22px rgba(88, 204, 2, 0.12);
}

.shop-item span,
.shop-item strong,
.shop-item small {
  display: block;
}

.shop-item span {
  font-size: 26px;
}

.shop-item small {
  color: var(--muted);
  margin-top: 4px;
}

.deck-card.is-locked {
  opacity: 0.7;
  filter: grayscale(0.35);
}

.lock-badge {
  background: #fff1d6;
  color: #8a5200;
}

.game-layout {
  display: grid;
  gap: 18px;
}

.game-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.game-score {
  display: flex;
  gap: 12px;
  align-items: center;
}

.game-score span {
  color: var(--muted);
}

.game-board {
  min-height: 480px;
  overflow: hidden;
  position: relative;
}

.game-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 800;
  text-align: center;
  margin: 8px auto 24px;
  max-width: 820px;
}

.game-question span {
  flex: 1;
}

.tiny-btn {
  padding: 8px 11px;
  min-width: auto;
}

.round-timer {
  height: 9px;
  border-radius: 999px;
  background: #edf1e7;
  overflow: hidden;
  margin: -10px 0 18px;
}

.round-timer i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #58cc02, #ffc800, #ff5c5c);
  animation: roundTimer 4.5s linear forwards;
}

.defense-board .round-timer i,
.racing-board .round-timer i {
  animation-duration: 5s;
}

@keyframes roundTimer {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.bubble-field {
  position: relative;
  min-height: 340px;
  border-radius: 30px;
  background:
    radial-gradient(circle at 20% 25%, rgba(255,255,255,0.9), transparent 18%),
    linear-gradient(180deg, #bdf1ff 0%, #eefcff 58%, #dcffd0 100%);
  overflow: hidden;
}

.bubble-skyline {
  position: absolute;
  inset: 18px 20px auto;
  color: rgba(255,255,255,0.85);
  font-size: 32px;
  letter-spacing: 22px;
}

.answer-bubble {
  position: absolute;
  width: min(42vw, 220px);
  min-height: 92px;
  border: 0;
  border-radius: 999px;
  padding: 18px;
  color: #17320a;
  font-weight: 800;
  background: radial-gradient(circle at 30% 24%, #ffffff, #a8ecff 34%, #1cb0f6 100%);
  box-shadow: 0 18px 30px rgba(28, 176, 246, 0.2);
  animation: bubbleFloat 7s linear infinite;
}

.answer-bubble span {
  position: relative;
  z-index: 1;
}

.answer-bubble.b0 { left: 4%; bottom: -6%; animation-delay: 0s; }
.answer-bubble.b1 { left: 31%; bottom: -12%; animation-delay: 0.7s; }
.answer-bubble.b2 { right: 26%; bottom: -8%; animation-delay: 1.2s; }
.answer-bubble.b3 { right: 4%; bottom: -14%; animation-delay: 0.35s; }

@keyframes bubbleFloat {
  from { transform: translateY(30px) scale(0.94); }
  50% { transform: translateY(-120px) scale(1.03); }
  to { transform: translateY(-250px) scale(0.98); }
}

.defense-field {
  min-height: 210px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 20px clamp(20px, 8vw, 90px);
  border-radius: 26px;
  background: linear-gradient(180deg, #e8f7ff, #fff6e9);
  box-shadow: inset calc(var(--danger, 0) * 10px) 0 34px rgba(255,92,92,0.14);
  border: 2px solid rgba(90, 155, 80, 0.15);
  margin-bottom: 22px;
}

.defense-map {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 20px;
  background: #13251d;
  color: #fff;
}

.defense-map div {
  display: flex;
  gap: 10px;
  align-items: center;
}

.defense-map span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
}

.defense-map span.is-active {
  background: #ffc800;
  color: #1f1800;
  transform: scale(1.12);
}

.defense-map small {
  color: rgba(255,255,255,0.72);
}

.laser-line {
  align-self: center;
  flex: 1;
  height: 4px;
  margin: 0 22px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 92, 92, 0.8), transparent);
  animation: laserPulse 800ms ease-in-out infinite alternate;
}

@keyframes laserPulse {
  from { opacity: 0.25; transform: scaleX(0.82); }
  to { opacity: 1; transform: scaleX(1); }
}

.base,
.monster {
  font-size: 58px;
  display: grid;
  gap: 8px;
  text-align: center;
}

.monster strong {
  display: inline-block;
  border-radius: 999px;
  padding: 7px 12px;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  box-shadow: 0 10px 24px rgba(31, 20, 10, 0.12);
}

.base span {
  font-size: 13px;
  color: var(--muted);
}

.monster {
  animation: monsterAdvance 2.2s ease-in-out infinite alternate;
}

@keyframes monsterAdvance {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-42px - var(--danger, 0) * 10px)); }
}

.game-board.is-correct {
  animation: boardCorrect 420ms ease;
}

.game-board.is-wrong {
  animation: boardWrong 420ms ease;
}

@keyframes boardCorrect {
  50% { box-shadow: 0 0 0 8px rgba(88, 204, 2, 0.2); }
}

@keyframes boardWrong {
  25%, 75% { transform: translateX(-5px); }
  50% { transform: translateX(5px); box-shadow: 0 0 0 8px rgba(255, 92, 92, 0.18); }
}

.racing-road {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 28px;
  background: #3d4147;
}

.racing-hint {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.gamefi-road {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 360px;
  align-items: stretch;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent),
    #333941;
}

.race-lane {
  position: relative;
  display: grid;
  place-items: center;
  align-items: start;
  border: 2px dashed rgba(255,255,255,0.28);
  border-radius: 18px;
  padding: 14px;
  color: white;
  background: rgba(255,255,255,0.08);
  text-align: left;
  cursor: pointer;
  min-height: 320px;
  overflow: hidden;
}

.race-lane em {
  font-style: normal;
  font-weight: 700;
}

.race-lane.is-player {
  border-color: #ffc800;
  background: linear-gradient(180deg, rgba(255,200,0,0.18), rgba(255,255,255,0.06));
}

.road-word {
  position: relative;
  z-index: 2;
  display: inline-block;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 14px;
  background: #fff;
  color: #1e2630;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(0,0,0,0.18);
  animation: roadWordDrop 6.5s linear forwards;
}

.lane-line {
  position: absolute;
  inset: 0 50%;
  width: 2px;
  border-left: 3px dashed rgba(255,255,255,0.34);
}

.race-car {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-size: 42px;
  z-index: 3;
  animation: carShake 360ms ease-in-out infinite alternate;
}

@keyframes roadWordDrop {
  from { transform: translateY(-20px) scale(0.95); }
  to { transform: translateY(238px) scale(1.04); }
}

@keyframes carShake {
  from { transform: translateX(-50%) rotate(-2deg); }
  to { transform: translateX(-50%) rotate(2deg); }
}

.race-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.game-result {
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
}

.result-medal {
  font-size: 72px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  max-width: min(92vw, 560px);
  border-radius: 999px;
  padding: 12px 18px;
  color: #17320a;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px rgba(57, 38, 20, 0.18);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

/* ===== WEAK WORDS PANEL ===== */
.weak-words-panel {
  display: grid;
  gap: 12px;
}

.weak-words-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.weak-word-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
  transition: border-color 180ms ease;
  overflow: hidden;
}

.weak-word-item[open] {
  border-color: rgba(255,92,92,0.3);
}

.weak-word-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.weak-word-summary::-webkit-details-marker { display: none; }
.weak-word-summary::marker { display: none; content: ""; }

.weak-word-summary strong {
  font-size: 16px;
  color: var(--text);
}

.weak-word-detail {
  padding: 0 14px 14px;
  display: grid;
  gap: 10px;
}

.weak-word-detail small {
  color: var(--muted);
  font-size: 13px;
}

.weak-word-meta {
  display: flex;
  gap: 6px;
  align-items: center;
}

.weak-word-count {
  background: #ffe0e0;
  color: #b33a3a;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
}

.weak-word-item .tiny-btn {
  opacity: 0.7;
  transition: opacity 180ms;
}

.weak-word-item:hover .tiny-btn {
  opacity: 1;
}

.weak-word-stats {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff5f5, #fff0ec);
  border: 1px solid rgba(255,92,92,0.2);
  margin-bottom: 8px;
}

.weak-word-stats strong {
  font-size: 22px;
  color: var(--bad);
}

.weak-word-stats span {
  color: var(--muted);
  font-size: 13px;
}

/* ===== ADMIN PANEL ===== */
.admin-nav-btn {
  background: linear-gradient(135deg, #1a1a2e, #16213e) !important;
  color: #ffc800 !important;
  border-color: #ffc800 !important;
  font-weight: 800;
}

.admin-nav-btn:hover {
  background: #16213e !important;
}

.admin-actions {
  display: grid;
  gap: 14px;
}

.admin-row {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.admin-row label {
  flex: 1;
  min-width: 100px;
}

.admin-row input,
.admin-row select {
  width: 100%;
}

/* ===== GAME RESULT READABILITY ===== */
.game-result {
  background: var(--panel-strong) !important;
  border: 2px solid var(--line);
}

.game-result h2 {
  color: var(--text);
}

.game-result p {
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

/* ===== MARKETPLACE ===== */
.marketplace-panel {
  display: grid;
  gap: 16px;
}

.marketplace-categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.marketplace-categories button {
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  color: var(--muted);
  transition: all 180ms ease;
}

.marketplace-categories button.active,
.marketplace-categories button:hover {
  background: var(--accent-soft);
  border-color: rgba(88,204,2,0.4);
  color: var(--accent-dark);
}

.marketplace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.marketplace-item {
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  text-align: center;
  background: rgba(255,255,255,0.82);
  cursor: pointer;
  transition: all 180ms ease;
  position: relative;
}

.marketplace-item:hover {
  border-color: rgba(88,204,2,0.5);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(88,204,2,0.12);
}

.marketplace-item.owned {
  border-color: rgba(88,204,2,0.3);
}

.marketplace-item.equipped {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.marketplace-item .item-icon {
  font-size: 42px;
  display: block;
  margin-bottom: 8px;
}

.marketplace-item .item-name {
  font-weight: 800;
  font-size: 14px;
  display: block;
}

.marketplace-item .item-desc {
  color: var(--muted);
  font-size: 11px;
  display: block;
  margin-top: 4px;
}

.marketplace-item .item-price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff3cc, #ffe8a0);
  color: #8a6500;
  font-weight: 800;
  font-size: 13px;
}

.marketplace-item .item-price.free {
  background: linear-gradient(135deg, #d4ffd4, #b8f5b8);
  color: #2a7a2a;
}

.marketplace-item .item-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--yellow);
  color: #5a4500;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
}

.marketplace-item .item-effect {
  display: block;
  font-size: 11px;
  color: var(--blue);
  margin-top: 4px;
  font-weight: 600;
}

/* ===== FULL BODY CHARACTER ===== */
.character-display {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
  border-radius: 28px;
  background: radial-gradient(circle at 50% 30%, #fff, #e0f0ff 40%, #b8e4ff 70%, #87d7ff);
  overflow: hidden;
}

.character-floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(180deg, transparent, rgba(120,180,100,0.18));
  border-radius: 0 0 28px 28px;
}

.character-figure {
  position: relative;
  display: grid;
  place-items: center;
  transform: translateY(10px);
}

.character-head {
  font-size: 80px;
  position: relative;
  z-index: 5;
}

.character-torso {
  font-size: 60px;
  margin-top: -18px;
  position: relative;
  z-index: 4;
}

.character-legs {
  font-size: 40px;
  margin-top: -10px;
  position: relative;
  z-index: 3;
}

/* Equipment overlays */
.char-hat {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 36px;
  z-index: 10;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

.char-glasses {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  z-index: 10;
}

.char-scarf {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 24px;
  z-index: 10;
}

.char-crown {
  position: absolute;
  top: -36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 32px;
  z-index: 10;
  filter: drop-shadow(0 4px 8px rgba(255,200,0,0.4));
}

.char-bodywear {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 44px;
  z-index: 6;
}

.char-backpack {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateX(34px);
  font-size: 24px;
  z-index: 3;
}

/* ===== WORD DEFENSE BATTLE (PvP) ===== */
.battle-lobby {
  display: grid;
  gap: 18px;
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.battle-lobby input {
  padding: 14px 18px;
  border-radius: 16px;
  border: 2px solid var(--line);
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
}

.battle-lobby input:focus {
  outline: none;
  border-color: var(--accent);
}

.battle-room-code {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: #ffc800;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 6px;
  font-family: monospace;
}

.battle-arena {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 500px;
}

.battle-player-side {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.6);
  border: 2px solid var(--line);
}

.battle-player-side.is-opponent {
  background: rgba(255,240,240,0.6);
  border-color: rgba(255,92,92,0.3);
}

.battle-center {
  display: grid;
  place-items: center;
  gap: 10px;
  padding-top: 40px;
}

.battle-center .vs-icon {
  font-size: 36px;
}

.battle-base-hp {
  display: grid;
  gap: 6px;
  text-align: center;
}

.battle-hp-bar {
  height: 14px;
  border-radius: 999px;
  background: #edf1e7;
  overflow: hidden;
}

.battle-hp-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff5c5c, #ffc800, #58cc02);
  transition: width 400ms ease;
}

.battle-monsters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.battle-monster {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.8);
  animation: monsterWalk 1.5s ease-in-out infinite alternate;
}

.battle-monster.is-mini {
  background: rgba(255,200,0,0.2);
  border: 1px dashed rgba(255,200,0,0.5);
}

@keyframes monsterWalk {
  from { transform: translateX(0); }
  to { transform: translateX(-12px); }
}

.battle-question-area {
  grid-column: 1 / -1;
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, #f0f8ff, #fff0f5);
  border: 2px solid var(--line);
  text-align: center;
}

.battle-question-word {
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 900;
  margin-bottom: 16px;
}

.battle-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 600px;
  margin: 0 auto;
}

.battle-options button {
  padding: 14px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.8);
  font-weight: 700;
  font-size: 15px;
  transition: all 180ms ease;
  cursor: pointer;
}

.battle-options button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.battle-streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff9800, #ff5722);
  color: white;
  font-weight: 800;
  font-size: 14px;
}

.battle-skill-activated {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: 900;
  color: #ffc800;
  text-shadow: 0 4px 20px rgba(255,200,0,0.5);
  z-index: 1000;
  animation: skillPop 1.2s ease forwards;
  pointer-events: none;
}

@keyframes skillPop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

.battle-timer {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-dark);
}

.battle-result {
  text-align: center;
  padding: 40px;
}

.battle-result .result-icon {
  font-size: 80px;
  margin-bottom: 16px;
}

/* Equipment effects in battle */
.equipped-effect {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.equipped-effect.buff {
  background: rgba(88,204,2,0.15);
  color: #2a7a2a;
}

.equipped-effect.special {
  background: rgba(28,176,246,0.15);
  color: #0a6ea8;
}

@media (max-width: 760px) {
  .reward-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .avatar-card {
    grid-template-columns: 1fr;
  }

  .game-topbar {
    grid-template-columns: 1fr;
  }

  .game-board {
    min-height: 520px;
  }

  /* Fix bubble overlap on mobile — stack vertically, large touch targets */
  .bubble-field {
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 8px;
    position: relative;
    overflow: visible;
  }

  .bubble-skyline {
    position: relative;
    top: auto;
    left: auto;
    font-size: 18px;
    letter-spacing: 10px;
    text-align: center;
    margin-bottom: 4px;
  }

  .answer-bubble {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
    width: 100%;
    min-height: 56px;
    padding: 14px 16px;
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
    border-radius: 16px;
    animation: bubblePulseMobile 2.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    word-break: break-word;
  }

  .answer-bubble span {
    white-space: normal;
    max-width: 100%;
  }

  .answer-bubble.b0 { animation-delay: 0s; }
  .answer-bubble.b1 { animation-delay: 0.3s; }
  .answer-bubble.b2 { animation-delay: 0.6s; }
  .answer-bubble.b3 { animation-delay: 0.9s; }

  @keyframes bubblePulseMobile {
    0%, 100% { transform: scale(0.98); }
    50% { transform: scale(1.015); }
  }

  /* Fix racing lanes on mobile — vertical cards, large touch targets */
  .gamefi-road {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 8px;
    min-height: auto;
  }

  .race-lane {
    min-height: 64px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-radius: 14px;
    flex-direction: row;
  }

  .race-lane .lane-line {
    display: none;
  }

  .race-lane .road-word {
    font-size: 16px;
    line-height: 1.3;
    padding: 8px 12px;
    writing-mode: horizontal-tb;
    max-height: none;
    animation: none;
    display: inline-block;
    margin-top: 0;
    white-space: normal;
    word-break: break-word;
    text-align: left;
    flex: 1;
  }

  .race-lane .race-car {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    font-size: 28px;
    animation: none;
  }

  .battle-arena {
    grid-template-columns: 1fr;
  }

  .battle-center {
    padding-top: 0;
    flex-direction: row;
    justify-content: center;
  }

  .battle-options {
    grid-template-columns: 1fr;
  }

  .marketplace-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .character-display {
    min-height: 260px;
  }

  .character-head {
    font-size: 64px;
  }

  .character-torso {
    font-size: 48px;
  }

  .character-legs {
    font-size: 32px;
  }
}


@media (max-width: 430px) {
  .game-mode-actions {
    grid-template-columns: 1fr;
  }

  .race-controls {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* === Voxel cat avatar marketplace === */
.avatar-card {
  grid-template-columns: minmax(220px, 320px) 1fr;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 52, 74, 0.14), transparent 28%),
    linear-gradient(135deg, #101015, #1b1822 52%, #111827);
  color: #fff;
  border-color: rgba(255, 77, 103, 0.22);
  box-shadow: 0 22px 60px rgba(12, 10, 20, 0.16);
}

.avatar-card .muted,
.avatar-card .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.avatar-stage {
  min-height: 270px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 51, 68, 0.20), transparent 34%),
    radial-gradient(circle at 50% 78%, rgba(255, 255, 255, 0.12), transparent 28%),
    linear-gradient(160deg, #050507, #16121b 70%, #211016);
  border: 1px solid rgba(255, 92, 118, 0.22);
  box-shadow: inset 0 0 44px rgba(255, 54, 73, 0.08);
}

.avatar-aura {
  width: 210px;
  height: 210px;
  background: radial-gradient(circle, rgba(255, 58, 78, 0.26), rgba(255, 58, 78, 0.05) 58%, transparent 70%);
  filter: blur(2px);
}

.avatar-pedestal {
  position: absolute;
  bottom: 22px;
  width: 180px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 65, 87, 0.32), transparent 68%);
  filter: blur(4px);
}

.avatar-character {
  position: relative;
  z-index: 2;
  width: min(240px, 78vw);
  height: 196px;
  display: grid;
  place-items: center;
  animation: avatarFloat 3.4s ease-in-out infinite;
}

.avatar-cat-img {
  position: absolute;
  inset: 4px 0 auto 0;
  width: 100%;
  height: 172px;
  object-fit: contain;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.42));
}

.avatar-item-layer {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.42));
}

.avatar-item-face { width: 48%; top: 10px; left: 16%; transform: rotate(-2deg); }
.avatar-item-neck { width: 44%; top: 92px; left: 12%; transform: rotate(-5deg); }
.avatar-item-body { width: 65%; top: 58px; right: 2%; opacity: 0.92; }
.avatar-item-hat { width: 46%; top: -30px; left: 15%; transform: rotate(-3deg); }
.avatar-item-back { width: 42%; top: 82px; right: -4%; opacity: 0.96; }

.avatar-equipped-list {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.avatar-equipped-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 11px;
  font-weight: 900;
  backdrop-filter: blur(10px);
}

.avatar-equipped-chip img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.avatar-equipped-chip.is-empty { opacity: 0.72; }

.shop-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.shop-item {
  display: grid;
  gap: 8px;
  min-height: 180px;
  background: linear-gradient(180deg, rgba(12, 12, 18, 0.94), rgba(26, 20, 32, 0.94));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 36px rgba(12, 10, 20, 0.12);
}

.shop-item:hover,
.shop-item.is-equipped {
  transform: translateY(-2px);
  border-color: rgba(255, 69, 91, 0.58);
  box-shadow: 0 18px 36px rgba(255, 48, 76, 0.16);
}

.shop-thumb {
  display: grid !important;
  place-items: center;
  min-height: 86px;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(255, 59, 84, 0.16), rgba(255, 255, 255, 0.04));
}

.shop-thumb img {
  width: 92px;
  height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.38));
}

.shop-item small {
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.35;
}

.shop-item em {
  display: inline-flex;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 74, 98, 0.16);
  color: #ffd0d8;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.shop-item.is-equipped em {
  background: rgba(88, 204, 2, 0.18);
  color: #b8ff8e;
}

@keyframes avatarFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.015); }
}

@media (max-width: 760px) {
  .avatar-card { grid-template-columns: 1fr; }
  .avatar-stage { min-height: 250px; }
  .shop-grid { grid-template-columns: 1fr; }
}

/* === Study paths / separated PvP === */
.study-path-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.path-card { min-height: 160px; }
.pvp-panel { background: linear-gradient(135deg, #111827, #1f1630); color: #fff; }
.pvp-panel .eyebrow, .pvp-panel small { color: rgba(255,255,255,.72); }
.pvp-card { border-color: rgba(255, 90, 120, .34); background: linear-gradient(145deg, #191522, #24182a); color: #fff; }

/* === Avatar v2: keep cat image, draw compatible wearables === */
.avatar-stage { min-height: 250px; }
.avatar-character { width: min(260px, 78vw); height: 190px; }
.avatar-cat-img { height: 176px; z-index: 3; }
.avatar-wearable { position: absolute; z-index: 5; pointer-events: none; --item:#58cc02; --item-accent:#fff; }
.avatar-item-face {
  top: 35px; left: 69px; width: 62px; height: 22px;
  border: 4px solid var(--item); border-radius: 12px;
  box-shadow: 38px 0 0 -4px #09090b, 38px 0 0 0 var(--item), 0 0 14px color-mix(in srgb, var(--item), transparent 45%);
}
.avatar-item-face::after { content:""; position:absolute; left:55px; top:7px; width:18px; height:4px; background:var(--item); border-radius:99px; }
.avatar-item-neck {
  top: 96px; left: 58px; width: 88px; height: 18px; border-radius: 999px;
  background: linear-gradient(90deg, var(--item), var(--item-accent)); transform: rotate(-5deg);
  box-shadow: 0 8px 16px rgba(0,0,0,.28);
}
.avatar-item-neck::after { content:""; position:absolute; left:50px; top:10px; width:18px; height:54px; border-radius: 0 0 12px 12px; background: var(--item); transform: rotate(-8deg); }
.avatar-item-body {
  top: 82px; left: 103px; width: 98px; height: 60px; z-index: 2;
  border-radius: 18px 26px 18px 18px; background: linear-gradient(135deg, var(--item), #10131a 72%);
  border: 2px solid color-mix(in srgb, var(--item), white 18%); opacity: .9;
}
.avatar-item-body::after { content:""; position:absolute; inset:10px 16px; border-radius:12px; border:2px solid var(--item-accent); opacity:.72; }
.avatar-item-hat {
  top: 6px; left: 72px; width: 86px; height: 34px; z-index: 6;
  background: linear-gradient(180deg, var(--item-accent), var(--item));
  clip-path: polygon(0 100%, 12% 38%, 30% 82%, 50% 10%, 70% 82%, 88% 38%, 100% 100%);
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--item), transparent 45%));
}
.avatar-item-back {
  top: 96px; right: 26px; width: 44px; height: 50px; z-index: 1;
  border-radius: 12px; background: linear-gradient(135deg, var(--item), #161821);
  border: 2px solid var(--item-accent); box-shadow: 0 10px 16px rgba(0,0,0,.34);
}
.avatar-item-back::before { content:""; position:absolute; left:-13px; top:8px; width:18px; height:34px; border:4px solid var(--item); border-right:0; border-radius:12px 0 0 12px; }
.tier-5 { filter: drop-shadow(0 0 10px var(--item)); }

.avatar-equipped-chip img { display:none; }
.mini-item { width:14px; height:14px; display:inline-block; border-radius:4px; background:var(--item); box-shadow: inset 0 0 0 2px var(--item-accent); }
.mini-item.glasses { border-radius:999px; }
.mini-item.scarf { border-radius:999px 999px 3px 3px; }
.mini-item.crown { clip-path: polygon(0 100%, 20% 25%, 38% 75%, 50% 0, 62% 75%, 80% 25%, 100% 100%); }
.mini-item.bag { border-radius:4px 4px 7px 7px; }

.shop-grid { grid-template-columns: 1fr; }
.shop-family { display:grid; gap:10px; }
.shop-family + .shop-family { margin-top: 12px; }
.shop-family-title { display:flex; justify-content:space-between; gap:10px; align-items:end; color:var(--ink); }
.shop-family-title span { color:var(--muted); font-size:12px; font-weight:800; }
.shop-family-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap:10px; }
.shop-item { min-height: 172px; }
.shop-thumb.css-item { position:relative; min-height:74px; display:grid!important; place-items:center; overflow:hidden; }
.shop-thumb.css-item::before { content:""; width:62px; height:38px; border-radius:14px; background:linear-gradient(135deg,var(--item),var(--item-accent)); box-shadow:0 12px 24px rgba(0,0,0,.3); }
.shop-thumb.glasses::before { height:26px; border:5px solid var(--item); background:transparent; box-shadow:38px 0 0 -5px #111,38px 0 0 0 var(--item); }
.shop-thumb.scarf::before { height:22px; border-radius:999px; }
.shop-thumb.robe::before { height:52px; border-radius:18px 18px 10px 10px; }
.shop-thumb.crown::before { clip-path: polygon(0 100%, 15% 30%, 35% 78%, 50% 8%, 65% 78%, 85% 30%, 100% 100%); }
.shop-thumb.bag::before { height:50px; border-radius:12px; }

/* === Games v2: moving mobile bubble / tower defense / real racing === */
.round-timer i { animation-duration: var(--round-ms, 14000ms) !important; }
.live-bubble-field { min-height: 430px; height: min(62vh, 520px); overflow:hidden; }
.answer-bubble { animation: bubbleRise var(--bubble-speed, 13s) linear infinite !important; touch-action: manipulation; }
@keyframes bubbleRise { 0%{ transform:translateY(80px) scale(.94); opacity:.9;} 72%{opacity:1;} 100%{ transform:translateY(-390px) scale(1.04); opacity:.18;} }

.tower-defense-field { min-height: 250px; position:relative; overflow:hidden; }
.tower-defense-field .base { position:absolute; left:18px; bottom:28px; z-index:3; }
.tower-defense-field .incoming-monster { position:absolute; right:18px; bottom:48px; max-width:34%; animation: defenseApproach var(--monster-speed, 15s) linear forwards; }
.tower-defense-field .incoming-monster strong { max-width: 120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@keyframes defenseApproach { from{ transform:translateX(0);} to{ transform:translateX(-45vw);} }
.defense-options { position:relative; z-index:4; }

.real-racing-road { height:min(56vh, 480px); min-height:360px; align-items:stretch; overflow:hidden; background:linear-gradient(180deg,#2b2f39,#141720); }
.real-racing-road .race-lane { min-height:100%; align-content:end; justify-items:center; overflow:hidden; }
.real-racing-road .road-answer-gate { position:absolute; top:-20%; left:8px; right:8px; padding:10px 8px; border-radius:14px; background:#fff; color:#171923; font-weight:900; box-shadow:0 12px 26px rgba(0,0,0,.25); animation: raceGate var(--race-speed, 13s) linear forwards; }
.real-racing-road .race-car { position:absolute; left:50%; bottom:22px; transform:translateX(-50%); font-size:38px; z-index:5; filter:drop-shadow(0 10px 10px rgba(0,0,0,.42)); }
.real-racing-road .race-lane.is-player { background:linear-gradient(180deg, rgba(88,204,2,.16), rgba(255,255,255,.06)); }
@keyframes raceGate { from{ top:-18%; } to{ top:76%; } }

@media (max-width: 760px) {
  .study-path-grid { grid-template-columns: 1fr; }
  .live-bubble-field { display:block; min-height:420px; height:62vh; position:relative; overflow:hidden; }
  .answer-bubble { position:absolute!important; width:min(45vw,190px); min-height:82px; border-radius:999px; }
  .answer-bubble.b0 { left:3%!important; bottom:-12%!important; }
  .answer-bubble.b1 { left:52%!important; bottom:-18%!important; }
  .answer-bubble.b2 { left:8%!important; bottom:-34%!important; }
  .answer-bubble.b3 { left:48%!important; bottom:-42%!important; }
  .real-racing-road { min-height:430px; grid-template-columns:repeat(4,1fr); }
  .real-racing-road .race-lane { padding:8px 4px; }
  .real-racing-road .road-answer-gate { writing-mode: horizontal-tb; font-size:12px; left:3px; right:3px; }
}

/* === Cat Word Fortress integration 2026-05-20 === */
.main-game-card {
  border-color: rgba(88, 204, 2, .55);
  box-shadow: 0 18px 46px rgba(88, 204, 2, .14);
}
.main-game-card span {
  background: linear-gradient(135deg, #58cc02, #b7f34b);
}
.cat-game-layout { max-width: 1040px; margin-inline: auto; }
.cat-game-topbar { align-items: center; }
.cat-game-board { overflow: hidden; }
.cat-game-question { font-size: clamp(15px, 2.4vw, 22px); line-height: 1.35; }
.cat-fortress-wrap { display: grid; gap: 14px; }
.cat-fortress-map {
  background: linear-gradient(135deg, #111827, #183021);
  color: #fff;
  border: 0;
}
.cat-fortress-map div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cat-fortress-map span {
  display: grid; place-items: center;
  min-width: 34px; height: 34px; padding: 0 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.8);
  font-weight: 900;
  font-size: 11px;
}
.cat-fortress-map span.is-active { background: #58cc02; color: #10200a; }
.cat-fortress-field {
  position: relative;
  min-height: min(55vh, 430px);
  height: 430px;
  overflow: hidden;
  border-radius: 28px;
  border: 2px solid rgba(88,204,2,.25);
  background:
    radial-gradient(circle at 50% 100%, rgba(88,204,2,.18), transparent 28%),
    linear-gradient(180deg, #dff6ff 0%, #f8fff1 48%, #dff0cd 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.72), 0 24px 60px rgba(30, 70, 30, .14);
  touch-action: manipulation;
}
.cat-fortress-field::before {
  content: "";
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.32) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.28) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: .42;
}
.fortress-lanes { position:absolute; inset:0; pointer-events:none; }
.fortress-lanes i {
  position:absolute; top:0; bottom:78px; width:2px;
  background: linear-gradient(180deg, transparent, rgba(23,66,45,.16), transparent);
}
.fortress-lanes i:nth-child(1){ left:18%; }
.fortress-lanes i:nth-child(2){ left:38%; }
.fortress-lanes i:nth-child(3){ left:58%; }
.fortress-lanes i:nth-child(4){ left:78%; }
.cat-tower {
  position:absolute; left:50%; bottom:20px; transform:translateX(-50%);
  width: 210px; height: 118px; z-index: 4;
  display:grid; place-items:center;
}
.fortress-tower-block {
  position:absolute; bottom:0; width: 190px; height: 72px;
  border-radius: 28px 28px 18px 18px;
  background: linear-gradient(180deg, #26362f, #121815);
  box-shadow: inset 0 0 0 3px rgba(88,204,2,.35), 0 16px 28px rgba(0,0,0,.28);
}
.demo-cat {
  position:absolute; bottom:46px; width: 76px; height: 78px;
  transform-origin: 50% 100%; filter: drop-shadow(0 12px 12px rgba(0,0,0,.24));
}
.demo-cat.attack { animation: catBump .22s ease; }
.demo-cat .cat-body {
  position:absolute; left:17px; bottom:0; width:42px; height:48px;
  background:#111; border-radius: 18px 18px 12px 12px;
  box-shadow: inset 0 -6px 0 rgba(255,255,255,.08);
}
.demo-cat .cat-ear {
  position:absolute; top:2px; width:24px; height:24px; background:#111;
  clip-path: polygon(50% 0, 0 100%, 100% 100%); z-index:2;
}
.demo-cat .cat-ear.left { left:14px; transform: rotate(-8deg); }
.demo-cat .cat-ear.right { right:14px; transform: rotate(8deg); }
.demo-cat .cat-face {
  position:absolute; left:10px; top:18px; width:56px; height:42px; z-index:3;
  display:grid; place-items:center;
  color:#ff4a4a; font-size:18px; letter-spacing:7px; text-indent:7px;
  background:#111; border-radius: 18px;
  box-shadow: 0 0 22px rgba(255,65,65,.38);
}
.tower-label {
  position:absolute; bottom:8px; z-index:5; padding:4px 10px; border-radius:999px;
  background:#58cc02; color:#10200a; font-weight:1000; font-size:11px;
}
.fortress-enemy {
  position:absolute; z-index:3; width:70px; min-height:70px; margin-left:-35px;
  display:grid; justify-items:center; gap:2px;
  transition: filter .16s ease, transform .16s ease;
  will-change: top, left;
}
.fortress-enemy .enemy-core {
  width:44px; height:44px; border-radius:14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, #2b2353, #7c3aed);
  color:#fff; box-shadow: 0 10px 18px rgba(49,24,94,.28);
}
.fortress-enemy b {
  max-width: 96px; padding:4px 7px; border-radius:999px;
  background:#fff; color:#172033; font-size:11px; line-height:1.1;
  box-shadow: 0 8px 16px rgba(0,0,0,.12);
  white-space: nowrap; overflow:hidden; text-overflow:ellipsis;
}
.fortress-enemy i { width:42px; height:5px; border-radius:999px; background:rgba(255,255,255,.8); overflow:hidden; }
.fortress-enemy em { display:block; height:100%; background:#ff4b4b; }
.fortress-enemy.boss .enemy-core { background: linear-gradient(135deg, #3b0d0d, #fb7185); transform: scale(1.12); }
.fortress-enemy.hit { filter: brightness(1.45); transform: scale(.82); opacity:.65; }
.fortress-enemy.rage { filter: hue-rotate(-35deg) saturate(1.5); }
.fortress-shot {
  position:absolute; width:12px; height:12px; border-radius:50%; z-index:6;
  background:#58cc02; box-shadow:0 0 16px #58cc02;
  animation: fortressShot .42s ease-out forwards;
}
.fortress-shot.miss { background:#ff4b4b; box-shadow:0 0 16px #ff4b4b; }
@keyframes fortressShot { to { transform: translate(var(--tx), var(--ty)) scale(.55); opacity:.15; } }
@keyframes catBump { 50% { transform: translateY(-8px) scale(1.05); } }
.cat-fortress-answers { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.cat-fortress-answers button {
  border-radius:18px; border:0; padding:14px 12px;
  background: linear-gradient(180deg, #fff8df, #f4ce83);
  color:#2d2113; font-weight:1000;
  box-shadow: 0 5px 0 #b8833c, 0 12px 20px rgba(77,45,12,.14);
}
.cat-bubble-field { min-height: min(60vh, 520px); }
.cat-bubble-field .answer-bubble { animation-duration: var(--bubble-speed, 5.8s) !important; }
.cat-race-road {
  height:min(56vh, 480px); min-height:360px; display:grid; grid-template-columns: repeat(4, 1fr);
  gap:8px; align-items:stretch; overflow:hidden;
  background:linear-gradient(180deg,#2b2f39,#141720);
}
.cat-race-road .race-lane { min-height:100%; position:relative; display:grid; align-items:end; justify-items:center; overflow:hidden; }
.cat-race-road .road-answer-gate {
  position:absolute; top:-22%; left:8px; right:8px; padding:10px 8px; border-radius:14px;
  background:#fff; color:#171923; font-weight:1000; box-shadow:0 12px 26px rgba(0,0,0,.25);
  animation: raceGate 7.6s linear forwards;
}
.cat-race-road .race-car {
  position:absolute; left:50%; bottom:24px; transform:translateX(-50%);
  z-index:5; padding:8px 10px; border-radius:14px;
  background:linear-gradient(135deg,#58cc02,#c8ff59); color:#10200a; font-weight:1000;
  box-shadow:0 12px 18px rgba(0,0,0,.34);
}
.cat-race-road .race-lane.is-player { background:linear-gradient(180deg, rgba(88,204,2,.16), rgba(255,255,255,.06)); }
@media (max-width: 760px) {
  .cat-game-layout { padding: 8px; }
  .cat-game-topbar { grid-template-columns: 1fr; text-align:left; }
  .cat-fortress-field { height: 58vh; min-height: 390px; border-radius:22px; }
  .cat-tower { width:150px; }
  .fortress-tower-block { width:145px; }
  .fortress-enemy b { max-width:72px; font-size:10px; }
  .cat-fortress-answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-race-road { min-height:430px; grid-template-columns:repeat(4,1fr); gap:4px; }
  .cat-race-road .road-answer-gate { left:3px; right:3px; font-size:12px; padding:8px 4px; }
}

/* === Clean beta reset: no shop / no PvP / bright study UI === */
.pvp-panel, #pvpHub { display: none !important; }
body {
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 230, 150, .55), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(142, 232, 255, .45), transparent 30%),
    linear-gradient(180deg, #f9fbff 0%, #f3fff0 52%, #fff8e8 100%) !important;
}
.panel {
  background: rgba(255,255,255,.88);
  border-color: rgba(20, 30, 50, .08);
  box-shadow: 0 22px 55px rgba(49, 79, 124, .10);
}
.profile-panel {
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(235,255,215,.92));
}
.clean-avatar-card {
  grid-template-columns: minmax(220px, 360px) 1fr !important;
  background: linear-gradient(135deg, #fff8d7, #dcfbff 46%, #e9ffd6) !important;
  color: #172033 !important;
  border: 2px solid rgba(88,204,2,.22) !important;
  box-shadow: 0 24px 60px rgba(88,204,2,.12) !important;
}
.clean-avatar-card .muted, .clean-avatar-card .eyebrow { color: #596274 !important; }
.clean-cat-stage {
  background: radial-gradient(circle at 50% 36%, #ffffff 0 25%, #d9f7ff 26% 50%, #dfffcf 51% 100%) !important;
  border: 2px solid rgba(88,204,2,.2) !important;
  min-height: 260px !important;
  overflow: hidden;
}
.avatar-sun {
  position:absolute; right: 26px; top: 22px; width: 54px; height:54px; border-radius:50%;
  background:#ffd75d; box-shadow:0 0 36px rgba(255,205,77,.55);
}
.avatar-grass {
  position:absolute; left:0; right:0; bottom:0; height:64px;
  background:linear-gradient(180deg,#bdf476,#69cc30);
  border-radius: 0 0 22px 22px;
}
.clean-cat-character { position:relative; z-index:2; filter: drop-shadow(0 18px 20px rgba(38,74,33,.22)); }
.avatar-wearable, .avatar-item-layer, .avatar-equipped-list, .shop-grid, .shop-family, .shop-item, .marketplace-panel { display:none !important; }
.avatar-cat-img { object-fit: contain; max-height: 230px; }

.weak-words-collapsible {
  border-radius: 22px;
  background: #ffffff;
  border: 1px solid rgba(30,40,60,.08);
  box-shadow: 0 14px 30px rgba(30,40,60,.06);
  overflow: hidden;
}
.weak-words-collapsible > summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 20px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:#172033;
  font-weight:900;
}
.weak-words-collapsible > summary::-webkit-details-marker { display:none; }
.weak-words-collapsible > summary em { color:#6b7280; font-style:normal; font-size:13px; }
.weak-word-actions { padding: 0 18px 12px; }
.weak-word-empty { padding: 16px 18px; border-radius:18px; background:#fff; color:#6b7280; }
.weak-words-list { padding: 0 14px 14px; display:grid; gap:8px; }
.weak-word-item { background:#f8fafc; border:1px solid rgba(30,40,60,.07); border-radius:16px; overflow:hidden; }
.weak-word-summary { padding:12px 14px; }
.weak-word-detail { padding:0 14px 12px; }

.study-review-tabs {
  display:grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin: 4px 0 18px;
}
.study-review-tabs button {
  border: 1px solid rgba(30,40,60,.10);
  border-radius: 20px;
  padding: 16px 14px;
  background: rgba(255,255,255,.9);
  color: #687084;
  font-weight: 1000;
  box-shadow: 0 12px 28px rgba(30,40,60,.08);
}
.study-review-tabs button.active {
  background: #121827;
  color: #fff;
  border-color: #121827;
}
.card-zone {
  border-radius: 36px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 28px 80px rgba(67, 78, 109, .12);
}
.unit-mode-card {
  min-height: 430px;
  display:grid;
  place-items:center;
  align-content:center;
  gap:18px;
  text-align:center;
  padding: 28px;
}
.unit-mode-card h3 {
  font-size: clamp(2.4rem, 8vw, 5rem);
  color:#151c2d;
  margin: 0;
}
.option-grid {
  width:min(720px, 100%);
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.option-grid button {
  border:0;
  border-radius:20px;
  padding:16px 14px;
  background:#f3f6fb;
  color:#182036;
  font-weight:900;
  box-shadow:0 5px 0 #d9e1ee;
}
.listen-orb {
  width:110px; height:110px; border-radius:50%;
  display:grid; place-items:center;
  background:linear-gradient(135deg,#eef2ff,#dcfce7);
  font-size:46px;
  box-shadow:0 18px 42px rgba(80,100,180,.16);
}
.game-question .tiny-btn, #gameSpeakBtn, #speakBtn, #mySpeakBtn, #listenModePlay {
  min-width: 46px;
  min-height: 42px;
  display:inline-grid;
  place-items:center;
  font-size: 20px;
}
.fortress-enemy b { display:none !important; }
.cat-race-road .race-car {
  font-size: 34px !important;
  background: transparent !important;
  box-shadow: none !important;
  filter: drop-shadow(0 14px 10px rgba(0,0,0,.4));
}
@media (max-width: 760px) {
  .clean-avatar-card { grid-template-columns: 1fr !important; }
  .study-review-tabs { display:flex; overflow-x:auto; padding-bottom:6px; }
  .study-review-tabs button { min-width: 178px; }
  .option-grid { grid-template-columns: 1fr; }
}

/* === Home reorder, live theme, shooter + matching game === */
.topbar-actions { align-items: center; flex-wrap: wrap; }
.topbar-select { display:flex; align-items:center; gap:7px; padding:6px 8px; border-radius:16px; background:rgba(255,255,255,.72); border:1px solid rgba(30,40,60,.08); font-size:12px; font-weight:900; color:#596274; }
.topbar-select span { text-transform:uppercase; letter-spacing:.06em; }
.topbar-select select { border:0; background:transparent; font-weight:1000; color:#172033; outline:0; }
.home-dashboard-grid { margin-top: 22px; }
.path-picker-panel { background:linear-gradient(135deg,#ffffff,#f1ffdf); }
.route-page { display:grid; gap:18px; }
.route-hero { display:grid; grid-template-columns:auto 1fr minmax(220px,320px); align-items:center; gap:18px; }
.route-hero h2 { margin:0; font-size:clamp(2rem,5vw,4rem); }
.route-deck-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:16px; }
body[data-theme="morning"] { background:radial-gradient(circle at 18% 8%,rgba(255,232,138,.65),transparent 28%),linear-gradient(180deg,#fff8d7,#ecfff7 54%,#f8fff0) !important; }
body[data-theme="day"] { background:radial-gradient(circle at 15% 10%,rgba(255,230,150,.55),transparent 28%),radial-gradient(circle at 88% 18%,rgba(142,232,255,.45),transparent 30%),linear-gradient(180deg,#f9fbff 0%,#f3fff0 52%,#fff8e8 100%) !important; }
body[data-theme="dusk"] { background:radial-gradient(circle at 14% 8%,rgba(255,177,92,.56),transparent 30%),radial-gradient(circle at 88% 10%,rgba(180,124,255,.28),transparent 34%),linear-gradient(180deg,#fff2df,#f7edf8 58%,#f4fff0) !important; }
body[data-theme="night"] { background:radial-gradient(circle at 15% 10%,rgba(88,204,255,.18),transparent 28%),radial-gradient(circle at 88% 18%,rgba(124,58,237,.22),transparent 30%),linear-gradient(180deg,#101827,#172033 56%,#152315) !important; }
body[data-theme="night"] .panel { background:rgba(255,255,255,.9); }
.bubble-shooter-wrap { display:grid; gap:14px; }
.bubble-shooter-map { display:flex; justify-content:space-between; align-items:center; gap:12px; background:#fff5df; border:2px solid rgba(74,45,34,.18); border-radius:22px; padding:12px 14px; }
.bubble-shooter-map div { display:flex; gap:8px; color:#58a800; font-size:18px; }
.bubble-shooter-field { min-height:min(60vh,540px); position:relative; overflow:hidden; border-radius:28px; background:linear-gradient(180deg,#24565b,#17353a); border:3px solid #4a2d22; box-shadow:inset 0 -8px 0 rgba(0,0,0,.18); }
.shooter-board { position:absolute; inset:18px 18px 150px; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; align-content:start; }
.target-bubble { aspect-ratio:1; border-radius:50%; border:4px solid #2c1b14; background:radial-gradient(circle at 32% 28%,#fff8cc 0 10%,#e8c85f 11% 100%); color:#2b1f19; font-weight:1000; padding:10px; display:grid; place-items:center; text-align:center; line-height:1.05; box-shadow:0 12px 0 rgba(0,0,0,.18); animation: shooterFloat 2.4s ease-in-out infinite alternate; animation-delay:calc(var(--i) * -.22s); }
.target-bubble span { max-width:100%; overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; }
.bubble-launcher { position:absolute; left:50%; bottom:16px; transform:translateX(-50%); display:grid; justify-items:center; gap:6px; color:#fff8df; font-weight:900; }
.loaded-bubble { width:128px; height:128px; border-radius:50%; border:4px solid #2c1b14; background:#b8d6b7; color:#2b1f19; display:grid; place-items:center; text-align:center; padding:12px; font-weight:1000; line-height:1.05; box-shadow:0 10px 0 rgba(0,0,0,.22); }
.launcher-line { width:4px; height:56px; border-radius:999px; background:rgba(255,248,223,.8); transform-origin:bottom; animation: aimWiggle 1.2s ease-in-out infinite alternate; }
.bubble-shooter-field.is-hit .target-bubble:not(:disabled) { animation-duration:.7s; }
.bubble-shooter-field.is-miss { filter:hue-rotate(-25deg) saturate(1.25); }
@keyframes shooterFloat { to { transform:translateY(12px); } }
@keyframes aimWiggle { to { transform:rotate(8deg); } }
.match-pairs-card { padding:24px; display:grid; gap:18px; }
.match-head { display:flex; justify-content:space-between; align-items:start; gap:16px; }
.match-head h3 { margin:0; color:#172033; font-size:clamp(1.6rem,4vw,2.6rem); }
.match-actions { display:flex; flex-wrap:wrap; gap:10px; justify-content:flex-end; }
.match-grid { display:grid; grid-template-columns:repeat(5,minmax(90px,1fr)); gap:12px; }
.match-grid.is-hard { grid-template-columns:repeat(auto-fit,minmax(92px,1fr)); }
.match-tile { min-height:92px; border-radius:20px; border:2px solid rgba(30,40,60,.10); background:linear-gradient(180deg,#ffffff,#eef4ff); box-shadow:0 8px 0 #d9e1ee; color:#182036; font-weight:1000; padding:10px; transition:.18s ease; }
.match-tile.is-selected { background:linear-gradient(180deg,#fff8d7,#ffe39a); transform:translateY(4px); box-shadow:0 4px 0 #d9a93e; }
.match-tile.is-matched { opacity:0; transform:scale(.82); pointer-events:none; }
@media (max-width: 760px) {
  .topbar-actions { justify-content:flex-end; gap:6px; }
  .topbar-select { max-width:150px; }
  .topbar-select span { display:none; }
  .route-hero { grid-template-columns:1fr; }
  .shooter-board { inset:14px 10px 138px; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .bubble-shooter-field { min-height:580px; }
  .loaded-bubble { width:108px; height:108px; font-size:13px; }
  .match-head { display:grid; }
  .match-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .match-tile { min-height:78px; }
}

/* === Polish pass: balanced header, cat naming, source-like arcade games === */
.brand-lockup { gap: 18px; }
.brand-logo { width: clamp(118px, 15vw, 162px); height: 88px; }
.hero { padding: clamp(18px, 3vw, 38px) 0; }
.home-hero { gap: 14px; }
.home-dashboard-grid { margin-top: 10px; }
body[data-theme="night"] .brand-lockup h1,
body[data-theme="night"] .brand-lockup .eyebrow,
body[data-theme="night"] .topbar-select,
body[data-theme="night"] .topbar-select select { color: #f8fafc !important; }
body[data-theme="night"] .topbar-select { background: rgba(15, 23, 42, .72); border-color: rgba(255,255,255,.16); }
body[data-theme="night"] .ghost-btn { color: #f8fafc; border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.08); }
body[data-theme="night"] #installBtn { color: #d9f99d; background: rgba(88,204,2,.16); }

.clean-avatar-card { align-items: center; }
.cat-profile-copy { display: grid; gap: 10px; }
.cat-name-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cat-name-form input {
  min-width: 0;
  width: min(220px, 100%);
  border: 1px solid rgba(30,40,60,.12);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255,255,255,.86);
  color: #172033;
  font-weight: 900;
}
.avatar-celestial {
  position: absolute;
  right: 26px;
  top: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffd75d;
  box-shadow: 0 0 36px rgba(255, 205, 77, .58), 0 0 0 12px rgba(255, 215, 93, .12);
}
body[data-theme="night"] .clean-cat-stage {
  background: radial-gradient(circle at 50% 35%, #22314f 0 25%, #162338 26% 54%, #0e1a2c 55% 100%) !important;
  border-color: rgba(191, 219, 254, .28) !important;
}
body[data-theme="night"] .avatar-celestial {
  background: #fff7c2;
  box-shadow: -14px 0 0 0 #172033 inset, 0 0 34px rgba(233, 244, 255, .5), 0 0 0 12px rgba(219,234,254,.12);
}
body[data-theme="night"] .avatar-grass { background: linear-gradient(180deg, #335f4b, #183f35); }
body[data-theme="night"] .clean-avatar-card { background: linear-gradient(135deg, #f8fbff, #e6f2ff 55%, #ecffe4) !important; }

.vocab-arcade-shell { display: grid; gap: 14px; padding: clamp(14px, 2vw, 22px); }
.vocab-arcade-hud { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hud-box { border-radius: 18px; padding: 12px 14px; background: linear-gradient(135deg, #fff, #f2fff1); border: 1px solid rgba(88,204,2,.18); }
.hud-box span { display: block; color: #64748b; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.hud-box strong { color: #172033; font-weight: 1000; }
.vocab-arcade-playfield {
  position: relative;
  min-height: min(68vh, 620px);
  border-radius: 30px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 15%, rgba(255,255,255,.75), transparent 30%), linear-gradient(180deg, #bff4ff 0%, #e9f8ff 45%, #fff2ca 100%);
  border: 3px solid rgba(40, 65, 90, .16);
  box-shadow: inset 0 -10px 0 rgba(61, 43, 20, .08), 0 18px 44px rgba(30, 40, 60, .08);
  touch-action: none;
}
.vocab-arcade-playfield canvas { display: block; width: 100%; height: 100%; min-height: inherit; }
.arcade-ground-line { position: absolute; left: 20px; right: 20px; bottom: 96px; height: 3px; border-radius: 999px; background: repeating-linear-gradient(90deg, rgba(239,68,68,.55) 0 12px, transparent 12px 22px); pointer-events: none; }
.arcade-ammo-tray { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.arcade-ammo-btn { min-height: 62px; border-radius: 22px; border: 2px solid rgba(30,40,60,.12); background: linear-gradient(180deg, #fff, #eef8ff); color: #172033; font-weight: 1000; padding: 10px; box-shadow: 0 7px 0 rgba(30,40,60,.08); }
.arcade-ammo-btn.is-selected { border-color: #58cc02; background: linear-gradient(180deg, #f4ffd8, #dfffb5); transform: translateY(3px); box-shadow: 0 4px 0 rgba(58,130,8,.25); }
.arcade-toast { position: absolute; left: 50%; top: 16px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 999px; background: #172033; color: #fff; font-weight: 1000; transition: .2s ease; }
.arcade-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.arcade-toast.good { background: #22a55b; }
.arcade-toast.bad { background: #ef4444; }

.gold-game-wrapper { position: relative; min-height: min(72vh, 620px); overflow: hidden; padding: 0; background: #d9f7ff; border-radius: 30px; }
.gold-game-wrapper canvas { position: relative; z-index: 1; display: block; width: 100%; min-height: 520px; touch-action: none; }
.gold-sky { position: absolute; inset: 0; background: radial-gradient(circle at 18% 18%, #fff7b0 0 8%, transparent 9%), linear-gradient(180deg, #bdefff 0%, #e3fbff 35%, #ffe7a3 36%, #ffe7a3 100%); }
.gold-instruction { position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 2; padding: 10px 14px; border-radius: 18px; background: rgba(255,255,255,.78); color: #172033; font-weight: 900; text-align: center; backdrop-filter: blur(8px); }
.gold-question-modal { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(15,23,42,.35); padding: 18px; }
.gold-question-card { width: min(560px, 100%); border-radius: 28px; padding: 22px; background: #ffffff; box-shadow: 0 24px 70px rgba(15,23,42,.22); color: #172033; }
.gold-question-card h3 { margin: 8px 0 16px; font-size: clamp(20px, 4vw, 30px); }
.gold-options { display: grid; gap: 10px; }
.gold-option { border: 1px solid rgba(30,40,60,.1); border-radius: 18px; padding: 13px 14px; background: linear-gradient(180deg, #fff, #f6fbff); color: #172033; font-weight: 1000; text-align: left; }
.gold-option:hover { border-color: rgba(88,204,2,.45); background: #f2ffe5; }

@media (max-width: 760px) {
  .brand-logo { width: 118px; height: 70px; }
  .vocab-arcade-hud { grid-template-columns: 1fr; }
  .vocab-arcade-playfield { min-height: 560px; }
  .arcade-ammo-tray { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gold-game-wrapper canvas { min-height: 560px; }
}

/* === Stability patch: mobile-safe layout, synced timers, clearer night theme === */
html, body { max-width: 100%; overflow-x: hidden; }
* { box-sizing: border-box; }
.app-shell, #app, .panel, .game-layout, .study-layout, .card-zone { min-width: 0; }
body[data-theme="night"] .hero-copy h2,
body[data-theme="night"] .hero-copy p,
body[data-theme="night"] .hero-copy .eyebrow { color: #f8fafc !important; text-shadow: 0 2px 18px rgba(191,219,254,.24); }
body[data-theme="night"] .brand-logo { filter: drop-shadow(0 0 18px rgba(255,255,255,.34)) drop-shadow(0 10px 18px rgba(0,0,0,.28)); }
body[data-theme="night"] .clean-cat-character { filter: drop-shadow(0 0 28px rgba(255,255,255,.35)) drop-shadow(0 18px 20px rgba(38,74,33,.22)); }

.source-choice-grid { display: grid; gap: 12px; }
.source-choice-card { display: grid; gap: 4px; padding: 16px; border-radius: 20px; border: 1px solid rgba(30,40,60,.12); background: linear-gradient(135deg,#fff,#f5fff0); color:#172033; text-align:left; font-weight:900; }
.source-choice-card span, .source-choice-card em { color:#64748b; font-style:normal; font-weight:700; }
.source-choice-card:hover { border-color: rgba(88,204,2,.55); transform: translateY(-1px); }

.round-timer i { animation-duration: var(--round-ms, 10000ms) !important; }
.answer-bubble { animation-duration: var(--bubble-speed, 10500ms) !important; animation-fill-mode: forwards; }
.race-lane .road-answer-gate, .race-lane .race-car { animation-duration: var(--round-ms, 12000ms) !important; }

.vocab-arcade-shell { gap: 12px; }
.vocab-arcade-playfield { height: clamp(420px, 62vh, 620px); min-height: 0; display:block; }
.vocab-arcade-playfield canvas { width: 100%; height: 100%; min-height: 0; display:block; }
.arcade-ground-line { display: none !important; }
.arcade-ammo-tray { position: relative; z-index: 2; }
.gold-game-wrapper { height: clamp(460px, 68vh, 620px); min-height: 0; }
.gold-game-wrapper canvas { height: 100%; min-height: 0; }
.gold-answer-timer { display:inline-flex; width:max-content; margin: 0 0 12px; padding: 7px 12px; border-radius:999px; background:#fff7d6; color:#8a5200; font-weight:1000; }

.card-zone { overflow: visible; padding-bottom: clamp(18px, 4vw, 32px); }
#studyActions.action-row { justify-content:center; flex-wrap:wrap; gap: 10px; margin-top: 2px; }
.flashcard { min-height: clamp(300px, 54vh, 430px); }
.flashcard-shell { min-height: inherit; }
.study-review-tabs { max-width:100%; overflow-x:auto; scrollbar-width: thin; }
.study-review-tabs button { white-space: nowrap; }
.listen-mode-card .listen-orb { font-size: clamp(28px, 8vw, 56px); }
.unit-summary-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.unit-summary-stats span { display:grid; padding:10px; border-radius:16px; background:#f4ffe8; color:#172033; font-weight:900; }
.unit-vocab-table { display:grid; gap:8px; max-height:min(62vh,520px); overflow:auto; padding-right:4px; }
.unit-vocab-row { display:grid; grid-template-columns:44px minmax(90px,1fr) minmax(70px,.9fr) minmax(110px,1fr); gap:8px; align-items:center; padding:10px 12px; border:1px solid rgba(30,40,60,.08); border-radius:16px; background:#fff; }
.unit-vocab-row span { color:#94a3b8; font-weight:900; }
.unit-vocab-row em { color:#64748b; font-style:normal; }
.unit-vocab-row small { color:#2563eb; font-weight:800; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 18px, 1220px); padding-top: 16px; }
  .topbar, .game-topbar { width:100%; grid-template-columns:1fr; }
  .topbar-actions { width:100%; justify-content:flex-start; }
  .panel { border-radius: 22px; padding: 16px; }
  .game-board { min-height: 0; }
  .game-question { font-size: clamp(18px, 6vw, 25px); margin-bottom: 14px; }
  .vocab-arcade-hud { display:none; }
  .vocab-arcade-playfield { height: 500px; border-radius: 22px; }
  .arcade-ammo-tray { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .arcade-ammo-btn { min-height:56px; font-size:13px; }
  .gold-game-wrapper { height: 520px; border-radius: 22px; }
  .racing-road.gamefi-road { grid-template-columns: repeat(2,minmax(0,1fr)); min-height: 460px; }
  .race-lane { min-height: 210px; padding:10px; }
  .flashcard { min-height: 300px; }
  .flashcard-face { padding: 18px; }
  #studyActions.action-row > button { flex: 1 1 136px; }
  .unit-vocab-row { grid-template-columns:32px 1fr; }
  .unit-vocab-row em, .unit-vocab-row p, .unit-vocab-row small { grid-column: 2; }
}

/* === Learning logic polish: night contrast, readable summary, cleaner bubble shooter === */
.launcher-line,
.arcade-ground-line { display: none !important; }
.arcade-ammo-btn small {
  display:block;
  margin-bottom:4px;
  color:#64748b;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.05em;
}
.arcade-ammo-btn span { display:block; }
.arcade-ammo-btn.is-selected {
  border-color:#27364f !important;
  background:linear-gradient(180deg,#ffffff,#eef4ff) !important;
  box-shadow:0 4px 0 rgba(30,40,60,.16), inset 0 0 0 3px rgba(88,204,2,.20) !important;
  color:#172033 !important;
}
body[data-theme="night"] .study-review-tabs button:not(.active),
body[data-theme="night"] .card-zone .ghost-btn,
body[data-theme="night"] #studyActions .ghost-btn {
  color:#172033 !important;
  background:linear-gradient(180deg,#ffffff,#edf2f7) !important;
  border-color:rgba(30,40,60,.10) !important;
}
body[data-theme="night"] .study-review-tabs button.active {
  color:#ffffff !important;
  background:#111827 !important;
}
body[data-theme="night"] #studyActions .primary-btn,
body[data-theme="night"] .card-zone .primary-btn {
  color:#10210a !important;
}
.unit-vocab-row {
  grid-template-columns:44px minmax(90px,.9fr) minmax(80px,.7fr) minmax(160px,1.4fr) minmax(110px,.8fr);
}
.unit-vocab-row p {
  margin:0;
  color:#334155;
  font-weight:800;
  line-height:1.35;
}
@media (max-width: 760px) {
  .unit-vocab-row { grid-template-columns:32px 1fr; }
  .unit-vocab-row em,
  .unit-vocab-row p,
  .unit-vocab-row small { grid-column:2; }
}

/* === Sammy Defender embedded main game === */
.sammy-embed-layout {
  max-width: 1220px;
  margin-inline: auto;
}

.sammy-iframe-shell {
  padding: clamp(8px, 1.5vw, 14px);
  overflow: hidden;
  background: linear-gradient(135deg, #111827, #1f2a44 54%, #05070d);
  border-color: rgba(255, 234, 167, 0.26);
}

#sammyDefenderFrame {
  display: block;
  width: 100%;
  aspect-ratio: 20 / 9;
  min-height: 430px;
  max-height: min(78vh, 720px);
  border: 0;
  border-radius: 24px;
  overflow: hidden;
  background: #05070d;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 18px 44px rgba(0,0,0,.22);
}

.game-card[data-game-type="defense"] span,
.game-card[data-game-type="sammy"] span {
  display: none !important;
}

@media (max-width: 760px) {
  .sammy-embed-layout {
    width: 100%;
    max-width: 100%;
  }
  .sammy-iframe-shell {
    padding: 6px;
    border-radius: 20px;
  }
  #sammyDefenderFrame {
    min-height: min(74vh, 520px);
    aspect-ratio: 20 / 12;
    border-radius: 18px;
  }
}

/* === Polish pass: icons, defender frame, mobile unit summary, footer === */
.game-card .game-icon {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 0 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(244,255,232,.96));
  box-shadow: inset 0 0 0 1px rgba(23,32,51,.08), 0 10px 22px rgba(57,38,20,.08);
  font-size: 25px;
}

.main-game-card {
  border: 2px solid rgba(124, 58, 237, .62) !important;
  box-shadow: 0 18px 46px rgba(124, 58, 237, .18), inset 0 0 0 1px rgba(255,255,255,.62) !important;
  background: linear-gradient(135deg, #ffffff, #f8f4ff 55%, #fff8ec) !important;
}

.main-game-card .game-icon {
  background: linear-gradient(135deg, #7c3aed, #f59e0b);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(124,58,237,.1), 0 12px 28px rgba(124,58,237,.22);
}

.game-card[data-game-type="defense"] span.game-icon,
.game-card[data-game-type="sammy"] span.game-icon {
  display: inline-grid !important;
}

.sammy-iframe-shell {
  border: 3px solid rgba(124,58,237,.7) !important;
  box-shadow: 0 0 0 4px rgba(245,158,11,.14), 0 24px 70px rgba(17,24,39,.18);
}

.sammy-embed-layout .game-topbar {
  margin-bottom: 12px;
}

@supports selector(body:has(.sammy-embed-layout)) {
  body:has(.sammy-embed-layout) .app-shell {
    width: min(100% - 16px, 1480px);
  }
}

.unit-summary-card {
  overflow: hidden;
}
.unit-vocab-table {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.unit-vocab-row.is-unseen small { color: #dc2626; }
.unit-vocab-row.is-learning small { color: #d97706; }
.unit-vocab-row.is-mastered small { color: #2563eb; }
.unit-vocab-row.is-unseen { border-color: rgba(220,38,38,.18); background: linear-gradient(135deg,#fff,#fff5f5); }
.unit-vocab-row.is-learning { border-color: rgba(217,119,6,.2); background: linear-gradient(135deg,#fff,#fffbeb); }

.site-footer {
  margin: 34px auto 0;
  padding: 20px 12px 6px;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}
.site-footer img {
  width: min(190px, 46vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 16px 28px rgba(57,38,20,.16));
}
.site-footer p {
  margin: 0;
  font-weight: 800;
  letter-spacing: .01em;
}
.site-footer strong { color: var(--ink); }
body[data-theme="night"] .site-footer { color: #cbd5e1; }
body[data-theme="night"] .site-footer strong { color: #fff; }
body[data-theme="night"] .site-footer img { filter: drop-shadow(0 0 22px rgba(255,255,255,.18)); }

@media (max-width: 760px) {
  @supports selector(body:has(.sammy-embed-layout)) {
    body:has(.sammy-embed-layout) .app-shell {
      width: 100%;
      padding: 6px 4px 12px;
    }
    body:has(.sammy-embed-layout) .topbar {
      margin-inline: 6px;
    }
  }
  .sammy-embed-layout .game-topbar {
    padding: 8px 10px;
    border-radius: 18px;
    gap: 8px;
  }
  .sammy-embed-layout .game-topbar h2 {
    font-size: clamp(20px, 6vw, 30px);
  }
  .sammy-embed-layout .game-score {
    gap: 5px;
    font-size: 12px;
  }
  #sammyDefenderFrame {
    width: 100%;
    height: calc(100dvh - 112px);
    min-height: min(620px, calc(100dvh - 112px));
    max-height: none;
    aspect-ratio: auto;
  }
  .unit-summary-card {
    max-height: calc(100dvh - 165px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .unit-vocab-table {
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
  }
  .unit-vocab-row {
    width: 100%;
    text-align: left;
  }
  .unit-summary-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .unit-summary-stats span {
    padding: 8px 6px;
    text-align: center;
  }
}


/* Polishing pass: smoother game embeds, lighter unit summary, compact footer. */
.gold-instruction.is-hidden { opacity: 0; transform: translateY(8px); pointer-events: none; transition: .22s ease; }
.home-welcome-modal .welcome-copy { font-size: clamp(19px, 3vw, 28px); line-height: 1.35; font-weight: 900; color: var(--ink); }
body[data-theme="night"] .home-welcome-modal .welcome-copy { color: #f8fafc; }
.sammy-iframe-shell { position: relative; }
.sammy-frame-controls { position: absolute; z-index: 5; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; }
.sammy-frame-controls button { pointer-events: auto; padding: 8px 12px; min-height: 36px; background: rgba(255,255,255,.86); backdrop-filter: blur(10px); }
.sammy-exit-fullscreen-btn { display: none; }
.sammy-landscape-hint { display: none; margin: 0 0 8px; padding: 10px 12px; border-radius: 16px; background: rgba(124,58,237,.12); color: var(--ink); font-weight: 900; text-align: center; }
.sammy-iframe-shell:fullscreen { width: 100vw; height: 100dvh; max-width: none; padding: 0 !important; border: 0 !important; border-radius: 0 !important; background: #05070d; }
.sammy-iframe-shell:fullscreen #sammyDefenderFrame { width: 100vw; height: 100dvh; min-height: 0; max-height: none; border-radius: 0; aspect-ratio: auto; }
.sammy-iframe-shell:fullscreen .sammy-fullscreen-btn { display: none; }
.sammy-iframe-shell:fullscreen .sammy-exit-fullscreen-btn { display: inline-flex; }
.unit-vocab-row { content-visibility: auto; contain-intrinsic-size: 92px; }
.unit-summary-card { overflow: visible !important; }
.site-footer { margin: 28px auto 0 !important; padding: 14px 12px 4px !important; display: flex !important; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; text-align: center; }
.site-footer img { width: 46px !important; height: 46px !important; object-fit: contain; flex: 0 0 auto; }
.site-footer p { margin: 0 !important; }
body[data-theme="night"] .site-footer img { filter: drop-shadow(0 0 16px rgba(255,255,255,.28)); }
@media (max-width: 760px) {
  .sammy-frame-controls { top: 8px; left: 8px; right: 8px; }
  .sammy-frame-controls button { font-size: 12px; padding: 7px 10px; }
  .sammy-landscape-hint { display: block; }
  .unit-summary-card { max-height: none !important; display: block !important; overflow: visible !important; }
  .unit-vocab-table { max-height: none !important; min-height: 0 !important; overflow: visible !important; touch-action: auto !important; padding-right: 0 !important; }
  .unit-vocab-row { grid-template-columns: 34px 1fr !important; gap: 6px 10px; }
  .unit-vocab-row em, .unit-vocab-row p, .unit-vocab-row small { grid-column: 2; }
  .site-footer img { width: 38px !important; height: 38px !important; }
}


/* Mobile stability pass: modal, avatar landscape, Sammy pseudo fullscreen. */
body.sammy-game-active { overscroll-behavior: none; }
body.sammy-pseudo-fullscreen { overflow: hidden !important; touch-action: none; }
.sammy-iframe-shell.is-sammy-pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: #05070d !important;
}
.sammy-iframe-shell.is-sammy-pseudo-fullscreen #sammyDefenderFrame {
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: 0 !important;
  aspect-ratio: auto !important;
}
.sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-fullscreen-btn { display:none; }
.sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-exit-fullscreen-btn { display:inline-flex; }
.modal-backdrop { z-index: 10000; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal.panel, .modal { background: var(--panel-strong); }
@media (max-width: 760px) {
  .modal-backdrop { align-items: start; place-items: start center; padding: 12px; }
  .modal { width: min(100%, 560px); max-height: calc(100dvh - 24px); border-radius: 24px; padding: 18px !important; }
  .modal .panel-heading { align-items: flex-start; gap: 10px; }
  .modal .panel-heading h2 { font-size: 24px; line-height: 1.1; }
  .modal #closeModalBtn { flex: 0 0 auto; padding: 9px 14px; }
  .home-welcome-modal { gap: 10px; }
  .home-welcome-modal .welcome-copy { font-size: 21px; line-height: 1.18; }
  .home-welcome-modal .primary-btn { width: 100%; min-height: 52px; white-space: normal; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .profile-panel { overflow: visible; }
  .clean-avatar-card {
    grid-template-columns: minmax(180px, 240px) minmax(260px, 1fr) !important;
    gap: 12px !important;
    padding: 14px !important;
  }
  .clean-cat-stage { min-height: 190px !important; }
  .avatar-character.clean-cat-character { width: min(210px, 40vw); height: 156px; }
  .avatar-cat-img { max-height: 165px; }
  .avatar-celestial { width: 42px; height: 42px; right: 18px; top: 16px; }
  .avatar-grass { height: 46px; }
  .cat-profile-copy { gap: 8px; align-content: center; }
  .cat-profile-copy h3 { font-size: 22px; line-height: 1.08; }
  .cat-name-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .cat-name-form input { width: 100%; }
  #buyUnitBtn { width: auto; min-height: 48px; white-space: normal; padding-inline: 16px; }
}


/* === Audio/mobile polish pass: safer fullscreen, clearer night modal, balanced profile === */
.sammy-frame-controls {
  left: auto !important;
  right: 12px !important;
  justify-content: flex-end !important;
  width: auto !important;
}
.sammy-frame-controls button {
  color: #172033 !important;
  background: rgba(255,255,255,.92) !important;
  border: 1px solid rgba(30,40,60,.12) !important;
  box-shadow: 0 10px 24px rgba(15,23,42,.14);
}
body[data-theme="night"] .cat-game-topbar .ghost-btn,
body[data-theme="night"] .sammy-frame-controls button,
body[data-theme="night"] .sammy-landscape-hint {
  color: #172033 !important;
  background: rgba(255,255,255,.94) !important;
  border-color: rgba(255,255,255,.32) !important;
}
body.sammy-pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}
.sammy-iframe-shell.is-sammy-pseudo-fullscreen,
.sammy-iframe-shell.is-sammy-pseudo-fullscreen #sammyDefenderFrame {
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}
.sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-frame-controls {
  top: max(8px, env(safe-area-inset-top)) !important;
  right: max(8px, env(safe-area-inset-right)) !important;
}
body[data-theme="night"] .modal,
body[data-theme="night"] .modal.panel {
  background: linear-gradient(180deg,#ffffff,#f4f7fb) !important;
  color: #172033 !important;
  border-color: rgba(255,255,255,.32) !important;
}
body[data-theme="night"] .modal .panel-heading h2,
body[data-theme="night"] .home-welcome-modal .welcome-copy {
  color: #172033 !important;
  text-shadow: none !important;
}
body[data-theme="night"] .modal .muted,
body[data-theme="night"] .home-welcome-modal p:not(.welcome-copy) {
  color: #64748b !important;
}
body[data-theme="night"] .modal .ghost-btn {
  color: #172033 !important;
  background: #fff !important;
  border-color: rgba(30,40,60,.12) !important;
}
.clean-avatar-card {
  grid-template-columns: minmax(220px, .9fr) minmax(240px, 1fr) !important;
  align-items: center !important;
  overflow: hidden !important;
}
.cat-profile-copy { min-width: 0; }
.cat-name-form input { flex: 1 1 170px; max-width: 260px; }
.cat-profile-copy .primary-btn { width: fit-content; max-width: 100%; }
.option-grid button.is-correct,
.option-grid button.picked-correct {
  border-color: rgba(88,204,2,.9) !important;
  background: linear-gradient(135deg,#ecffd7,#d9f99d) !important;
  color: #172033 !important;
  box-shadow: 0 0 0 4px rgba(88,204,2,.14);
}
.option-grid button.picked-wrong {
  border-color: rgba(239,68,68,.88) !important;
  background: linear-gradient(135deg,#fff1f2,#fecdd3) !important;
  color: #7f1d1d !important;
}
.option-grid button:disabled { opacity: .95; cursor: default; }
@media (max-width: 900px) {
  .dashboard-grid,
  .home-dashboard-grid { grid-template-columns: 1fr !important; }
  .clean-avatar-card { grid-template-columns: 1fr !important; }
  .cat-profile-copy .primary-btn { width: 100%; }
  .sammy-frame-controls { top: 8px !important; right: 8px !important; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .dashboard-grid,
  .home-dashboard-grid { grid-template-columns: 1fr !important; }
  .profile-panel { overflow: hidden !important; }
  .clean-avatar-card {
    grid-template-columns: minmax(170px, 230px) minmax(0, 1fr) !important;
    max-width: 100% !important;
    gap: 12px !important;
  }
  .clean-cat-stage { min-height: 180px !important; }
  .cat-profile-copy { font-size: 14px; }
}


/* === Patch: defender mobile lock, night result, very-known panel === */
.sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-landscape-hint,
.sammy-iframe-shell:fullscreen .sammy-landscape-hint { display: none !important; }
.sammy-frame-controls { justify-content: flex-end !important; }
.sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-frame-controls { pointer-events: none !important; }
.sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-frame-controls button { pointer-events: auto !important; }
body[data-theme="night"] .game-result,
body[data-theme="night"] .game-result.panel {
  background: linear-gradient(180deg,#ffffff,#f6fbff) !important;
  color: #172033 !important;
  border-color: rgba(15,23,42,.08) !important;
}
body[data-theme="night"] .game-result h2,
body[data-theme="night"] .game-result p,
body[data-theme="night"] .game-result .eyebrow,
body[data-theme="night"] .game-result .muted { color: #172033 !important; text-shadow: none !important; }
body[data-theme="night"] .game-result .ghost-btn { color: #172033 !important; background: #fff !important; }
.very-known-panel { border-color: rgba(88,204,2,.18); }
.very-known-collapsible summary strong { color: #3f8f16; }
.very-known-item summary span { color: #3f8f16; font-weight: 900; }
.listen-next-btn { margin-top: 12px; width: min(280px, 100%); }
@media (max-width: 900px) and (orientation: landscape) {
  .sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-frame-controls { top: max(4px, env(safe-area-inset-top)) !important; right: max(4px, env(safe-area-inset-right)) !important; }
  .sammy-iframe-shell.is-sammy-pseudo-fullscreen .sammy-frame-controls button { transform: scale(.86); transform-origin: right top; opacity: .86; }
}
