/* ==========================================================
   JAPANESE MASTER — Editorial Design System
   OKLCH-based, typography-first, purposeful motion
   ========================================================== */

/* ==========================================================
   DESIGN TOKENS — OKLCH Color System
   ========================================================== */
:root {
  /* --- Brand Palette --- */
  --ink:          oklch(12% 0.015 260);
  --ink-soft:     oklch(28% 0.020 260);
  --muted:        oklch(52% 0.018 260);
  --muted-light:  oklch(68% 0.012 260);
  --surface-dim:  oklch(92% 0.008 260);
  --surface:      oklch(97% 0.004 260);
  --surface-pure: oklch(99% 0.002 260);

  /* --- Accent: Traditional Indigo (Aizome) --- */
  --accent:       oklch(70.334% 0.13135 244.43);
  --accent-hover: oklch(62.402% 0.16296 251.05);
  --accent-dim:   oklch(48% 0.14 250 / 0.10);
  --accent-glow:  oklch(48% 0.14 250 / 0.22);

  /* --- Secondary: Deep Teal --- */
  --blue:         oklch(45% 0.12 210);
  --blue-dim:     oklch(45% 0.12 210 / 0.10);

  /* --- Semantic --- */
  --success:      oklch(52% 0.18 145);
  --success-dim:  oklch(52% 0.18 145 / 0.10);
  --error:        oklch(55% 0.22 25);
  --error-dim:    oklch(55% 0.22 25 / 0.10);
  --warning:      oklch(68% 0.18 65);

  /* --- Typography Scale --- */
  --text-xs:   clamp(0.75rem,  0.72rem + 0.2vw,  0.85rem);
  --text-sm:   clamp(0.875rem, 0.82rem + 0.28vw, 1rem);
  --text-base: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
  --text-md:   clamp(1.35rem,  1.20rem + 0.7vw,  1.6rem);
  --text-lg:   clamp(1.75rem,  1.50rem + 1.2vw,  2.2rem);
  --text-xl:   clamp(2.5rem,   2.00rem + 2.5vw,  3.5rem);
  --text-2xl:  clamp(3.5rem,   2.50rem + 5vw,    6rem);
  --text-huge: clamp(5rem,     4rem    + 8vw,    10rem);

  /* --- Font Families --- */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-jp:      'Noto Sans JP', sans-serif;

  /* --- Spacing (4px grid) --- */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* --- Motion --- */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Legacy aliases (JS compatibility) --- */
  --primary-color:   var(--accent);
  --primary-dark:    var(--accent-hover);
  --secondary-color: var(--blue);
  --accent-color:    var(--accent);
  --success-color:   var(--success);
  --error-color:     var(--error);
  --warning-color:   var(--warning);
  --text-dark:       var(--ink);
  --text-light:      var(--muted);
  --bg-light:        var(--surface-dim);
  --bg-white:        var(--surface-pure);
  --shadow:          0 4px 20px oklch(12% 0.015 260 / 0.08);
  --shadow-lg:       0 12px 48px oklch(12% 0.015 260 / 0.12);
  --gradient:        linear-gradient(135deg, var(--accent) 0%, oklch(40% 0.12 220) 100%);
  --gradient-light:  linear-gradient(135deg, var(--accent-dim), var(--blue-dim));
}

/* ==========================================================
   RESET & BASE
   ========================================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Google Fonts import via link tag in HTML — no @import needed */

/* ==========================================================
   BACKGROUND
   ========================================================== */
.bg-elements {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.bg-elements::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 5%,  oklch(48% 0.14 250 / 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 50% 70% at 85% 95%, oklch(45% 0.12 210 / 0.04) 0%, transparent 60%);
}

/* Hide old decorative circles */
.bg-circle { display: none; }

/* ==========================================================
   SCREEN & LAYOUT
   ========================================================== */
.screen {
  display: none;
  width: 100%;
  padding: var(--sp-6) var(--sp-4);
  flex-grow: 1;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 860px;
  background: var(--surface-pure);
  border-radius: 20px;
  padding: clamp(var(--sp-8), 5vw, var(--sp-16)) clamp(var(--sp-6), 4vw, var(--sp-12));
  box-shadow: var(--shadow-lg);
  border: 1px solid oklch(12% 0.015 260 / 0.06);
  animation: page-in 0.55s var(--ease-out-expo) both;
}

.main-hub { max-width: 960px; }

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

/* ==========================================================
   HEADER & TYPOGRAPHY
   ========================================================== */
.header { margin-bottom: var(--sp-10); }

