:root {
  --ink: #14183a;
  --ink-2: #4a5078;
  --ink-3: #8a90b4;
  --bg: #f3f5fc;
  --card: #ffffff;
  --line: #e3e7f5;
  --blue: #3d6bff;
  --blue-2: #6a8cff;
  --orange: #ff8a3d;
  --green: #1fbf88;
  --purple: #8a5cf6;
  --red: #f0506e;
  --shadow: 0 10px 30px rgba(34, 44, 110, .10), 0 2px 6px rgba(34, 44, 110, .06);
  --shadow-s: 0 4px 14px rgba(34, 44, 110, .08);
  --r: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; font-family: inherit; }
button { font-family: inherit; cursor: pointer; border: 0; color: inherit; }
#app { min-height: 100%; max-width: 560px; margin: 0 auto; position: relative; }
.boot { display: grid; place-items: center; height: 100vh; font-weight: 800; font-size: 28px; color: var(--blue); letter-spacing: .02em; }

/* ---------- 共通 ---------- */
.screen { padding: calc(var(--safe-t) + 16px) 18px calc(var(--safe-b) + 28px); min-height: 100vh; }
.screen.has-tabs { padding-bottom: calc(var(--safe-b) + 96px); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.brand { font-weight: 900; font-size: 22px; letter-spacing: .01em; }
.brand b { color: var(--blue); }
.chips { display: flex; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border-radius: 999px; padding: 8px 13px; font-weight: 800; font-size: 14px; box-shadow: var(--shadow-s); }
.icon-btn { width: 40px; height: 40px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-s); display: grid; place-items: center; font-size: 19px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.h2 { font-size: 18px; font-weight: 900; margin: 22px 2px 10px; }
.muted { color: var(--ink-3); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.btn { min-height: 52px; padding: 0 22px; border-radius: 16px; font-size: 17px; font-weight: 800; background: var(--blue); color: #fff; box-shadow: 0 8px 18px rgba(61, 107, 255, .28); transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn.sec { background: var(--card); color: var(--ink); box-shadow: var(--shadow-s); }
.btn.green { background: var(--green); box-shadow: 0 8px 18px rgba(31, 191, 136, .3); }
.btn.red { background: var(--red); box-shadow: 0 8px 18px rgba(240, 80, 110, .3); }
.btn.orange { background: var(--orange); box-shadow: 0 8px 18px rgba(255, 138, 61, .3); }
.btn.full { width: 100%; }
.btn.small { min-height: 40px; font-size: 14px; padding: 0 14px; border-radius: 12px; box-shadow: var(--shadow-s); }
.btn[disabled] { opacity: .45; box-shadow: none; pointer-events: none; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.input { width: 100%; min-height: 50px; border-radius: 14px; border: 2px solid var(--line); background: #fff; padding: 0 14px; font-size: 17px; color: var(--ink); outline: none; }
.input:focus { border-color: var(--blue-2); }
.input.sm { min-height: 42px; font-size: 15px; border-radius: 11px; }
textarea.input { padding: 10px 14px; min-height: 70px; }
.seg { display: flex; background: #e6eafb; border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 42px; border-radius: 11px; background: transparent; font-weight: 800; font-size: 15px; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--blue); box-shadow: var(--shadow-s); }
.alert { border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 600; line-height: 1.55; background: #fff4e8; color: #8a4a12; }
.alert.err { background: #ffeef1; color: #a02a45; }
.alert.ok { background: #e6faf3; color: #146e50; }
#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translate(-50%, -16px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 700; max-width: 88vw; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; text-align: center; line-height: 1.5; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- ログイン ---------- */
.auth { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; padding: 24px 22px; }
.auth .logo { font-size: 40px; font-weight: 900; letter-spacing: -.01em; margin-bottom: 4px; }
.auth .logo b { color: var(--blue); }
.auth .sub { color: var(--ink-2); margin-bottom: 26px; font-weight: 600; }

/* ---------- 子供ホーム ---------- */
.hero { border-radius: 28px; padding: 22px 22px 20px; color: #fff; background: linear-gradient(135deg, #3d6bff 0%, #7a5cf6 100%); box-shadow: 0 18px 38px rgba(80, 90, 240, .35); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -50px; width: 190px; height: 190px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.hero .eyebrow { font-size: 13px; font-weight: 800; letter-spacing: .08em; opacity: .85; }
.hero .big { font-size: 34px; font-weight: 900; margin: 4px 0 2px; }
.hero .count { font-size: 15px; font-weight: 700; opacity: .92; margin-bottom: 18px; }
.hero .btn { background: #fff; color: var(--blue); box-shadow: 0 10px 22px rgba(20, 24, 58, .25); width: 100%; font-size: 19px; min-height: 58px; position: relative; z-index: 1; }
.progress { height: 12px; background: #e3e7f7; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--green), #6be3b6); transition: width .35s; }
.goalrow { display: flex; justify-content: space-between; font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mode { background: var(--card); border-radius: 16px; padding: 10px 4px; text-align: center; font-weight: 800; font-size: 13px; box-shadow: var(--shadow-s); border: 2px solid transparent; line-height: 1.35; }
.mode small { display: block; font-size: 11px; color: var(--ink-3); font-weight: 700; }
.mode.on { border-color: var(--blue); color: var(--blue); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { border-radius: 20px; padding: 16px; text-align: left; background: var(--card); box-shadow: var(--shadow-s); position: relative; min-height: 104px; display: flex; flex-direction: column; justify-content: space-between; }
.tile .t { font-weight: 900; font-size: 16px; }
.tile .n { font-size: 13px; color: var(--ink-3); font-weight: 700; }
.tile .dot { position: absolute; right: 14px; top: 14px; width: 12px; height: 12px; border-radius: 50%; }
.tile[disabled] { opacity: .5; }
.tile .big { font-size: 26px; font-weight: 900; }

/* ---------- フラッシュカード ---------- */
.study { display: flex; flex-direction: column; min-height: 100vh; padding: calc(var(--safe-t) + 12px) 18px calc(var(--safe-b) + 18px); }
.study .bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.study .bar .progress { flex: 1; }
.study .meta { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 12px; font-size: 13px; font-weight: 800; color: var(--ink-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border-radius: 99px; padding: 7px 12px; font-weight: 800; font-size: 13px; box-shadow: var(--shadow-s); }
.pill.on { color: var(--blue); }
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; perspective: 1400px; min-height: 340px; }
.flip { position: relative; width: 100%; height: min(56vh, 460px); min-height: 320px; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, .8, .3, 1); touch-action: pan-y; }
.flip.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px; text-align: center; overflow: hidden; }
.face.front { background: #fff; }
.face.back { background: linear-gradient(160deg, #ffffff 0%, #eef1ff 100%); transform: rotateY(180deg); }
.face .tag { position: absolute; top: 18px; left: 20px; font-size: 12px; font-weight: 900; letter-spacing: .06em; color: var(--blue); background: #e9eeff; padding: 5px 10px; border-radius: 99px; }
.face .tag.o { color: #b85a14; background: #fff0e2; }
.word { font-size: clamp(40px, 13vw, 62px); font-weight: 900; line-height: 1.12; word-break: break-word; letter-spacing: -.01em; }
.word.ja { font-size: clamp(32px, 9.5vw, 46px); line-height: 1.3; }
.word.sm { font-size: 22px; color: var(--ink-3); font-weight: 800; }
.ipa { margin-top: 10px; font-size: 20px; color: var(--purple); font-weight: 700; font-family: "SF Pro Text", "Segoe UI", "Noto Sans", sans-serif; }
.pos { margin-top: 8px; font-size: 14px; font-weight: 800; color: var(--ink-3); }
.spell { margin-top: 12px; font-size: 22px; font-weight: 800; letter-spacing: .22em; color: var(--orange); }
.ex { margin-top: 16px; font-size: 15px; color: var(--ink-2); line-height: 1.6; font-weight: 600; max-width: 94%; }
.ex em { font-style: normal; color: var(--ink-3); display: block; font-size: 13px; }
.spk { width: 62px; height: 62px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 22px rgba(61, 107, 255, .35); margin-top: 18px; }
.spk.sm { width: 38px; height: 38px; margin: 0 0 0 8px; box-shadow: none; display: inline-grid; vertical-align: middle; }
.spk.big { width: 120px; height: 120px; }
.spk svg { width: 55%; height: 55%; }
.hint { text-align: center; font-size: 13px; color: var(--ink-3); font-weight: 700; margin-top: 12px; height: 18px; }
.answer { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; min-height: 66px; }
.answer .btn { min-height: 66px; font-size: 19px; }
.reveal { margin-top: 14px; }
.reveal .btn { width: 100%; min-height: 66px; font-size: 19px; }

/* ---------- 結果 ---------- */
.result { text-align: center; position: relative; }
.ring { width: 190px; height: 190px; border-radius: 50%; margin: 18px auto; display: grid; place-items: center; background: conic-gradient(var(--green) calc(var(--p) * 1%), #e3e7f7 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 16px; background: var(--bg); border-radius: 50%; }
.ring b { position: relative; font-size: 44px; font-weight: 900; }
.ring small { position: relative; display: block; font-size: 12px; color: var(--ink-3); font-weight: 800; }
.stars { font-size: 42px; letter-spacing: 6px; animation: pop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(0) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 18px; }
.stat { background: var(--card); border-radius: 18px; padding: 14px 6px; box-shadow: var(--shadow-s); }
.stat b { display: block; font-size: 24px; font-weight: 900; }
.stat span { font-size: 12px; color: var(--ink-3); font-weight: 800; }
.missed { text-align: left; }
.missed .item { display: flex; justify-content: space-between; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); font-weight: 700; }
.missed .item:last-child { border: 0; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; opacity: .95; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- 保護者 ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 6px calc(var(--safe-b) + 6px); z-index: 20; }
.tabs button { background: none; padding: 8px 0; font-size: 12px; font-weight: 800; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--blue); }
.drop { border: 2px dashed #b9c4f5; border-radius: 22px; padding: 26px 16px; text-align: center; background: #f8faff; }
.drop b { font-size: 17px; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; }
.thumbs img { height: 120px; border-radius: 12px; box-shadow: var(--shadow-s); }
.irow { display: flex; gap: 10px; background: var(--card); border-radius: 18px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow-s); border: 2px solid transparent; }
.irow.unc { border-color: #ffc89a; background: #fffaf4; }
.irow.dup { border-color: #cfd6f3; background: #f6f7fc; }
.irow .chk { padding-top: 8px; }
.irow .chk input { width: 26px; height: 26px; accent-color: var(--blue); }
.irow .fields { flex: 1; min-width: 0; display: grid; gap: 8px; }
.irow .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note { font-size: 13px; font-weight: 700; color: #b05a14; line-height: 1.5; }
.note.dup { color: var(--ink-3); }
.note button { background: #ffe4cc; color: #8a4a12; border-radius: 8px; padding: 4px 9px; font-weight: 800; font-size: 13px; margin-left: 4px; }
.regbar { position: sticky; bottom: calc(var(--safe-b) + 76px); padding: 18px 0 8px; background: linear-gradient(to top, var(--bg) 62%, rgba(243, 245, 252, 0)); z-index: 5; }
.wgroup { margin-bottom: 6px; }
.wgroup h4 { margin: 18px 4px 8px; font-size: 14px; color: var(--ink-2); display: flex; justify-content: space-between; }
.wrow { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 16px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow-s); }
.wrow .w { flex: 1; min-width: 0; }
.wrow .w b { display: block; font-size: 17px; }
.wrow .w span { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.wrow .mini { width: 38px; height: 38px; border-radius: 12px; background: #eef1ff; color: var(--blue); display: grid; place-items: center; font-size: 16px; font-weight: 800; }
.wrow .mini svg { width: 18px; height: 18px; }
.wrow .mini.del { background: #ffeef1; color: var(--red); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi { background: var(--card); border-radius: 20px; padding: 16px; box-shadow: var(--shadow-s); }
.kpi b { font-size: 30px; font-weight: 900; display: block; }
.kpi span { font-size: 13px; color: var(--ink-3); font-weight: 800; }
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.days i { aspect-ratio: 1; border-radius: 6px; background: #e3e7f7; }
.days i.on { background: var(--green); }
.days i.today { outline: 2px solid var(--blue); outline-offset: 1px; }
.rank { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.rank:last-child { border: 0; }
.rank .no { width: 28px; height: 28px; border-radius: 50%; background: #eef1ff; color: var(--blue); font-weight: 900; display: grid; place-items: center; font-size: 13px; }
.rank .w { flex: 1; min-width: 0; }
.rank .w b { display: block; }
.rank .w span { font-size: 13px; color: var(--ink-2); }
.rank .x { font-weight: 900; color: var(--red); }
.slist .s { display: flex; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px; gap: 8px; }
.slist .s:last-child { border: 0; }
.modal { position: fixed; inset: 0; background: rgba(20, 24, 58, .5); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--bg); border-radius: 28px 28px 0 0; padding: 20px 18px calc(var(--safe-b) + 22px); max-height: 92vh; overflow-y: auto; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 14px; font-size: 20px; font-weight: 900; }
.opt { display: flex; gap: 8px; }
.opt button { flex: 1; min-height: 46px; border-radius: 13px; background: var(--card); font-weight: 800; box-shadow: var(--shadow-s); border: 2px solid transparent; }
.opt button.on { border-color: var(--blue); color: var(--blue); }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 14px; font-weight: 800; }
.switch button { width: 56px; height: 32px; border-radius: 99px; background: #cfd5ee; position: relative; transition: .2s; }
.switch button::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
.switch button.on { background: var(--green); }
.switch button.on::after { left: 28px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #cfd8ff; border-top-color: var(--blue); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.capbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.capbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 8px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); border: 2px solid transparent; font-size: 16px; text-align: center; cursor: pointer; }
.capbtn:first-child { background: linear-gradient(135deg, #3d6bff, #7a5cf6); color: #fff; box-shadow: 0 12px 26px rgba(80, 90, 240, .32); }
.capbtn .ic { font-size: 36px; line-height: 1; }
.pthumb { position: relative; flex: 0 0 auto; }
.pthumb img { height: 130px; border-radius: 12px; display: block; }
.pthumb button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(20, 24, 58, .75); color: #fff; font-size: 13px; display: grid; place-items: center; }
