/* styles.css — Reverse Engineer */

/* ─── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --purple: #1B2A6B;
  --purple-light: #2D45A0;
  --purple-dark: #111A47;
  --purple-faint: #E8EBF7;
  --green: #22C55E;
  --green-bg: #DCFCE7;
  --yellow: #F59E0B;
  --yellow-bg: #FEF3C7;
  --red: #EF4444;
  --red-bg: #FEE2E2;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-btn: 0 4px 14px rgba(27, 42, 107, 0.35);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", "Cascadia Code", Menlo, monospace;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Semantic tokens (light defaults) ── */
  --bg:          #F5F5F7;
  --surface:     #ffffff;
  --surface-2:   var(--gray-50);
  --header-bg:   rgba(255, 255, 255, 0.85);
  --border:      var(--gray-200);
  --border-faint:var(--gray-100);
  --text-primary:   var(--gray-800);
  --text-secondary: var(--gray-600);
  --text-muted:     var(--gray-600);
  --text-faint:     var(--gray-500);
  --text-hairline:  var(--gray-400);
  --hint-bg:     #FFFBEB;
  --hint-border: #FDE68A;
  --hint-text:   #78350F;
  --hint-text-2: #92400E;
  --color-correct: #16A34A;
  --color-close:   #D97706;
  --color-wrong:   #DC2626;
}

/* ─── Dark mode overrides ────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --purple:       #7B8FE8;
  --purple-light: #9AAAF0;
  --purple-dark:  #5C72D6;
  --bg:          #0F0F11;
  --surface:     #1C1C1E;
  --surface-2:   #2C2C2E;
  --header-bg:   rgba(28, 28, 30, 0.88);
  --border:      #3A3A3C;
  --border-faint:#2C2C2E;
  --text-primary:   #F2F2F7;
  --text-secondary: #C7C7CC;
  --text-muted:     #AEAEB2;
  --text-faint:     #8E8E93;
  --text-hairline:  #636366;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  --purple-faint:#1E1A38;
  --green-bg:    #0D2818;
  --yellow-bg:   #2A1F00;
  --red-bg:      #2C0F0F;
  --hint-bg:     #1F1A00;
  --hint-border: #5C4A00;
  --hint-text:   #FCD34D;
  --hint-text-2: #FDE68A;
  --color-correct: #4ADE80;
  --color-close:   #FCD34D;
  --color-wrong:   #F87171;
}

/* ─── Theme transition ───────────────────────────────────────────────────────── */
html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body, .card, .header, .modal-content, .result-card, .answer-input {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* ─── Utilities ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

/* ─── Focus visibility ───────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 3px;
}

/* Input already shows a purple border+shadow on focus — suppress the outline */
.answer-input:focus-visible,
.beta-input:focus-visible {
  outline: none;
}

/* ─── App shell ─────────────────────────────────────────────────────────────── */
.app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.header {
  padding: 14px 20px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-logo .logo-icon {
  width: 22px;
  height: 22px;
  color: var(--purple);
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

.header-logo-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.header-content > div:last-child {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.logo-word-1 { color: #C2410C; }
.logo-word-2 { color: var(--purple); }

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--purple);
  flex-shrink: 0;
}

.puzzle-number {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  white-space: nowrap;
  letter-spacing: 0.1px;
  min-height: 14px;
}

#admin-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.admin-diff-btns {
  display: flex;
  gap: 3px;
}

.admin-diff-btn {
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--purple-faint);
  transition: background var(--transition), color var(--transition);
}

.admin-diff-btn:hover {
  background: var(--border);
}

.admin-diff-btn.active {
  background: var(--purple);
  color: #fff;
}

.admin-puzzle-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

#admin-puzzle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
}

.admin-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: var(--purple-faint);
  color: var(--purple);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.admin-nav-btn:hover {
  background: var(--border);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn:active { background: var(--border); }

.icon-btn svg { width: 20px; height: 20px; }

/* ─── Main ───────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  padding: 24px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (prefers-reduced-motion: no-preference) {
  .card { animation: card-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) both; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Card top row */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-top-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-top-logo .logo-icon {
  width: 26px;
  height: 26px;
  color: var(--purple);
}

/* Badges */
.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
}

.badge-easy   { background: #DCFCE7; color: #166534; }
.badge-medium { background: #FEF3C7; color: #854D0E; }
.badge-hard   { background: #FEE2E2; color: #991B1B; }

/* ─── Examples ──────────────────────────────────────────────────────────────── */
.examples {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.example-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-faint);
}

.example-word {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
  min-width: 80px;
}

.example-eq {
  font-size: 18px;
  font-weight: 300;
  color: var(--text-faint);
  flex-shrink: 0;
}

.example-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--purple);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

/* ─── Separator ─────────────────────────────────────────────────────────────── */
.separator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-hairline);
}

.separator-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.separator-text {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-hairline);
  white-space: nowrap;
}

/* ─── Target row ────────────────────────────────────────────────────────────── */
.target-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--purple-faint);
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(109, 74, 255, 0.18);
}

.target-word {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--text-primary);
  min-width: 80px;
}