.title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: var(--sp-2);
  display: inline-block;
}

/* Accent rule beneath title */
.title::after {
  content: '';
  display: block;
  width: 2.5rem;
  height: 3px;
  background: var(--accent);
  margin: var(--sp-3) auto 0;
  border-radius: 2px;
}

.subtitle {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: var(--sp-5);
}

/* ==========================================================
   WELCOME
   ========================================================== */
.welcome-section {
  margin-bottom: var(--sp-8);
  color: var(--muted);
  font-size: var(--text-sm);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

/* ==========================================================
   EDITORIAL LIST LAYOUT
   ========================================================== */
.editorial-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-10);
  margin-top: var(--sp-8);
  width: 100%;
}

.editorial-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-6);
  padding: var(--sp-6) 0;
  border-bottom: 1.5px solid oklch(12% 0.015 260 / 0.08);
  position: relative;
  transition: transform 0.4s var(--ease-out-quart);
  align-items: center;
}

.editorial-item:hover {
  transform: translateX(12px);
}

.editorial-item:last-child {
  border-bottom: none;
}

.ed-num {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--surface-dim);
  font-weight: 300;
  line-height: 0.8;
  transition: color 0.4s var(--ease-out-quart);
}

.editorial-item:hover .ed-num {
  color: var(--accent);
}

.ed-content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 500px;
}

.display-huge {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
}

.ed-content p {
  color: var(--muted);
  font-size: var(--text-base);
  line-height: 1.5;
  margin: 0;
}

.ed-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  margin-left: auto;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.4s var(--ease-out-quart), transform 0.4s var(--ease-out-quart);
}

.editorial-item:hover .ed-actions {
  opacity: 1;
  transform: translateX(0);
}

.ed-badge {
  position: absolute;
  top: var(--sp-6);
  right: 0;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 40px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

@media (max-width: 768px) {
  .editorial-item {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
  }
  .ed-actions {
    margin-left: 0;
    opacity: 1;
    transform: none;
    margin-top: var(--sp-4);
  }
  .ed-num {
    font-size: var(--text-xl);
  }
}


/* ==========================================================
   BUTTONS
   ========================================================== */
.btn-primary,
.btn-secondary,
.btn-submit,
.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition:
    background   0.2s var(--ease-out-quart),
    color        0.2s var(--ease-out-quart),
    transform    0.15s var(--ease-out-quart),
    box-shadow   0.2s var(--ease-out-quart),
    border-color 0.2s var(--ease-out-quart);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--surface-pure);
  padding: var(--sp-4) var(--sp-8);
  border-radius: 4px;
  font-size: var(--text-base);
  box-shadow: none;
  width: 100%;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-dim);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  padding: var(--sp-4) var(--sp-6);
  border-radius: 10px;
  font-size: var(--text-base);
  border: 1.5px solid oklch(12% 0.015 260 / 0.15);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-dim);
  border-color: oklch(12% 0.015 260 / 0.28);
  transform: translateY(-1px);
  color: var(--ink);
}

.btn-submit {
  background: var(--success);
  color: var(--surface-pure);
  padding: var(--sp-3) var(--sp-6);
  border-radius: 4px;
  font-size: var(--text-base);
  min-width: 92px;
  box-shadow: none;
}
.btn-submit:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-primary-sm {
  background: var(--ink);
  color: var(--surface-pure);
  padding: var(--sp-2) var(--sp-5);
  border-radius: 4px;
  font-size: var(--text-sm);
  box-shadow: none;
}
.btn-primary-sm:hover {
  background: var(--ink-soft);
  transform: translateY(-1px);
}

.btn-link {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.2s;
  display: inline-block;
}
.btn-link:hover { border-bottom-color: var(--accent); }

button:disabled, a:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-icon {
  font-size: 1em;
  font-style: normal;
  transition: transform 0.2s var(--ease-out-quart);
}
.btn-primary:hover .btn-icon { transform: translateX(3px); }

/* ==========================================================
   ACTION BUTTONS GROUP
   ========================================================== */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.secondary-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
}

.secondary-actions .btn-secondary {
  flex: 1;
  font-size: var(--text-sm);
  padding: var(--sp-3) var(--sp-4);
}

/* ==========================================================
   START SCREEN CONTENT
   ========================================================== */
#start-screen .content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

/* ==========================================================
   INSTRUCTIONS CARD
   ========================================================== */
.instructions-card {
  background: var(--surface-dim);
  border-radius: 12px;
  padding: var(--sp-5) var(--sp-6);
  text-align: left;
  border: 1px solid oklch(12% 0.015 260 / 0.06);
}

