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

:root {
  /* Core Neutrals */
  --ink: #0f172a;          /* Sleek Dark Slate */
  --bg-main: #f8fafc;      /* Crisp, bright canvas */
  --bg-subtle: #f1f5f9;    /* Clean structural light gray */
  --card-bg: #ffffff;      /* Pure white for modern cards */
  --border: #cbd5e1;       /* Neutral, crisp border */

  /* Primary Branding (Teal Evolution) */
  --primary: #0d9488;      /* Vibrant digital teal */
  --primary-light: #ccfbf1;/* Fresh, clean backdrop tint */

  /* Secondary Accent (Gold/Amber Evolution) */
  --accent: #111;       /* Energetic amber/gold */
  --accent-light: #fef3c7; /* Soft amber tint */

  /* Shadows & Depth */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.08);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Serif JP', serif;
  background: var(--bg-main);
  color: var(--ink);
  min-height: 100vh;
  /* Reimagined modern, clean atmospheric gradients using modern palette shades */
  background-image:
    radial-gradient(ellipse at 10% 0%, rgba(217, 119, 6, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(13, 148, 136, 0.05) 0%, transparent 50%);
}

/* ── HEADER ── */
header {
  background: var(--ink);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 16px;
}

.logo { 
  display: flex; 
  align-items: baseline; 
  gap: 10px; 
  text-decoration: none; 
  flex-shrink: 0; /* Prevents logo from crushing on small mobile screens */
}

.logo-jp { font-size: 1rem; font-weight: 900; color: var(--accent-light); letter-spacing: 0.04em; }
.logo-en { font-size: 0.7rem; color: var(--border); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 400; opacity: 0.8; }

/* ── NEW: Level Selector Styling ── */
.level-selector-wrap {
  margin-left: auto; /* Pushes the dropdown cleanly to the right side next to any secondary elements */
}

.level-selector-wrap p{
  color: #ffe;
  font-size: 0.9rem;
  font-weight: bold;
}

.level-selector-wrap .unit-select {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.level-selector-wrap .unit-select:hover,
.level-selector-wrap .unit-select:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent-light);
}

/* Styled option blocks for browser support */
.level-selector-wrap .unit-select option {
  background: var(--ink);
  color: #ffffff;
}

/* Kept for backwards compatibility if badge is used elsewhere */
.header-badge {
  background: white; color: var(--ink);
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 4px 10px; border-radius: 4px;
  font-family: 'DM Mono', monospace;
}


/* ── HERO ── */
.hero {
  max-width: 1100px; margin: 0 auto; padding: 48px 24px 32px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.hero-text { flex: 1; min-width: 220px; }
.unit-tag {
  font-family: 'DM Mono', monospace; font-size: 0.7rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-light);
  padding: 4px 10px; border-radius: 4px;
  display: inline-block; margin-bottom: 14px;
  border-left: 3px solid var(--primary);
}
.hero-title {
  font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 900;
  line-height: 1.15; color: var(--ink); letter-spacing: -0.02em;
}
.hero-title span { color: var(--accent); }
.hero-subtitle {
  margin-top: 10px; font-size: 0.75rem; color: var(--ink); opacity: 0.65;
  font-weight: 400; font-family: 'Noto Sans Myanmar', sans-serif;
}
.hero-right { display: flex; flex-direction: column; gap: 14px; align-items: flex-end; }

/* ── UNIT SELECTOR ── */
.unit-selector-wrap { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.unit-sel-label {
  font-family: 'DM Mono', monospace; font-size: 0.7rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.unit-select {
  appearance: none;
  background: var(--card-bg) 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='%230d9488' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1.5px solid var(--border); border-radius: 6px;
  padding: 9px 36px 9px 14px;
  font-family: 'DM Mono', monospace; font-size: 0.78rem;
  color: var(--ink); cursor: pointer; min-width: 260px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.unit-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15); }

.hero-stats { display: flex; gap: 12px; }
.stat-pill {
  text-align: center; background: var(--card-bg);
  border: 1px solid var(--border); padding: 10px 20px;
  border-radius: 6px; box-shadow: var(--shadow-sm);
}
.stat-number { font-size: 1.6rem; font-weight: 900; color: var(--primary); display: block; line-height: 1; }
.stat-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink); opacity: 0.6; font-family: 'DM Mono', monospace; margin-top: 4px; display: block; }

