:root {
  --pumpkin: #ff7a1a;
  --pumpkin-dark: #e05d00;
  --wizard: #6b3fa0;
  --wizard-dark: #4b2775;
  --cream: #fff7ec;
  --ink: #2b1b3d;
  --muted: #7a6a8a;
  --good: #23a55a;
  --bad: #e5484d;
  --card: #ffffff;
  --radius: 22px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 0%, #ffe3c7 0%, var(--cream) 45%, #f1e6ff 100%) fixed;
  color: var(--ink);
}

body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

#app { max-width: 640px; margin: 0 auto; padding: 18px 18px 40px; }

.view { display: none; animation: pop 0.25s ease-out; }
.view.active { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 2rem; color: var(--wizard-dark); }
h2 { font-size: 1.4rem; color: var(--wizard-dark); }
h3 { font-size: 1.1rem; margin-bottom: 10px; }

.hero { text-align: center; margin: 30px 0 20px; }
.logo { font-size: 4rem; }
.hero-art { width: 100%; max-width: 340px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 24px; box-shadow: 0 8px 28px rgba(75, 39, 117, 0.25); }
.sub { color: var(--muted); font-size: 1.15rem; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: 1rem; }
.center-text { text-align: center; }
.error { color: var(--bad); text-align: center; min-height: 1.2em; font-weight: 600; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 44px; }
.topbar h1 { font-size: 1.6rem; flex: 1; }
.topbar h2 { flex: 1; }
.badges { display: flex; gap: 8px; }
.badge { background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 1.05rem; box-shadow: 0 2px 6px rgba(75, 39, 117, 0.12); }