.instructions-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--ink-soft);
  margin-bottom: var(--sp-3);
}

.instructions-card ul { list-style: none; }

.instructions-card li {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--sp-2);
  padding-left: var(--sp-5);
  position: relative;
  line-height: 1.6;
}

.instructions-card li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* Legacy instructions (alternate markup) */
.instructions { text-align: left; }
.instructions h3 { color: var(--ink); margin-bottom: var(--sp-4); }
.instructions ul { list-style: none; }
.instructions li {
  padding: var(--sp-2) 0 var(--sp-2) var(--sp-6);
  color: var(--muted);
  position: relative;
  font-size: var(--text-sm);
}
.instructions li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
}

/* ==========================================================
   SETTINGS
   ========================================================== */
.basic-settings { margin-bottom: var(--sp-2); }

.quiz-length-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  background: var(--surface-dim);
  padding: var(--sp-4) var(--sp-6);
  border-radius: 12px;
  border: 1px solid oklch(12% 0.015 260 / 0.06);
  margin: 0 auto;
  max-width: 360px;
}

.quiz-length-container label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
}

#quiz-length-input,
#countdown-minutes,
#start-range-input,
#end-range-input,
#start-kanji-input {
  width: 72px;
  padding: var(--sp-2) var(--sp-3);
  border: 1.5px solid oklch(12% 0.015 260 / 0.12);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  text-align: center;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-pure);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#quiz-length-input:focus,
#countdown-minutes:focus,
#start-range-input:focus,
#end-range-input:focus,
#start-kanji-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ==========================================================
   ADVANCED OPTIONS
   ========================================================== */
.advanced-options-details { text-align: left; }

.advanced-summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  padding: var(--sp-3) var(--sp-4);
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  user-select: none;
  list-style: none;
  letter-spacing: 0.02em;
}
.advanced-summary::-webkit-details-marker { display: none; }
.advanced-summary:hover { color: var(--accent); background: var(--accent-dim); }

.learning-options,
.start-from-container {
  background: var(--surface-dim);
  border-radius: 12px;
  padding: var(--sp-5);
  margin-top: var(--sp-3);
  border: 1px solid oklch(12% 0.015 260 / 0.06);
  text-align: left;
  animation: fadeIn 0.25s var(--ease-out-quart) both;
}

.learning-options h3,
.start-from-container h3 {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: var(--sp-4);
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.option-label {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-pure);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.option-label:hover { background: oklch(12% 0.015 260 / 0.03); }

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  margin-right: var(--sp-3);
  accent-color: var(--accent);
  flex-shrink: 0;
}

.option-text {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  font-weight: 500;
}

.countdown-mode-container,
.repetition-mode-container,
.contoh-kata-mode-container,
.no-hints-container {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid oklch(12% 0.015 260 / 0.08);
}

#countdown-settings {
  margin-top: var(--sp-3);
  padding-left: var(--sp-8);
  animation: fadeIn 0.25s var(--ease-out-quart) both;
}

#countdown-settings label {
  font-size: var(--text-sm);
  color: var(--muted);
  display: block;
  margin-bottom: var(--sp-2);
}

/* Selectors */
.category-selector,
.specific-kanji-selector,
.range-selector {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-pure);
  border-radius: 8px;
  border: 1px solid oklch(12% 0.015 260 / 0.08);
  animation: fadeIn 0.25s var(--ease-out-quart) both;
}

.category-selector label,
.specific-kanji-selector label,
.range-selector label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.category-selector select,
#voice-selection-container select {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1.5px solid oklch(12% 0.015 260 / 0.12);
  border-radius: 8px;
  background: var(--surface-pure);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

.category-selector select:focus,
#voice-selection-container select:focus {
  outline: none;
  border-color: var(--accent);
}

.range-inputs {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}
.range-selector .input-field { flex: 1; }
.range-selector .input-field input { width: 100%; }

small { font-size: var(--text-xs); color: var(--muted-light); }

/* ==========================================================
   GAME SCREEN
   ========================================================== */
#game-container { background: var(--surface); }

#game-container.active {
  flex-direction: column;
  justify-content: flex-start;
  padding-top: var(--sp-4);
}

/* ==========================================================
   GAME HEADER
   ========================================================== */
.game-header {
  width: 100%;
  max-width: 520px;
  background: var(--surface-pure);
  padding: var(--sp-4) var(--sp-6);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid oklch(12% 0.015 260 / 0.06);
  margin-bottom: var(--sp-6);
  position: relative;
  animation: page-in 0.5s var(--ease-out-expo) both;
}

