/* ══════════════════════════════════════════════════════════════════
   MORI NO GAKKŌ — Design System
   Palette: Amazon Dark Navy + Orange, professional & structured
══════════════════════════════════════════════════════════════════ */
:root {
  /* Amazon-inspired palette */
  --navy:       #232F3E;   /* Amazon dark header */
  --navy-mid:   #2D3A4A;
  --navy-lt:    #37475A;   /* secondary dark */
  --navy-card:  #1C2733;   /* card background */
  --orange:     #FF9900;   /* Amazon orange */
  --orange-dk:  #E47911;   /* hover orange */
  --orange-lt:  #FEBD69;   /* soft gold */
  --teal:       #00A8A2;   /* accent teal (Amazon teal) */
  --green:      #067D62;
  --green-lt:   #00C851;
  --red:        #CC0C39;
  --red-lt:     #FF4B4B;
  --warn:       #F0AD00;

  --bg:         #131921;   /* darkest Amazon bg */
  --surface:    #1C2733;
  --surface2:   #232F3E;
  --surface3:   #2D3A4A;
  --border:     #3D4F63;
  --border-lt:  #4A6078;

  --text:       #F2F2F2;
  --text2:      #ADBAC7;
  --text3:      #6E8091;
  --text-inv:   #0F1111;

  --radius:     10px;
  --radius-sm:  6px;
  --radius-lg:  16px;
  --shadow-sm:  0 2px 8px rgba(0,0,0,.4);
  --shadow:     0 4px 20px rgba(0,0,0,.55);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.65);
  --glow-orange:0 0 20px rgba(255,153,0,.25);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP",
          "Helvetica Neue", Arial, sans-serif;
  --transition: .17s ease;
}

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

html { font-size: 16px; height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button  { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul      { list-style: none; }
img     { max-width: 100%; display: block; }

/* ══════════════════════════════════════════════════════════════════
   SCREEN SYSTEM
══════════════════════════════════════════════════════════════════ */
#app { position: relative; min-height: 100dvh; }

.screen {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: block; }

.screen-inner {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 540px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════
   ── SPLASH SCREEN ──────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
#screen-splash {
  background: linear-gradient(160deg, #131921 0%, #1a2a3a 55%, #0d1f2d 100%);
}

.splash-inner {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 24px 28px;
  text-align: center;
}

.splash-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-image {
  width: min(260px, 68vw);
  height: min(260px, 68vw);
  border-radius: 28px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(255,153,0,.18);
  object-fit: cover;
  animation: float 4s ease-in-out infinite;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}

.splash-kana {
  font-size: .85rem;
  color: var(--orange-lt);
  letter-spacing: .18em;
  font-weight: 500;
}

.splash-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.01em;
  line-height: 1.1;
}

.splash-sub {
  font-size: .95rem;
  color: var(--text2);
  margin-top: 2px;
  margin-bottom: 12px;
}

.splash-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 15px 36px;
  background: var(--orange);
  color: var(--text-inv);
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius);
  box-shadow: var(--glow-orange);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.splash-btn:hover  { background: var(--orange-dk); box-shadow: 0 0 30px rgba(255,153,0,.4); }
.splash-btn:active { transform: scale(.97); }

.splash-footer {
  font-size: .75rem;
  color: var(--text3);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding-top: 8px;
}

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

/* ══════════════════════════════════════════════════════════════════
   ── BUTTONS ────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */

/* Primary — orange */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  background: var(--orange);
  color: var(--text-inv);
  font-size: .97rem;
  font-weight: 700;
  border-radius: var(--radius);
  transition: background var(--transition), transform var(--transition);
  border: none;
}
.btn-primary:hover  { background: var(--orange-dk); }
.btn-primary:active { transform: scale(.98); }

/* Secondary — outlined */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  background: transparent;
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  transition: border-color var(--transition), background var(--transition);
}
.btn-secondary:hover { border-color: var(--orange); color: var(--orange); }

/* Ghost */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  color: var(--text2);
  font-size: .88rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: color var(--transition), border-color var(--transition);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-lt); }

.btn-large { padding: 15px 20px; font-size: 1rem; }
.btn-sm    { padding: 7px 14px; font-size: .82rem; border-radius: var(--radius-sm); }

.btn-icon {
  background: none; border: none;
  font-size: 1.25rem; padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer; opacity: .7;
  transition: opacity var(--transition);
}
.btn-icon:hover { opacity: 1; }
.btn-icon.danger { color: var(--red-lt); }