button, .file-btn {
  font: inherit; border: none; cursor: pointer; border-radius: var(--radius);
  padding: 12px 18px; font-size: 1.05rem; font-weight: 700; color: var(--ink); background: #fff;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
button:active, .file-btn:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; }
.big { display: block; width: 100%; padding: 18px; font-size: 1.3rem; margin: 10px 0; text-align: center; }
.primary { background: linear-gradient(180deg, var(--pumpkin), var(--pumpkin-dark)); color: #fff; box-shadow: 0 6px 0 #b84a00; }
.secondary { background: linear-gradient(180deg, #8a5cc4, var(--wizard)); color: #fff; box-shadow: 0 6px 0 var(--wizard-dark); }
.ghost { background: #fff; box-shadow: 0 4px 0 #e2d6f0; }
.pill { background: #fff; border-radius: 999px; box-shadow: 0 3px 0 #e2d6f0; }
.back { background: transparent; color: var(--wizard); padding: 8px 4px; }
.link { background: none; color: var(--muted); display: block; margin: 30px auto 0; font-weight: 600; text-decoration: underline; }
.stack { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; margin: 14px 0; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 6px 18px rgba(75, 39, 117, 0.1); margin-bottom: 14px; }
.card .title { font-size: 1.3rem; font-weight: 800; color: var(--wizard-dark); }
.card .meta { color: var(--muted); margin-top: 4px; }

.week-progress { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.chip { background: #fff; border-radius: 14px; padding: 8px 12px; text-align: center; box-shadow: 0 2px 6px rgba(75, 39, 117, 0.1); }
.chip .d { font-size: 0.8rem; color: var(--muted); }
.chip .s { font-weight: 800; }

/* PIN */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 10px 0 20px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; background: #e2d6f0; }
.pin-dots span.on { background: var(--pumpkin); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 320px; margin: 0 auto; }
.pin-pad button { font-size: 1.8rem; padding: 18px 0; box-shadow: 0 5px 0 #e2d6f0; }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* Forms */
.field { display: block; font-weight: 700; margin-bottom: 14px; }
.field input, .field textarea, .add-row input, select {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 1.2rem; padding: 14px;
  border: 3px solid #e2d6f0; border-radius: 16px; background: #fff; color: var(--ink);
}
.add-row input { flex: 1; margin-top: 0; width: auto; }
select { flex: 1; width: auto; margin-top: 0; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--pumpkin); }

.word-list, .check-list, .result-list { list-style: none; padding: 0; margin: 0 0 14px; }
.word-list li { background: #fff; border-radius: 18px; padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(75, 39, 117, 0.08); }
.word-list .w { display: flex; align-items: center; gap: 8px; }
.word-list .w input { flex: 1; font: inherit; font-size: 1.25rem; font-weight: 800; border: none; padding: 4px 0; color: var(--wizard-dark); background: transparent; }
.word-list textarea { width: 100%; font: inherit; font-size: 1rem; border: 2px solid #f0e8f8; border-radius: 12px; padding: 8px 10px; margin-top: 6px; color: var(--ink); }
.status { font-size: 0.85rem; padding: 3px 8px; border-radius: 999px; background: #f0e8f8; color: var(--muted); white-space: nowrap; }
.status.ready { background: #dcf5e6; color: var(--good); }
.status.error { background: #fde2e2; color: var(--bad); }
.icon-btn { background: transparent; padding: 6px 8px; font-size: 1.2rem; }

/* Test */
.progress-bar { height: 12px; background: #fff; border-radius: 999px; overflow: hidden; margin-bottom: 20px; }
.progress-bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--pumpkin), #ffb347); transition: width 0.3s; }
.speaker {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  width: 230px; height: 230px; margin: 10px auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a77ad9, var(--wizard)); color: #fff; box-shadow: 0 10px 0 var(--wizard-dark);
}
.speaker-icon { font-size: 4.5rem; }
.speaker-label { font-size: 1rem; max-width: 170px; text-align: center; }
.speaker.playing { animation: pulse 0.9s infinite; }
@keyframes pulse { 50% { transform: scale(1.05); box-shadow: 0 10px 0 var(--wizard-dark), 0 0 0 16px rgba(107, 63, 160, 0.15); } }
.toggle { display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; margin: 6px 0; }
.toggle input { width: 24px; height: 24px; accent-color: var(--pumpkin); }

/* Checking */
.check-list li, .result-list li {
  display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 18px;
  padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(75, 39, 117, 0.08);
}
.num { width: 34px; height: 34px; flex: none; border-radius: 50%; background: #f0e8f8; display: grid; place-items: center; font-weight: 800; color: var(--wizard); }
.check-list .word, .result-list .word { flex: 1; font-size: 1.3rem; font-weight: 800; }
.yn { width: 52px; height: 52px; padding: 0; font-size: 1.5rem; border-radius: 50%; box-shadow: 0 3px 0 #e2d6f0; }
.yn.yes.on { background: var(--good); color: #fff; box-shadow: 0 3px 0 #17803f; }
.yn.no.on { background: var(--bad); color: #fff; box-shadow: 0 3px 0 #b3262b; }
.check-list input { flex: 1; font: inherit; font-size: 1.2rem; padding: 10px; border: 3px solid var(--pumpkin); border-radius: 12px; }
.check-list .read { flex: 1; font-size: 1.25rem; font-weight: 700; }
.check-list .ask { flex: 1; }
.check-list .ask small { display: block; color: var(--pumpkin-dark); font-weight: 700; margin-bottom: 4px; }

.photo-preview { width: 100%; border-radius: var(--radius); margin: 10px 0; box-shadow: 0 6px 18px rgba(75, 39, 117, 0.15); }
.loading { text-align: center; color: var(--wizard); font-weight: 700; }
.spinner { width: 54px; height: 54px; margin: 16px auto 4px; border-radius: 50%; border: 6px solid #e2d6f0; border-top-color: var(--pumpkin); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.stars { font-size: 3.6rem; letter-spacing: 6px; }
.stars span { display: inline-block; animation: starpop 0.5s backwards; }
.stars span:nth-child(2) { animation-delay: 0.2s; }
.stars span:nth-child(3) { animation-delay: 0.4s; }
.stars .dim { filter: grayscale(1); opacity: 0.3; }
@keyframes starpop { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }
.result-list .mark { font-size: 1.4rem; }
.result-list .yours { color: var(--bad); text-decoration: line-through; margin-right: 6px; font-weight: 600; }
.result-list li.right .word { color: var(--good); }

.parent-list { margin-bottom: 14px; }
.parent-list table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.parent-list td { padding: 6px 4px; border-top: 1px solid #f0e8f8; vertical-align: top; }
.parent-list .miss { color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 20; max-width: 90vw; text-align: center; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 10; width: 100vw; height: 100vh; }