.id-display {
  position: absolute;
  top: var(--sp-4); left: var(--sp-4);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-light);
  background: var(--surface-dim);
  padding: 3px var(--sp-3);
  border-radius: 40px;
}

.score-display {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--sp-3);
}

.score-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  margin-right: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.score-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--accent);
  font-weight: 400;
}

.score-max { font-size: var(--text-sm); color: var(--muted-light); }

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface-dim);
  border-radius: 2px;
  overflow: hidden;
  margin-top: var(--sp-3);
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s var(--ease-out-quart);
  width: 0%;
}

/* ==========================================================
   TIMER
   ========================================================== */
.timer-display {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: var(--ink);
  color: var(--surface-pure);
  padding: 4px var(--sp-4);
  border-radius: 40px;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  margin: var(--sp-3) auto var(--sp-1);
  width: fit-content;
  transition: background 0.3s;
}

#timer-value { font-variant-numeric: tabular-nums; }

/* ==========================================================
   GAME CONTENT
   ========================================================== */
.game-content {
  max-width: 480px;
  width: 100%;
  padding: 0 var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ==========================================================
   FLASHCARD
   ========================================================== */
.hint-wrapper {
  position: relative;
  margin-bottom: var(--sp-2);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 40px;
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--muted);
  font-weight: 500;
  width: 100%;
  max-width: 380px;
}

#hint-icon, #hint-text {
  position: absolute;
  transition: opacity 0.25s var(--ease-out-quart);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

#hint-icon.active, #hint-text.active {
  opacity: 1;
  pointer-events: auto;
}

#hint-icon { font-size: 1.5em; }

#hint-text {
  padding: 5px var(--sp-5);
  border-radius: 40px;
  background: var(--accent-dim);
  border: 1.5px solid oklch(48% 0.14 250 / 0.18);
  color: var(--accent);
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  max-width: 95vw;
}

.flashcard-wrapper {
  position: relative;
  margin-bottom: var(--sp-6);
  perspective: 1200px;
  animation: card-enter 0.5s var(--ease-out-expo) both;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.kanji-card {
  width: clamp(240px, 35vh, 380px);
  height: clamp(240px, 35vh, 380px);
  position: relative;
  z-index: 2;
  transform-style: preserve-3d;
  transition: transform 0.8s var(--ease-out-expo);
  cursor: pointer;
}

.kanji-card.flipped { transform: rotateY(180deg); }

.card-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
}

.card-front, .card-back {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.card-front { z-index: 2; }

.card-back {
  transform: rotateY(180deg);
  flex-direction: column;
  padding: var(--sp-5);
  z-index: 1;
}

.kanji-character {
  font-family: var(--font-jp);
  font-size: var(--text-huge);
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  text-shadow: 0 20px 40px oklch(12% 0.015 260 / 0.15);
  transition: transform 0.4s var(--ease-out-quart), color 0.4s;
}

.kanji-card:hover .kanji-character {
  transform: translateY(-8px);
  color: var(--accent);
}

.contoh-kata-container { text-align: center; }

.contoh-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: var(--sp-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.contoh-kata-text {
  font-family: var(--font-jp);
  font-size: 2.2em;
  font-weight: 700;
  color: var(--accent);
}

.card-shine {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 280px; height: 280px;
  background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0.5;
  filter: blur(28px);
  z-index: 1;
  pointer-events: none;
}

/* ==========================================================
   INPUT & ANSWER
   ========================================================== */
.input-wrapper {
  width: 100%;
  max-width: 380px;
  margin: 0 auto var(--sp-3);
}

.input-group {
  display: flex;
  gap: var(--sp-3);
  align-items: stretch;
}

#answer-input {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid oklch(12% 0.015 260 / 0.12);
  border-radius: 10px;
  font-size: var(--text-base);
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface-pure);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#answer-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

#answer-input::placeholder { color: var(--muted-light); }

/* ==========================================================
   RESULT MESSAGE
   ========================================================== */
.result-message {
  margin: 0 0 var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  min-height: 40px;
  max-width: 380px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity   0.25s var(--ease-out-quart),
    transform 0.25s var(--ease-out-quart);
  opacity: 0;
  transform: translateY(4px);
  visibility: hidden;
  word-break: break-word;
  line-height: 1.4;
  text-align: center;
}

.result-message.show {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.result-message.correct {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid oklch(52% 0.18 145 / 0.2);
}

.result-message.incorrect {
  background: var(--error-dim);
  color: var(--error);
  border: 1px solid oklch(55% 0.22 25 / 0.2);
}

/* ==========================================================
   GAME CONTROLS
   ========================================================== */
.game-controls {
  margin-top: var(--sp-2);
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ==========================================================
   MUTE BUTTON
   ========================================================== */
.mute-btn {
  position: absolute;
  top: var(--sp-4); right: var(--sp-4);
  background: var(--surface-dim);
  border: 1.5px solid oklch(12% 0.015 260 / 0.10);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1em;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  z-index: 100;
  padding: 0;
}
.mute-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  transform: scale(1.08);
}
.mute-btn.muted { border-color: var(--error); color: var(--error); }

/* ==========================================================
   TOAST NOTIFICATIONS
   ========================================================== */
.toast-container {
  position: fixed;
  top: var(--sp-5); right: var(--sp-5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  background: var(--surface-pure);
  color: var(--ink);
  padding: var(--sp-4) var(--sp-5);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 272px;
  max-width: 400px;
  transform: translateX(120%);
  transition: transform 0.45s var(--ease-out-expo);
  pointer-events: auto;
  border-left: 3px solid var(--accent);
}
.toast.show { transform: translateX(0); }
.toast.error { border-left-color: var(--error); }
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--blue); }

.toast-icon { font-size: 1.3em; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: var(--text-sm); color: var(--ink); margin-bottom: 1px; }
.toast-message { font-size: var(--text-xs); color: var(--muted); }

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}
.toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: oklch(12% 0.015 260 / 0.08); width: 0; }
.toast.show .toast-progress { animation: toastProgress 3s linear forwards; }

