/* VocabUp — Tinder-style TOEIC vocabulary learning
   Follows native-real.com design system (DESIGN.md) */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.page-content { min-height: calc(100vh - 60px); }

/* ───── Landing: Hero ───── */
.vocab-hero {
  max-width: 640px;
  margin: 0 auto;
  padding: 60px 20px 40px;
  text-align: center;
}
.vocab-hero-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--gold-bg);
  color: var(--gold);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}
.vocab-hero h1 {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.25;
  color: var(--text-1);
  margin-bottom: 16px;
}
.vocab-hero h1 .accent { color: var(--gold); }
.vocab-hero-sub {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-2);
  margin-bottom: 32px;
  text-wrap: balance;
}

/* ───── Landing: CTAs ───── */
.vocab-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 14px 32px;
  background: linear-gradient(180deg, #E09520 0%, #F5A623 50%, #F8C347 100%);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t);
  box-shadow: 0 4px 14px rgba(245,166,35,0.35);
  font-family: inherit;
}
.vocab-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,166,35,0.45); }
.vocab-cta:active { transform: translateY(0); }

.vocab-ghost-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 14px 28px;
  background: transparent;
  color: var(--text-1);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

/* ───── Landing: Level select ───── */
.level-select {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px 40px;
}
.level-select-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.level-btn {
  padding: 16px 8px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  cursor: pointer;
  transition: all var(--t);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.level-btn:hover { border-color: var(--gold); }
.level-btn.active {
  border-color: var(--gold);
  background: var(--gold-bg);
  box-shadow: var(--gold) 0 -3px 0 0 inset;
}
.level-btn .lv-num { font-size: 20px; letter-spacing: -0.5px; }
.level-btn .lv-label { font-size: 11px; color: var(--text-2); font-weight: 600; }
.level-note {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  margin: -12px 0 20px;
  line-height: 1.6;
}
.level-note.beta {
  color: var(--gold);
  font-weight: 600;
}

/* ───── Landing: Feature cards ───── */
.feature-grid {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 20px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.feature-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  transition: all var(--t);
}
.feature-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.04); }
.feature-card .emoji { font-size: 28px; margin-bottom: 8px; display: block; }
.feature-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.3px; color: var(--text-1); }
.feature-card p { font-size: 13px; line-height: 1.7; color: var(--text-2); }

/* ═══════════════════════════════════════════
   SWIPE UI (app.html)
   ═══════════════════════════════════════════ */
body.vocab-app {
  background: var(--bg);
  overflow: hidden;
  touch-action: none;
}

.vocab-app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  position: relative;
}

/* Top bar */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px 14px;
  flex-shrink: 0;
}
.app-topbar .exit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: 36px;
}
.app-topbar .progress-wrap { flex: 1; }
.progress-bar {
  height: 6px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #F8C347);
  width: 0%;
  transition: width 0.35s ease;
}
.progress-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  margin-top: 4px;
  text-align: center;
}

/* Stats row (XP / Combo) */
.stats-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-1);
}
.stat-pill.xp { color: var(--xp); border-color: rgba(245,166,35,0.3); }
.stat-pill.combo { color: var(--streak); border-color: rgba(234,88,12,0.3); }
.stat-pill.combo.active { background: var(--streak-bg); }

/* Card stack */
.card-stack {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 6px 0;
}
.swipe-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 3 / 4;
  max-height: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 8px 32px rgba(26,26,26,0.08);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: grab;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  transform: translate(-50%, -50%);
  transition: box-shadow var(--t);
}
.swipe-card.dragging { cursor: grabbing; transition: none; }
.swipe-card.behind {
  transform: translate(-50%, -50%) scale(0.94);
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
}
.swipe-card.top { z-index: 2; }

.swipe-card .level-tag {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.06em;
}
.swipe-card .play-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold-bg);
  color: var(--gold);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t);
  font-family: inherit;
}
.swipe-card .play-btn:hover { background: var(--gold); color: #fff; transform: scale(1.05); }
.swipe-card .play-btn.playing { animation: pulse-gold 1.2s ease infinite; }
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,166,35,0.6); }
  50% { box-shadow: 0 0 0 12px rgba(245,166,35,0); }
}