.btn-back {
  background: none; border: none;
  color: var(--orange);
  font-size: .9rem; font-weight: 600;
  padding: 4px 0;
  white-space: nowrap;
}
.btn-back:hover { color: var(--orange-lt); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: transparent; color: var(--red-lt);
  font-size: .82rem; border-radius: var(--radius-sm);
  border: 1px solid rgba(204,12,57,.5);
  transition: background var(--transition);
}
.btn-danger:hover { background: rgba(204,12,57,.12); }

/* Toggle group */
.btn-group { display: flex; gap: 6px; }
.btn-toggle {
  flex: 1; padding: 10px 12px;
  background: var(--surface2);
  color: var(--text2);
  font-size: .88rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  transition: all var(--transition);
}
.btn-toggle.active {
  background: var(--orange);
  color: var(--text-inv);
  border-color: var(--orange);
  font-weight: 700;
}

/* Hint + quick-grade row */
.hint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.quick-grade-btns-inline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Hint button */
.btn-hint {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px;
  background: rgba(254,189,105,.08);
  color: var(--orange-lt);
  font-size: .82rem; font-weight: 600;
  border: 1px solid rgba(254,189,105,.3);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.btn-hint:hover:not(:disabled) { background: rgba(254,189,105,.16); }
.btn-hint:disabled { opacity: .4; cursor: not-allowed; }

/* Compact inline quick-grade buttons */
.btn-quick-compact {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-quick-compact .qg-icon { font-size: .95rem; line-height: 1; }

/* Self-grade */
.btn-grade {
  flex: 1; padding: 12px 8px;
  font-size: .88rem; font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  transition: all var(--transition);
}
.btn-wrong   { background: rgba(204,12,57,.12);  color: var(--red-lt);  border-color: rgba(204,12,57,.35); }
.btn-partial { background: rgba(240,173,0,.12);  color: var(--warn);    border-color: rgba(240,173,0,.35); }
.btn-right   { background: rgba(6,125,98,.15);   color: var(--green-lt);border-color: rgba(6,125,98,.35); }
.btn-wrong:hover   { background: rgba(204,12,57,.25); }
.btn-partial:hover { background: rgba(240,173,0,.25); }
.btn-right:hover   { background: rgba(6,125,98,.28); }

/* ══════════════════════════════════════════════════════════════════
   ── FORM CONTROLS ──────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.select-ctrl {
  appearance: none;
  width: 100%;
  padding: 11px 36px 11px 14px;
  background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236E8091' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font-size: .93rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition);
}
.select-ctrl:focus  { outline: none; border-color: var(--orange); }
.select-ctrl option { background: var(--surface2); color: var(--text); }
.select-sm { width: auto; padding: 7px 30px 7px 10px; font-size: .82rem; }

/* ══════════════════════════════════════════════════════════════════
   ── STAT CHIPS ─────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.stat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .8rem; color: var(--text2);
  white-space: nowrap;
}
.level-chip { color: var(--orange); border-color: rgba(255,153,0,.4); }

/* ══════════════════════════════════════════════════════════════════
   ── HOME SCREEN ────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */

/* Top bar — matches Amazon dark header */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 14px;
  border-bottom: 2px solid var(--orange);
  margin-bottom: 4px;
  gap: 12px;
}

.app-logo { display: flex; align-items: center; gap: 10px; }

.home-logo-img {
  width: 46px; height: 46px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.home-logo-text { display: flex; flex-direction: column; gap: 1px; }

.logo-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--orange);
  letter-spacing: -.01em;
  line-height: 1.2;
}
.logo-kana {
  font-size: .72rem;
  color: var(--text3);
  letter-spacing: .12em;
}

.home-global-stats { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }

.home-main { display: flex; flex-direction: column; gap: 18px; padding-top: 18px; }

/* Setting groups */
.setting-group { display: flex; flex-direction: column; gap: 7px; }

.setting-label {
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text3);
  font-weight: 700;
}
.setting-hint { font-size: .78rem; color: var(--text3); margin-top: -4px; }

/* Nav buttons at bottom */
.home-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.home-nav .btn-ghost { flex: 1; min-width: 90px; font-size: .82rem; }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

/* ══════════════════════════════════════════════════════════════════
   ── PRACTICE SCREEN ────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */

/* Top bar */
.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 10px;
  border-bottom: 2px solid var(--orange);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.ph-streak {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: .95rem; font-weight: 800;
  min-width: 60px;
}
.streak-fire { font-size: 1rem; }

.ph-score {
  font-size: 1.05rem; font-weight: 700;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
}
.score-c  { color: var(--green-lt); }
.score-sep{ color: var(--text3); margin: 0 2px; }
.score-t  { color: var(--text2); }

.ph-xp {
  font-size: .88rem; font-weight: 700;
  color: var(--orange);
  background: rgba(255,153,0,.1);
  border: 1px solid rgba(255,153,0,.3);
  border-radius: 20px;
  padding: 5px 12px;
}

/* Practice main */
.practice-main {
  display: flex; flex-direction: column; gap: 14px;
  padding-top: 18px; flex: 1;
}

/* Question card */
.q-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-top: 3px solid var(--orange);
  border-radius: var(--radius-lg);
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
  min-height: 150px; justify-content: center;
}
.q-direction {
  font-size: .72rem;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 700;
}
.q-text {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text);
  word-break: break-word;
}
.q-hint-line {
  font-size: 1rem;
  color: var(--orange-lt);
  background: rgba(254,189,105,.07);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  animation: fade-in .3s ease;
}

/* Phases */
.practice-phase { display: none; flex-direction: column; gap: 10px; }
.practice-phase.active { display: flex; }

/* Input */
.answer-input {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.answer-input:focus  { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,153,0,.12); }
.answer-input::placeholder { color: var(--text3); }

.sentence-input {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface2);
  color: var(--text);
  font-size: .97rem; line-height: 1.55;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.sentence-input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,153,0,.12); }
.sentence-input::placeholder { color: var(--text3); }

.btn-quick-no {
  background: rgba(204,12,57,.1);
  color: var(--red-lt);
  border-color: rgba(204,12,57,.3);
}
.btn-quick-no:hover {
  background: rgba(204,12,57,.22);
  border-color: rgba(204,12,57,.6);
  transform: translateY(-1px);
}

.btn-quick-yes {
  background: rgba(6,125,98,.12);
  color: var(--green-lt);
  border-color: rgba(6,125,98,.35);
}
.btn-quick-yes:hover {
  background: rgba(6,125,98,.25);
  border-color: rgba(6,125,98,.65);
  transform: translateY(-1px);
}

/* Feedback */
.fb-result {
  font-size: 1.3rem; font-weight: 800;
  text-align: center; padding: 10px;
  border-radius: var(--radius-sm);
}
.fb-result.correct { color: var(--green-lt); background: rgba(6,125,98,.12); }
.fb-result.partial { color: var(--warn);     background: rgba(240,173,0,.1); }
.fb-result.wrong   { color: var(--red-lt);   background: rgba(204,12,57,.1); }

.fb-correct { text-align: center; font-size: 1.2rem; font-weight: 700; color: var(--text); }
.fb-kana    { text-align: center; font-size: .95rem; color: var(--text2); }
.fb-alts    { text-align: center; font-size: .78rem; color: var(--text3); }

/* Self-grade */
.sg-label {
  font-size: .72rem; color: var(--text3);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 700;
}
.sg-attempt {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: .97rem; color: var(--text2);
  min-height: 52px; white-space: pre-wrap; word-break: break-word;
}
.sg-divider {
  text-align: center; font-size: .78rem; color: var(--text3);
  letter-spacing: .08em;
  position: relative;
}
.sg-divider::before, .sg-divider::after {
  content: '';
  position: absolute; top: 50%;
  width: 30%; height: 1px;
  background: var(--border);
}
.sg-divider::before { left: 0; }
.sg-divider::after  { right: 0; }

.sg-answer {
  background: var(--navy-card);
  border: 1.5px solid var(--green);
  border-radius: var(--radius-sm); padding: 14px 16px;
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.sg-kana  { font-size: .88rem; color: var(--text2); text-align: center; }
.sg-alts  { font-size: .78rem; color: var(--text3); text-align: center; }
.sg-buttons { display: flex; gap: 8px; margin-top: 4px; }

.practice-footer { padding: 12px 0 20px; text-align: center; }

/* ══════════════════════════════════════════════════════════════════
   ── SIMPLE HEADER (editor, stats, reference, session-end) ──────
══════════════════════════════════════════════════════════════════ */
.simple-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 14px;
  border-bottom: 2px solid var(--orange);
  margin-bottom: 20px;
  position: sticky; top: 0;
  background: var(--bg); z-index: 10;
}
.simple-header h1 { font-size: 1.15rem; font-weight: 800; flex: 1; }