/* ==========================================================
   FOOTER
   ========================================================== */
.main-footer {
  width: 100%;
  padding: var(--sp-5);
  text-align: center;
  border-top: 1px solid oklch(12% 0.015 260 / 0.06);
  margin-top: auto;
  position: relative;
  z-index: 10;
}

.footer-content p {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--muted-light);
  letter-spacing: 0.04em;
}

.heart {
  color: var(--accent);
  display: inline-block;
  animation: heartbeat 2s ease-in-out infinite;
}

.author { font-weight: 600; color: var(--muted); }

@keyframes heartbeat {
  0%, 80%, 100% { transform: scale(1); }
  40%           { transform: scale(1.3); }
}

/* ==========================================================
   KANJI LIST PAGE OVERRIDE
   ========================================================== */
body.kanji-list-page {
  display: block;
  text-align: left;
}
body.kanji-list-page main { margin: 0 auto; padding: var(--sp-5); }
body.kanji-list-page .header { text-align: center; }

/* ==========================================================
   ANIMATIONS
   ========================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes flipIn {
  from { transform: rotateY(90deg); opacity: 0; }
  to   { transform: rotateY(0deg);  opacity: 1; }
}

/* ==========================================================
   REDUCED MOTION
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 768px) {
  .container { padding: var(--sp-8) var(--sp-5); border-radius: 16px; }
  .learning-path { grid-template-columns: 1fr; }
  .kanji-card { width: 220px; height: 220px; }
  .kanji-character { font-size: 4.5em; }
  .contoh-kata-text { font-size: 1.8em; }
  .input-group { flex-direction: column; }
  #answer-input { width: 100%; text-align: center; }
  .btn-submit { width: 100%; }
}

@media (max-width: 480px) {
  .container { padding: var(--sp-6) var(--sp-4); border-radius: 14px; }
  #game-container.active { padding-top: var(--sp-2); }
  .game-header { padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); }
  .kanji-card { width: 180px; height: 180px; }
  .kanji-character { font-size: 3.2em; }
  .btn-primary, .btn-secondary, .btn-submit { padding: var(--sp-3) var(--sp-5); font-size: var(--text-sm); }
  .quiz-length-container { flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); }
  .id-display { font-size: var(--text-xs); top: var(--sp-2); left: var(--sp-2); }
  .mute-btn { top: var(--sp-2); right: var(--sp-2); width: 32px; height: 32px; font-size: 14px; }
  .result-message { min-height: 32px; font-size: 0.8em; }
  .game-controls { gap: var(--sp-2); }
  .hint-wrapper { height: 32px; margin-bottom: var(--sp-1); }
  .flashcard-wrapper { margin-bottom: var(--sp-4); }
}

.category-selector select option,
#voice-selection-container select option {
  background: var(--surface-pure);
  color: var(--ink);
}