/* ── MODE TABS ── */
.mode-tabs { max-width: 1100px; margin: 0 auto 20px; padding: 0 24px; display: flex; gap: 6px; }
.mode-tab {
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 6px;
  padding: 8px 20px; font-family: 'DM Mono', monospace; font-size: 0.72rem;
  letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  color: var(--ink); opacity: 0.7; transition: all 0.15s;
}
.mode-tab.active { background: var(--ink); color: var(--accent-light); border-color: var(--ink); opacity: 1; }
.mode-tab:hover:not(.active) { border-color: var(--primary); color: var(--primary); opacity: 1; }

/* ── CONTROLS ── */
.controls {
  max-width: 1100px; margin: 0 auto 8px; padding: 0 24px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--border); pointer-events: none; }
#searchInput {
  width: 100%; padding: 11px 14px 11px 42px;
  border: 1.5px solid var(--border); border-radius: 6px;
  font-family: 'Noto Serif JP', serif; font-size: 0.9rem;
  background: var(--card-bg); color: var(--ink); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#searchInput:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15); }
#searchInput::placeholder { color: var(--border); }

.view-toggle { display: flex; border: 1.5px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--card-bg); }
.view-btn {
  background: none; border: none; padding: 10px 16px; cursor: pointer;
  color: var(--ink); opacity: 0.6; transition: background 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.view-btn.active { background: var(--ink); color: var(--accent-light); opacity: 1; }

.shuffle-btn {
  background: var(--ink); color: var(--accent-light); border: none;
  padding: 10px 20px; border-radius: 6px;
  font-family: 'DM Mono', monospace; font-size: 0.75rem;
  letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex; align-items: center; gap: 8px;
}
.shuffle-btn:hover { background: rgba(15, 23, 66, 0.9); transform: translateY(-1px); }
.shuffle-btn:active { transform: translateY(0); }

.result-info {
  max-width: 1100px; margin: 0 auto 16px; padding: 0 24px;
  font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--ink); opacity: 0.6; letter-spacing: 0.08em;
}

/* ── GRID ── */
.vocab-grid {
  max-width: 1100px; margin: 0 auto; padding: 0 24px 60px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px;
}
.vocab-grid.hidden { display: none; }

.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 20px; box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative; overflow: hidden;
  animation: fadeUp 0.4s ease both;
}
.card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--primary); transform: scaleY(0); transition: transform 0.2s; transform-origin: bottom;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.card:hover::before { transform: scaleY(1); }
.card-index { position: absolute; top: 12px; right: 14px; font-family: 'DM Mono', monospace; font-size: 0.65rem; color: var(--border); }
.card-kanji { font-size: 1.3rem; font-weight: 900; color: var(--ink); line-height: 1.2; margin-bottom: 4px; padding-right: 36px; }
.card-reading { font-family: 'DM Mono', monospace; font-size: 0.78rem; color: var(--primary); margin-bottom: 10px; }
.divider { height: 1px; background: var(--bg-subtle); margin: 10px 0; }
.card-english { font-size: 0.88rem; color: var(--ink); font-weight: 600; margin-bottom: 6px; }
.card-burmese { font-family: 'Noto Sans Myanmar', sans-serif; font-size: 0.82rem; color: var(--ink); opacity: 0.75; line-height: 1.6; font-weight: 400; }

.card:nth-child(1){animation-delay:.02s}.card:nth-child(2){animation-delay:.05s}
.card:nth-child(3){animation-delay:.08s}.card:nth-child(4){animation-delay:.11s}
.card:nth-child(5){animation-delay:.14s}.card:nth-child(6){animation-delay:.17s}
.card:nth-child(7){animation-delay:.20s}.card:nth-child(8){animation-delay:.23s}
.card:nth-child(9){animation-delay:.26s}.card:nth-child(10){animation-delay:.29s}