.meaning-ja {
  font-size: clamp(26px, 6.5vw, 36px);
  font-weight: 800;
  line-height: 1.35;
  color: var(--text-1);
  letter-spacing: 0;
  max-width: 100%;
  text-wrap: balance;
  word-break: break-word;
}
.meaning-pos {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 600;
  margin-top: 14px;
  letter-spacing: 0.04em;
}

.audio-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Swipe indicators (overlay) */
.swipe-indicator {
  position: absolute;
  top: 24px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 0.1s ease;
  pointer-events: none;
  border: 2.5px solid currentColor;
}
.swipe-indicator.right {
  right: 24px;
  color: var(--success);
  transform: rotate(12deg);
}
.swipe-indicator.left {
  left: 24px;
  color: var(--error);
  transform: rotate(-12deg);
}
.swipe-indicator.up {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--hint);
}

/* Action buttons below the card */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 10px 0 4px;
  flex-shrink: 0;
}
.action-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t);
  font-family: inherit;
  color: var(--text-1);
}
.action-btn:hover { transform: translateY(-2px); }
.action-btn.no { color: var(--error); border-color: rgba(220,38,38,0.3); }
.action-btn.no:hover { background: var(--error-bg); }
.action-btn.skip { color: var(--hint); border-color: rgba(217,119,6,0.3); }
.action-btn.skip:hover { background: var(--hint-bg); }
.action-btn.yes { color: var(--success); border-color: rgba(22,163,74,0.3); }
.action-btn.yes:hover { background: var(--success-bg); }
.action-btn.yes.big, .action-btn.no.big { width: 68px; height: 68px; }
.action-labels {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 4px 0 8px;
  font-size: 10px;
  color: var(--text-3);
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.action-labels span {
  width: 56px;
  text-align: center;
}

/* Reveal panel (after answer) */
.reveal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.reveal-overlay.show { display: flex; }
.reveal-sheet {
  width: 100%;
  max-width: 520px;
  background: var(--bg-elevated);
  border-radius: 22px 22px 0 0;
  padding: 24px 22px 28px;
  animation: slideUp 0.28s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.reveal-verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
}
.reveal-verdict.correct { color: var(--success); }
.reveal-verdict.incorrect { color: var(--error); }
.reveal-verdict.skipped { color: var(--hint); }
.reveal-word {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.reveal-ipa {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 14px;
  font-family: "Times New Roman", serif;
}
.reveal-meaning {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 12px;
  line-height: 1.6;
}
.reveal-example {
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.reveal-example .en { font-size: 15px; line-height: 1.7; color: var(--text-1); margin-bottom: 6px; font-weight: 600; }
.reveal-example .ja { font-size: 13px; color: var(--text-2); line-height: 1.7; }
.reveal-played {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
  line-height: 1.6;
}
.reveal-played.match { border-left-color: var(--success); }
.reveal-played.mismatch {
  border-left-color: var(--gold);
  background: var(--gold-bg);
  color: var(--text-2);
}
.reveal-played b { color: var(--text-1); font-weight: 700; }
.reveal-played .played-label { font-weight: 700; color: var(--text-2); }
.reveal-played .played-sep { color: var(--text-3); font-weight: 700; padding: 0 2px; }
.reveal-played .played-note { color: var(--text-2); }

.reveal-next-review {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  margin: -4px 0 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.reveal-next {
  width: 100%;
  min-height: 52px;
  background: linear-gradient(180deg, #E09520 0%, #F5A623 50%, #F8C347 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ───── Level-up toast ───── */
.level-up-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: linear-gradient(135deg, #F8C347, #F5A623);
  color: #fff;
  padding: 20px 36px;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 12px 40px rgba(245,166,35,0.5);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 30;
  text-align: center;
}
.level-up-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ───── Adaptive difficulty toast ───── */
.adaptive-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(26,26,26,0.82);
  color: #fff;
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
}
.adaptive-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ───── Session complete screen ───── */
.complete-screen {
  display: none;
  flex-direction: column;
  padding: 40px 20px;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
}
.complete-screen.show { display: flex; }
.complete-icon {
  font-size: 56px;
  margin-bottom: 12px;
}
.complete-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}
.complete-sub {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 26px;
}
.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
}
.score-cell {
  padding: 16px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.score-cell .v { font-size: 24px; font-weight: 800; color: var(--gold); letter-spacing: -0.5px; }
.score-cell .l { font-size: 11px; color: var(--text-2); font-weight: 600; margin-top: 4px; }

.cta-recommendation {
  padding: 22px 20px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius);
  margin-bottom: 20px;
  text-align: left;
}
.cta-recommendation .label {
  font-size: 11px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.cta-recommendation .name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}
.cta-recommendation .desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 14px;
}
.cta-recommendation .link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--gold);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.cta-recommendation .note {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 10px;
}

.complete-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.complete-actions .btn {
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  border: none;
  min-height: 44px;
}
.complete-actions .btn.primary {
  background: linear-gradient(180deg, #E09520, #F5A623);
  color: #fff;
}
.complete-actions .btn.ghost {
  background: transparent;
  border: 1.5px solid var(--border-strong);
  color: var(--text-1);
}

/* ───── Loading / Error / Onboarding ───── */
.loading-screen,
.error-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg);
  z-index: 35;
  text-align: center;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: vu-spin 0.9s linear infinite;
}
@keyframes vu-spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-2); font-size: 14px; font-weight: 600; }