.target-question {
  font-size: 28px;
  font-weight: 900;
  color: var(--purple);
  margin-left: auto;
  line-height: 1;
}

/* ─── Input section ─────────────────────────────────────────────────────────── */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-wrapper {
  position: relative;
}

.answer-input {
  width: 100%;
  height: 54px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: center;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -moz-appearance: textfield;
}

.answer-input::-webkit-inner-spin-button,
.answer-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.answer-input::placeholder {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-hairline);
}

.answer-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(109, 74, 255, 0.12);
}

/* Primary button */
.btn-primary {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--purple);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.1px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  background: var(--purple-light);
  box-shadow: 0 6px 20px rgba(109, 74, 255, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--purple-dark);
  transform: translateY(0);
  box-shadow: var(--shadow-btn);
}

/* Secondary button */
.btn-secondary {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}

.btn-secondary:hover { background: var(--border); }
.btn-secondary:active { background: var(--text-hairline); transform: scale(0.98); }

.btn-hint-icon {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  background: var(--purple-faint);
  border: 1.5px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.btn-hint-icon:hover { background: var(--border); border-color: var(--text-hairline); }
.btn-hint-icon:disabled { opacity: 0.3; cursor: default; }
.hint-confirm {
  background: var(--hint-bg);
  border: 1.5px solid var(--hint-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--hint-text);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hint-confirm.hidden { display: none; }

.hint-confirm-actions {
  display: flex;
  gap: 8px;
}

.hint-confirm-btn {
  flex: 1;
  height: 36px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 700;
}

.hint-confirm-yes {
  background: var(--purple);
  color: #fff;
}
.hint-confirm-yes:hover { background: var(--purple-light); }

.hint-confirm-cancel {
  background: var(--surface-2);
  color: var(--text-primary);
}
.hint-confirm-cancel:hover { background: var(--border); }

.hint-box {
  background: var(--hint-bg);
  border: 1.5px solid var(--hint-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--hint-text-2);
  font-weight: 500;
  line-height: 1.4;
  margin-top: 2px;
}

/* ─── Attempts ───────────────────────────────────────────────────────────────── */
.attempts-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.attempts-dots {
  display: flex;
  gap: 7px;
}

.attempt-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--purple);
  transition: background var(--transition), transform var(--transition);
}

.attempt-dot.used {
  background: var(--border);
  transform: scale(0.85);
}

.attempts-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
}

/* ─── Guess list ────────────────────────────────────────────────────────────── */
.guesses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.wrong-chips-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.guess-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  letter-spacing: 0.2px;
}

.guess-chip--wrong {
  background: var(--red-bg);
  color: var(--color-wrong);
  border-color: rgba(239, 68, 68, 0.2);
}

.guess-chip--close {
  background: var(--yellow-bg);
  color: var(--color-close);
  border-color: rgba(245, 158, 11, 0.25);
}

.guess-chip--correct {
  background: var(--green-bg);
  color: var(--color-correct);
  border-color: rgba(34, 197, 94, 0.25);
}

.guess-chip--hint {
  background: var(--surface-2);
  color: var(--text-faint);
  border-color: var(--border);
  font-size: 18px;
}

.chip-arrow {
  font-size: 10px;
  font-weight: 700;
  margin-left: 2px;
  opacity: 0.75;
  vertical-align: middle;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.guess-correct {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.25);
}

.guess-close {
  background: var(--yellow-bg);
  border-color: rgba(245, 158, 11, 0.25);
}

.guess-wrong {
  background: var(--red-bg);
  border-color: rgba(239, 68, 68, 0.2);
}

.guess-emoji {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.guess-number {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  min-width: 40px;
}

.guess-hint {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: auto;
}

.guess-correct .guess-hint { color: var(--color-correct); }
.guess-close   .guess-hint { color: var(--color-close); }
.guess-wrong   .guess-hint { color: var(--color-wrong); }

/* ─── Animations ────────────────────────────────────────────────────────────── */
.animate-in {
  animation: none;
}

@media (prefers-reduced-motion: no-preference) {
  .animate-in { animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1) both; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@media (prefers-reduced-motion: no-preference) {
  .shake { animation: shake 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
  .shake-card { animation: shake-card 0.3s ease; }
}

@keyframes shake-card {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

@keyframes pulse-success {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70%  { box-shadow: 0 0 0 16px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ─── Result overlay ────────────────────────────────────────────────────────── */
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 0.3s;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.result-overlay.visible {
  background: rgba(0, 0, 0, 0.35);
  pointer-events: all;
}

.result-overlay.hidden {
  display: none;
}

.result-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-lg);
  padding: 32px 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

@media (prefers-reduced-motion: no-preference) {
  .result-card { animation: sheet-up 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
}

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

.result-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  transition: background var(--transition), color var(--transition);
}
.result-close:hover { background: var(--surface-2); color: var(--text-secondary); }
.result-close svg { width: 18px; height: 18px; }

.result-icon { font-size: 52px; line-height: 1; }
.result-title { font-size: 26px; font-weight: 800; color: var(--text-primary); }

.result-subtitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: -4px;
}

.result-explanation {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  line-height: 1.5;
  width: 100%;
  text-align: left;
}

/* ─── Social proof ───────────────────────────────────────────────────────────── */
.result-social-proof {
  width: 100%;
  background: var(--purple-faint);
  border: 1px solid rgba(109, 74, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.result-social-proof-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
  max-width: 64px;
}

.result-social-proof-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--purple);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-social-proof strong {
  color: var(--purple);
  font-weight: 700;
}

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

.result-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border-faint);
  width: 100%;
}

.result-countdown-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
}

.result-countdown-timer {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--purple);
  letter-spacing: 2px;
}

