/* ==========================================================================
   My Japan Traveler — Learn
   Design system per ui-ux-pro-max: Claymorphism + Vibrant block-based.
   Learning indigo #4F46E5 + progress green #16A34A, chunky rounded cards,
   double shadows, soft-bounce micro-interactions.
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-deep: #4338ca;
  --secondary: #818cf8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #f59e0b;
  --bg: #eef2ff;
  --fg: #312e81;
  --card: #ffffff;
  --muted: #64748b;
  --border: #c7d2fe;
  --sans: 'Noto Sans JP', system-ui, sans-serif;
  --serif: 'Noto Serif JP', serif;
  --r: 20px;
  --clay: 0 8px 24px rgba(79, 70, 229, 0.16), inset 0 -3px 0 rgba(49, 46, 129, 0.08);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: var(--sans); background: var(--bg); color: var(--fg); line-height: 1.55; -webkit-font-smoothing: antialiased; }
button { font-family: var(--sans); cursor: pointer; }
.jp { font-family: var(--serif); }

.app { max-width: 560px; margin: 0 auto; padding: 1.2rem 1.2rem 5rem; min-height: 100vh; }
@media (min-width: 900px) { .app { max-width: 680px; } }

/* boot splash */
.boot { display: grid; place-items: center; min-height: 70vh; gap: 1rem; color: var(--muted); }
.boot__kanji { font: 700 4rem var(--serif); color: var(--primary); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); opacity: 0.75; } }

/* ---------- shared ---------- */
.screen { animation: slide-in .35s var(--bounce); }
@keyframes slide-in { from { opacity: 0; transform: translateY(16px); } }

.brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.6rem; }
.brand__logo { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; background: var(--primary); color: #fff; border-radius: 12px; font: 700 1.2rem var(--serif); box-shadow: var(--clay); }
.brand strong { font-size: 1.05rem; }
.brand .sub { font-size: .78rem; color: var(--muted); display: block; }
.brand__spacer { flex: 1; }

.card { background: var(--card); border-radius: var(--r); padding: 1.6rem; box-shadow: var(--clay); border: 3px solid #fff; }
h1.title { font: 700 1.7rem/1.25 var(--sans); margin-bottom: .4rem; }
p.lede { color: var(--muted); font-size: .95rem; margin-bottom: 1.4rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; padding: 1rem 1.4rem; border: none; border-radius: 16px;
  font: 700 1rem var(--sans); transition: transform .18s var(--bounce), box-shadow .18s ease, filter .15s ease;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 6px 0 var(--primary-deep), 0 12px 24px rgba(79,70,229,.3); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--primary:disabled { opacity: .5; box-shadow: none; cursor: not-allowed; }
.btn--green { background: var(--green); color: #fff; box-shadow: 0 6px 0 #15803d, 0 12px 24px rgba(22,163,74,.3); }
.btn--ghost { background: transparent; color: var(--primary); border: 2.5px solid var(--border); }
.btn--ghost:hover { border-color: var(--primary); }
.btn--small { width: auto; padding: .55rem 1rem; font-size: .85rem; border-radius: 12px; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 700; margin-bottom: .35rem; }
.field input, .field select {
  width: 100%; padding: .85rem 1rem; border: 2.5px solid var(--border); border-radius: 14px;
  font: 500 1rem var(--sans); color: var(--fg); background: #fff; transition: border-color .15s ease;
}
.field input:focus { outline: none; border-color: var(--primary); }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: .25rem; }
.form-error { background: #fef2f2; color: var(--red); border: 2px solid #fecaca; border-radius: 12px; padding: .7rem 1rem; font-size: .88rem; margin-bottom: 1rem; display: none; }
.form-error.show { display: block; }
.auth-alt { text-align: center; margin-top: 1.2rem; font-size: .9rem; color: var(--muted); }
.auth-alt a { color: var(--primary); font-weight: 700; text-decoration: none; }

/* ---------- onboarding: tracks ---------- */
.choices { display: grid; gap: .8rem; margin: 1.2rem 0 1.6rem; }
.choice {
  display: flex; align-items: center; gap: .9rem; text-align: left;
  background: var(--card); border: 3px solid var(--border); border-radius: 18px;
  padding: 1rem 1.1rem; transition: transform .18s var(--bounce), border-color .15s, box-shadow .15s;
}
.choice:hover { transform: translateY(-2px); }
.choice.on { border-color: var(--primary); box-shadow: 0 6px 18px rgba(79,70,229,.25); background: #f5f3ff; }
.choice__badge { flex: 0 0 3rem; height: 3rem; display: grid; place-items: center; border-radius: 12px; color: #fff; font: 700 .95rem var(--sans); }
.choice strong { display: block; font-size: .98rem; }
.choice .sub { font-size: .78rem; color: var(--muted); }
.choice__check { margin-left: auto; font-size: 1.2rem; opacity: 0; transition: opacity .15s, transform .2s var(--bounce); transform: scale(.5); }
.choice.on .choice__check { opacity: 1; transform: scale(1); }

/* ---------- onboarding: pixel-art japan map ---------- */
.map-wrap { background: linear-gradient(170deg, #dbeafe, #e0e7ff); border-radius: var(--r); padding: 1rem; border: 3px solid #fff; box-shadow: var(--clay); }
.pixmap { display: grid; grid-template-columns: repeat(18, 1fr); gap: 3px; aspect-ratio: 18 / 20; }
.cell { display: block; border: none; padding: 0; border-radius: 4px; }
.cell.sea { background: transparent; }
.cell.land { background: #a5b4fc; }
.cell.city {
  background: var(--primary); cursor: pointer; position: relative;
  box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(79,70,229,.45);
  transition: transform .15s var(--bounce), background .12s;
  z-index: 1;
}
.cell.city:hover { transform: scale(1.35); }
.cell.city:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.cell.city.on { background: var(--red); box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(220,38,38,.55); transform: scale(1.25); }
.cell.city.on::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: .6rem; font-weight: 900; }
.city-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.4rem; }
.chip {
  border: 2.5px solid var(--border); background: #fff; border-radius: 999px;
  padding: .45rem .95rem; font: 600 .85rem var(--sans); color: var(--fg);
  transition: all .15s var(--bounce);
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(1.05); }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-bottom: 1.4rem; }
.stat { background: var(--card); border-radius: 16px; padding: .9rem; text-align: center; box-shadow: var(--clay); border: 3px solid #fff; }
.stat__num { font: 900 1.5rem var(--sans); color: var(--primary); }
.stat__num.fire { color: var(--amber); }
.stat__num.green { color: var(--green); }
.stat__label { font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.tracks { display: grid; gap: 1rem; }
.track { background: var(--card); border-radius: var(--r); padding: 1.2rem 1.3rem; box-shadow: var(--clay); border: 3px solid #fff; }
.track__head { display: flex; align-items: center; gap: .9rem; margin-bottom: .8rem; }
.track__badge { flex: 0 0 3rem; height: 3rem; display: grid; place-items: center; border-radius: 14px; color: #fff; font: 700 .95rem var(--sans); }
.track__head strong { font-size: 1.02rem; display: block; }
.track__head .sub { font-size: .76rem; color: var(--muted); }
.progressbar { height: 12px; background: #e0e7ff; border-radius: 999px; overflow: hidden; margin-bottom: .9rem; }
.progressbar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--secondary), var(--primary)); transition: width .6s var(--bounce); }
.track__meta { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: .9rem; }
.track__cta { display: flex; gap: .6rem; }
.lock-note { font-size: .78rem; color: var(--amber); font-weight: 600; }

/* ---------- session player ---------- */
.session-top { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.2rem; }
.session-top .progressbar { flex: 1; margin: 0; }
.quit { background: none; border: none; font-size: 1.3rem; color: var(--muted); }
.combo { font: 900 .9rem var(--sans); color: var(--amber); min-width: 3.2rem; text-align: right; }

.qcard { text-align: center; padding: 2rem 1.4rem; }
.qcard__emoji { font-size: 2.6rem; margin-bottom: .4rem; }
.qcard__jp { font: 700 clamp(2rem, 8vw, 2.8rem)/1.3 var(--serif); margin-bottom: .3rem; }
.qcard__kana { color: var(--muted); font-size: 1rem; margin-bottom: .2rem; }
.qcard__prompt { font-size: .85rem; color: var(--muted); margin-bottom: 1.2rem; }
.audio-btn {
  background: #eef2ff; border: 2.5px solid var(--border); border-radius: 999px;
  width: 2.8rem; height: 2.8rem; font-size: 1.2rem; margin-bottom: 1rem;
  transition: transform .18s var(--bounce);
}
.audio-btn:hover { transform: scale(1.12); }

.answers { display: grid; gap: .7rem; margin-top: 1rem; }
.answer {
  background: #fff; border: 3px solid var(--border); border-radius: 16px;
  padding: .95rem 1.1rem; font: 600 .98rem var(--sans); color: var(--fg); text-align: left;
  transition: transform .15s var(--bounce), border-color .12s, background .12s;
}
.answer:hover { transform: translateY(-2px); border-color: var(--secondary); }
.answer.correct { background: #f0fdf4; border-color: var(--green); color: var(--green); animation: pop .35s var(--bounce); }
.answer.wrong { background: #fef2f2; border-color: var(--red); color: var(--red); animation: shake .35s ease; }
.answer:disabled { cursor: default; }
@keyframes pop { 50% { transform: scale(1.05); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback { margin-top: 1rem; border-radius: 14px; padding: .9rem 1.1rem; font-size: .88rem; display: none; text-align: left; }
.feedback.show { display: block; animation: slide-in .3s var(--bounce); }
.feedback.good { background: #f0fdf4; color: #166534; }
.feedback.bad { background: #fef2f2; color: #991b1b; }
.feedback .jp { font-size: 1rem; }

/* flashcard intro mode */
.flash { perspective: 900px; cursor: pointer; }
.flash__inner { transition: transform .5s var(--bounce); transform-style: preserve-3d; position: relative; }
.flash.flipped .flash__inner { transform: rotateY(180deg); }
/* backface-visibility MUST be on BOTH faces — with it only on the front, the
   back face's mirror image bled through (QA screenshot 04a, 2026-06-10). */
.flash__face, .flash__back { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flash__back { position: absolute; inset: 0; transform: rotateY(180deg); display: grid; place-content: center; gap: .4rem; padding: 1rem; }

/* session summary */
.summary { text-align: center; padding: 2.2rem 1.6rem; }
.summary__big { font-size: 3.4rem; animation: pop .6s var(--bounce); }
.summary h2 { font-size: 1.5rem; margin: .6rem 0; }
.summary__stats { display: flex; justify-content: center; gap: 1.6rem; margin: 1.2rem 0 1.6rem; }
.summary__stats div { text-align: center; }
.summary__stats .n { font: 900 1.6rem var(--sans); color: var(--primary); }
.summary__stats .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti span { position: absolute; top: -3vh; width: 10px; height: 14px; border-radius: 3px; animation: drop linear forwards; }
@keyframes drop { to { transform: translateY(110vh) rotate(720deg); } }

/* upgrade banner */
.upgrade { background: linear-gradient(135deg, #fef3c7, #fde68a); border: 3px solid #fcd34d; border-radius: var(--r); padding: 1.1rem 1.3rem; margin-bottom: 1.2rem; }
.upgrade strong { display: block; margin-bottom: .2rem; }
.upgrade p { font-size: .85rem; color: #92400e; }

/* toast */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(150%);
  background: var(--fg); color: #fff; border-radius: 14px; padding: .8rem 1.3rem;
  font: 600 .9rem var(--sans); transition: transform .3s var(--bounce); z-index: 70; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* nav footer */
.bottnav {
  position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px); border-top: 2px solid var(--border); display: flex; justify-content: center; gap: 3rem;
  padding: .6rem 0 calc(.6rem + env(safe-area-inset-bottom)); z-index: 50;
}
.bottnav button { background: none; border: none; font-size: .72rem; font-weight: 700; color: var(--muted); display: grid; place-items: center; gap: .15rem; }
.bottnav button .ic { font-size: 1.3rem; }
.bottnav button.on { color: var(--primary); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