/* ══════════════════════════════════════════════════════════════════
   ── SESSION END ─────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.se-main { display: flex; flex-direction: column; gap: 22px; }

.se-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.se-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: var(--shadow-sm);
}
.se-icon { font-size: 1.5rem; }
.se-val  { font-size: 2rem; font-weight: 800; color: var(--text); }
.se-lbl  { font-size: .72rem; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; }

.se-missed h3 { font-size: .88rem; color: var(--text2); margin-bottom: 10px; }
.se-missed-list { display: flex; flex-direction: column; gap: 6px; }
.se-missed-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: .88rem;
  display: flex; justify-content: space-between; gap: 12px;
}
.missed-jp { color: var(--orange-lt); font-weight: 600; }
.missed-de { color: var(--text2); }

.se-actions { display: flex; flex-direction: column; gap: 10px; }

/* ══════════════════════════════════════════════════════════════════
   ── EDITOR ──────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.editor-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.editor-tabs {
  display: flex; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.tab {
  flex: 1; padding: 9px 12px;
  background: var(--surface); color: var(--text2);
  font-size: .88rem; font-weight: 600; border: none;
  transition: all var(--transition);
}
.tab.active { background: var(--orange); color: var(--text-inv); }

.editor-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.editor-load-btn { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

.editor-table-wrap {
  overflow-x: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 54dvh; overflow-y: auto;
}
.editor-table { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.editor-table th {
  background: var(--surface2); padding: 9px 10px;
  text-align: left; color: var(--text3); font-size: .73rem;
  text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
  position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--border);
}
.editor-table td {
  padding: 9px 10px; border-top: 1px solid var(--border);
  color: var(--text); vertical-align: top;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.editor-table tr:hover td { background: var(--surface2); }
.td-actions { overflow: visible !important; white-space: nowrap; }
.col-actions { display: flex; gap: 4px; }
.btn-edit { padding: 3px 8px; border-radius: 4px; font-size: .76rem; font-weight: 700;
  background: rgba(0,161,162,.15); color: var(--teal); }
.btn-del  { padding: 3px 8px; border-radius: 4px; font-size: .76rem; font-weight: 700;
  background: rgba(204,12,57,.15); color: var(--red-lt); }
.btn-edit:hover { background: rgba(0,161,162,.3); }
.btn-del:hover  { background: rgba(204,12,57,.3); }

.editor-empty { text-align: center; padding: 36px; color: var(--text3); font-size: .9rem; }

.editor-footer { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.editor-footer-hint { font-size: .75rem; color: var(--text3); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end;
}
@media (min-height: 600px) { .modal { align-items: center; } }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative; z-index: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-top: 3px solid var(--orange);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px; width: 100%; max-width: 540px;
  margin: 0 auto; max-height: 90dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
@media (min-height: 600px) { .modal-box { border-radius: var(--radius-lg); } }
.modal-box h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 16px; color: var(--orange); }

.modal-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.modal-field { display: flex; flex-direction: column; gap: 4px; }
.modal-field label {
  font-size: .72rem; color: var(--text3);
  text-transform: uppercase; letter-spacing: .09em; font-weight: 700;
}
.modal-field input {
  width: 100%; padding: 10px 12px;
  background: var(--surface2); color: var(--text);
  font-size: .93rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.modal-field input:focus { outline: none; border-color: var(--orange); }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn-secondary { flex: 1; }
.modal-actions .btn-primary   { flex: 2; }

/* ══════════════════════════════════════════════════════════════════
   ── STATS ───────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.stats-main { display: flex; flex-direction: column; gap: 18px; }
.stats-section-title {
  font-size: .73rem; color: var(--orange);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 700;
  margin-bottom: 8px;
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 14px;
  display: flex; flex-direction: column; gap: 3px;
  box-shadow: var(--shadow-sm);
}
.stats-card-val { font-size: 1.75rem; font-weight: 800; color: var(--orange); }
.stats-card-lbl { font-size: .76rem; color: var(--text2); }

.xp-bar-wrap { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; }
.xp-bar-bg {
  background: var(--surface2); border-radius: 6px; height: 10px;
  overflow: hidden; margin-bottom: 6px;
}
.xp-bar-fill {
  height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--orange-dk), var(--orange), var(--orange-lt));
  transition: width .7s ease;
}
.xp-bar-label { font-size: .76rem; color: var(--text3); }

.word-progress-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.word-progress-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: .84rem;
}
.wpi-jp  { color: var(--orange-lt); min-width: 90px; font-size: .88rem; font-weight: 600; }
.wpi-de  { flex: 1; color: var(--text2); }
.wpi-bar { width: 60px; height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; }
.wpi-bar-fill { height: 100%; border-radius: 4px; }
.wpi-pct { font-size: .75rem; color: var(--text3); min-width: 32px; text-align: right; }

/* ══════════════════════════════════════════════════════════════════
   ── REFERENCE ───────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.ref-main { display: flex; flex-direction: column; gap: 16px; }
.ref-section-title {
  font-size: .73rem; color: var(--orange);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 700;
  margin-bottom: 6px;
}
.ref-grid { display: flex; flex-direction: column; gap: 8px; }
.ref-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius); padding: 13px 16px;
  display: flex; flex-direction: column; gap: 3px;
}
.ref-card-jp  { font-size: 1.25rem; color: var(--orange-lt); font-weight: 700; }
.ref-card-rom { font-size: .82rem; color: var(--text3); }
.ref-card-de  { font-size: .93rem; color: var(--text); font-weight: 700; }
.ref-card-use { font-size: .8rem; color: var(--text2); border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.ref-example  { font-size: .76rem; color: var(--text3); font-style: italic; }

/* ══════════════════════════════════════════════════════════════════
   ── TOAST ───────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 28px;
  left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 11px 24px;
  border-radius: 30px; font-size: .88rem; font-weight: 700;
  z-index: 500; box-shadow: var(--shadow);
  pointer-events: none; white-space: nowrap;
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.streak  { background: #2a1a00; border-color: var(--orange); color: var(--orange); }
.toast.success { background: #001a12; border-color: var(--green-lt); color: var(--green-lt); }
.toast.info    { background: var(--surface3); border-color: var(--teal); color: var(--teal); }

/* ══════════════════════════════════════════════════════════════════
   ── CELEBRATION OVERLAY ─────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.celebration-overlay {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(5px);
  animation: fade-in .2s ease;
}
.celebration-box {
  text-align: center; padding: 36px 44px;
  background: var(--surface);
  border: 2px solid var(--orange);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--glow-orange);
  animation: pop-in .3s cubic-bezier(.34,1.56,.64,1);
}
.cel-emoji { font-size: 3.5rem; display: block; margin-bottom: 10px; }
.cel-title { font-size: 1.65rem; font-weight: 800; color: var(--orange); }
.cel-sub   { font-size: 1rem; color: var(--text2); margin-top: 6px; }

/* ══════════════════════════════════════════════════════════════════
   ── CONFETTI CANVAS ─────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.confetti-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 300;
}

/* ══════════════════════════════════════════════════════════════════
   ── ANIMATIONS ──────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pop-in {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}

.anim-shake { animation: shake .4s ease; }

/* ══════════════════════════════════════════════════════════════════
   ── RESPONSIVE ──────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  .q-text        { font-size: 1.65rem; }
  .se-val        { font-size: 1.6rem; }
  .splash-title  { font-size: 1.8rem; }
  .splash-btn    { padding: 13px 26px; font-size: .97rem; }
}

@media (min-width: 520px) {
  .screen-inner    { padding: 0 28px 44px; }
  .splash-inner    { padding: 48px 32px 32px; }
  .splash-image    { width: 300px; height: 300px; }
  .q-card          { padding: 36px 32px; min-height: 170px; }
  .q-text          { font-size: 2.3rem; }
}

/* Scrollbar — subtle dark style */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-lt); }

/* ══════════════════════════════════════════════════════════════════
   ── AUDIO BUTTON ────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════ */
.q-card { position: relative; }

.btn-audio {
  position: absolute;
  bottom: 10px; right: 10px;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1rem;
  color: var(--text2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1;
}
.btn-audio:hover    { background: var(--navy-lt); color: var(--orange); border-color: var(--orange); }
.btn-audio:active   { transform: scale(.93); }
.btn-audio:disabled { opacity: .5; cursor: default; }

/* Auto-play toggle — lights up orange when active */
#audio-autoplay-btn.active { color: var(--orange); border-color: var(--orange); }