/* ── LIST ── */
.vocab-list { max-width: 1100px; margin: 0 auto; padding: 0 24px 60px; display: flex; flex-direction: column; }
.vocab-list.hidden { display: none; }
.list-row {
  background: var(--card-bg); border: 1px solid var(--border); border-bottom: none;
  display: grid; grid-template-columns: 36px 1fr 1fr 1fr;
  align-items: center; transition: background 0.15s; animation: fadeUp 0.3s ease both;
}
.list-row:first-child { border-radius: 8px 8px 0 0; }
.list-row:last-child  { border-bottom: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.list-row:only-child  { border-radius: 8px; border-bottom: 1px solid var(--border); }
.list-row:hover       { background: var(--bg-subtle); }
.list-header { background: var(--ink) !important; color: var(--accent-light); font-family: 'DM Mono', monospace; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; border-color: var(--ink) !important; }
.list-cell { padding: 13px 16px; border-right: 1px solid var(--bg-subtle); }
.list-cell:last-child { border-right: none; }
.list-num  { font-family: 'DM Mono', monospace; font-size: 0.65rem; color: var(--border); text-align: center; }
.list-kanji { font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.list-reading { font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--primary); display: block; margin-top: 2px; }
.list-english { font-size: 0.82rem; color: var(--ink); font-weight: 500; }
.list-burmese { font-family: 'Noto Sans Myanmar', sans-serif; font-size: 0.78rem; color: var(--ink); opacity: 0.75; line-height: 1.5; font-weight: 400; }

/* ── FLASHCARD ── */
.flashcard-wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px 60px; display: none; }
.flashcard-wrap.active { display: block; }
.fc-progress-bar { height: 4px; background: var(--bg-subtle); border-radius: 2px; margin-bottom: 28px; overflow: hidden; }
.fc-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 2px; transition: width 0.4s ease; }
.fc-counter { font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--ink); opacity: 0.6; text-align: center; margin-bottom: 16px; letter-spacing: 0.1em; }
.fc-stage { perspective: 1200px; margin: 0 auto; max-width: 560px; height: 280px; }
.fc-card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.4,0,0.2,1); cursor: pointer; }
.fc-card.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.fc-front { background: var(--ink); border: 2px solid var(--accent); box-shadow: var(--shadow-md); }
.fc-back  { background: var(--card-bg); border: 2px solid var(--primary); box-shadow: var(--shadow-md); transform: rotateY(180deg); }
.fc-hint  { font-family: 'DM Mono', monospace; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 16px; }
.fc-front .fc-hint { color: var(--accent-light); opacity: 0.8; }
.fc-back  .fc-hint { color: var(--primary); }
.fc-word  { font-size: 1.8rem; font-weight: 900; line-height: 1.2; }
.fc-front .fc-word { color: var(--accent-light); }
.fc-back  .fc-word { color: var(--ink); }
.fc-reading-fc { font-family: 'DM Mono', monospace; font-size: 0.8rem; margin-top: 8px; color: var(--primary); }
.fc-english    { font-size: 1rem; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.fc-burmese-fc { font-family: 'Noto Sans Myanmar', sans-serif; font-size: 0.85rem; color: var(--ink); opacity: 0.75; line-height: 1.6; font-weight: 400; }
.fc-nav { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 24px; }
.fc-btn {
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 6px;
  padding: 10px 28px; font-family: 'DM Mono', monospace; font-size: 0.72rem;
  letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; color: var(--ink);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.fc-btn:hover { background: var(--bg-subtle); border-color: var(--primary); transform: translateY(-1px); }
.fc-btn.primary { background: var(--ink); color: var(--accent-light); border-color: var(--ink); }
.fc-btn.primary:hover { background: rgba(15, 23, 66, 0.9); }
.fc-tap-hint { text-align: center; font-family: 'DM Mono', monospace; font-size: 0.65rem; color: var(--border); letter-spacing: 0.1em; margin-top: 12px; }

/* ── MISC ── */
.loading-state, .error-state { text-align: center; padding: 80px 24px; color: var(--ink); opacity: 0.6; font-size: 0.9rem; }
.loading-spinner { width: 36px; height: 36px; border: 3px solid var(--bg-subtle); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 16px; }
.empty-state { text-align: center; padding: 60px 24px; color: var(--ink); opacity: 0.6; grid-column: 1/-1; }
.empty-state .em-icon { font-size: 2.5rem; margin-bottom: 12px; }

footer { background: var(--ink); color: var(--border); opacity: 0.8; text-align: center; padding: 20px; font-family: 'DM Mono', monospace; font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; }
footer a { color: var(--accent-light); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@keyframes fadeUp { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
@keyframes spin   { to { transform:rotate(360deg); } }

@media (max-width: 700px) {
  .hero { padding: 28px 16px 20px; }
  .hero-right { align-items: flex-start; }
  .unit-select { min-width: 0; width: 100%; }
  .controls,.mode-tabs,.vocab-grid,.vocab-list,.flashcard-wrap,.result-info { padding-left:16px; padding-right:16px; }
  .vocab-grid { grid-template-columns: 1fr; }
  .list-row { grid-template-columns: 28px 1fr 1fr; }
  .list-cell:nth-child(4) { display: none; }
}