/* ─── Stats modal ───────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

@media (prefers-reduced-motion: no-preference) {
  .modal-content { animation: modal-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1); }
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
}

.distribution h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.dist-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  width: 14px;
  text-align: right;
}

.dist-bar-wrap {
  flex: 1;
  background: var(--surface-2);
  border-radius: 4px;
  height: 22px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  background: var(--text-hairline);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  min-width: 22px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.dist-bar-filled { background: var(--purple); }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--text-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 40px;
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.hidden { display: none; }

/* ─── Responsive tweaks ─────────────────────────────────────────────────────── */
@media (min-width: 480px) {
  .main { padding: 32px 24px 40px; }
  .card { padding: 32px 28px; }
  .example-word { font-size: 19px; }
  .example-value { font-size: 24px; }
  .target-word { font-size: 22px; }
}

@media (max-height: 700px) {
  .card { gap: 14px; }
  .main { padding: 16px 16px 24px; }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  .header { padding-top: max(14px, env(safe-area-inset-top)); }
}

#app { width: 100%; display: flex; justify-content: center; }

/* ─── Dev toolbar (localhost only) ─────────────────────────────────────────── */
#dev-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,0.1);
  font-family: var(--mono);
  font-size: 12px;
  color: #fff;
}

.dev-label {
  font-weight: 700;
  color: #F59E0B;
  margin-right: 4px;
}

#dev-toolbar button {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

#dev-toolbar button:hover { background: rgba(255,255,255,0.22); }

#dev-select {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  flex: 1;
  max-width: 220px;
}

/* ─── Difficulty Picker ──────────────────────────────────────────────────────── */
.difficulty-picker {
  width: 100%;
  margin-top: auto;
  margin-bottom: auto;
}

.picker-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.picker-seg {
  position: relative;
  display: flex;
  background: rgba(120, 120, 128, 0.12);
  border-radius: 10px;
  padding: 3px;
}

[data-theme="dark"] .picker-seg {
  background: rgba(120, 120, 128, 0.28);
}

.picker-seg-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.14), 0 1px 1px rgba(0,0,0,0.08);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1),
              width   0.22s cubic-bezier(0.34, 1.2, 0.64, 1),
              opacity 0.15s ease;
}

[data-theme="dark"] .picker-seg-indicator {
  background: #48484A;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4), 0 1px 1px rgba(0,0,0,0.3);
}

.picker-seg-btn {
  flex: 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--text-primary);
  transition: color 0.15s;
}

.picker-btn-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.picker-btn-status {
  font-size: 10px;
  line-height: 1;
  min-height: 10px;
  color: var(--text-secondary);
}

/* ─── Stats Tabs ─────────────────────────────────────────────────────────────── */
.stats-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.stats-tab {
  flex: 1;
  padding: 7px 4px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.stats-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* ─── Result More ────────────────────────────────────────────────────────────── */
.result-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--border-faint);
}

.result-more-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-more-btns {
  display: flex;
  gap: 8px;
}

.result-more-btn {
  padding: 8px 18px;
  border-radius: 20px;
  border: 2px solid transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s;
  background: var(--surface-2);
  color: var(--text-primary);
}

.result-more-btn:hover { transform: translateY(-1px); }
.result-more-btn--easy   { border-color: #86EFAC; }
.result-more-btn--medium { border-color: #FCD34D; }
.result-more-btn--hard   { border-color: #FCA5A5; }

[data-theme="dark"] .result-more-btn--easy   { border-color: #166534; }
[data-theme="dark"] .result-more-btn--medium { border-color: #854D0E; }
[data-theme="dark"] .result-more-btn--hard   { border-color: #991B1B; }

/* ─── Archive modal ─────────────────────────────────────────────────────────── */
.archive-modal-content {
  max-height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.archive-list {
  margin-top: 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overscroll-behavior: contain;
}

.archive-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-faint);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  text-align: left;
  width: 100%;
  color: var(--text-primary);
  font-family: inherit;
}

.archive-item:hover {
  background: var(--border);
  border-color: var(--border);
}

.archive-item-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 72px;
}

.archive-item-num {
  font-size: 13px;
  color: var(--text-faint);
  flex: 1;
}

.archive-item-status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.archive-item-status--solved   { background: var(--green-bg);  color: var(--color-correct); }
.archive-item-status--failed   { background: var(--red-bg);    color: var(--color-wrong); }
.archive-item-status--unplayed { background: var(--purple-faint); color: var(--purple); }

.archive-loading {
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  padding: 32px 0;
}