.error-icon { font-size: 40px; }
.error-text {
  max-width: 360px;
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.7;
  font-weight: 600;
}
.error-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.error-actions .btn {
  padding: 12px 22px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
}
.error-actions .btn.primary {
  background: linear-gradient(180deg, #E09520, #F5A623);
  color: #fff;
}
.error-actions .btn.ghost {
  background: transparent;
  border: 1.5px solid var(--border-strong);
  color: var(--text-1);
}

.onboarding-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26,26,26,0.45);
  backdrop-filter: blur(4px);
  z-index: 45;
}
.onboarding-card {
  max-width: 360px;
  width: 100%;
  padding: 28px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  box-shadow: 0 18px 48px rgba(26,26,26,0.14);
}
.onboarding-card h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin-bottom: 10px;
}
.onboarding-lead {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 16px;
}
.onboarding-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.onboarding-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-1);
}
.onboarding-list .key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gold-bg);
  color: var(--gold);
  font-weight: 800;
  font-size: 16px;
}
.onboarding-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 18px;
  line-height: 1.6;
}
.onboarding-card .btn.primary {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  background: linear-gradient(180deg, #E09520, #F5A623);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* Audio playback feedback */
.swipe-card .play-btn.audio-error {
  outline: 2px solid var(--error);
  outline-offset: 2px;
}

/* Keyboard focus rings (show only on keyboard nav) */
.action-btn:focus-visible,
.exit-btn:focus-visible,
.reveal-next:focus-visible,
.onboarding-card .btn:focus-visible,
.error-actions .btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ───── Confetti ───── */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 14px;
  top: -20px;
  animation: confetti-fall 1.4s linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.3; }
}

/* ───── Small screens ───── */
@media (max-height: 700px) {
  .vocab-app-root { padding: 6px 14px 14px; }
  .app-topbar { padding: 4px 0 8px; }
  .meaning-ja { font-size: clamp(22px, 5.5vw, 30px); }
  .action-btn { width: 50px; height: 50px; }
  .action-btn.yes.big, .action-btn.no.big { width: 58px; height: 58px; }
  .action-labels span { width: 50px; }
  .action-bar { gap: 10px; }
}

@media (max-width: 420px) {
  .vocab-hero h1 { font-size: 28px; }
  .vocab-hero { padding: 40px 16px 30px; }
  .meaning-ja { font-size: 26px; }
}
