/* 우리집 공부방 — 16인치 터치 모니터(DeX)에서 손가락으로 쓰기 좋게, 큰 글씨와 큰 버튼 */
:root {
  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --ink: #1F2633;
  --muted: #667085;
  --line: #D9DFE8;
  --good: #1F9D61;
  --good-soft: #E2F5EA;
  --bad: #D64545;
  --bad-soft: #FCE7E7;
  --warn: #B26B00;
  --warn-soft: #FFF2D6;
  --kid: #2F6FD6;
  --kid-soft: #E3EDFC;
  --display: 'Jua', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  --body: 'Gowun Dodum', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* 크롬의 당겨서 새로고침, 옆으로 밀어 뒤로 가기, 두 번 눌러 확대를 막는다 (문제 풀다 튕기는 것 방지) */
html, body { height: 100%; overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--kid); outline-offset: 3px; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 400; }
p { margin: 0; }

#app { min-height: 100%; }
.screen {
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 공통 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 60px; padding: 0 28px; border-radius: 16px;
  font-family: var(--display); font-size: 24px;
  border: 2px solid transparent; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--kid); color: #fff; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.ghost:disabled { color: var(--muted); background: transparent; }
.btn.danger { background: var(--bad); color: #fff; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 17px; padding: 10px 12px; text-decoration: underline; text-underline-offset: 4px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; }
.back {
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px;
  padding: 10px 18px; font-size: 18px; font-family: var(--display);
}
.topbar .back, .topbar .count { flex: none; white-space: nowrap; }
.round-title { font-family: var(--display); font-size: 24px; color: var(--kid); text-align: center; flex: 1; min-width: 0; }
.count { font-family: var(--display); font-size: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count b { color: var(--ink); font-weight: 400; font-size: 30px; }

/* 첫 화면 */
.home { justify-content: center; gap: 32px; }
.home-head { text-align: center; display: flex; flex-direction: column; gap: 6px; }
.home-head .date { color: var(--muted); font-size: 20px; }
.home-head h1 { font-size: clamp(44px, 6vw, 68px); }
.ask { text-align: center; font-size: 24px; color: var(--muted); }
.kid-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 24px; }
.kid-card {
  background: var(--surface); border: 3px solid transparent; border-radius: 28px;
  padding: 32px 20px 28px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: 0 2px 0 var(--line);
  transition: transform .1s ease, border-color .1s ease;
}
button.kid-card:active { transform: scale(.98); border-color: var(--kid); }
.avatar {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: var(--kid-soft); color: var(--kid); font-family: var(--display); font-size: 48px;
}
.kname { font-family: var(--display); font-size: 44px; line-height: 1.2; }
.kgrade { color: var(--muted); font-size: 18px; }
.kstatus {
  margin-top: 8px; padding: 6px 16px; border-radius: 999px; font-size: 16px;
  background: var(--bg); color: var(--muted);
}
.kstatus.done { background: var(--good-soft); color: var(--good); }
.kstatus.doing { background: var(--warn-soft); color: var(--warn); }
.kid-card.waiting { background: transparent; border: 3px dashed var(--line); box-shadow: none; }
.kid-card.waiting .avatar { opacity: .55; }
.kid-card.waiting .kname { color: var(--muted); }
.home-foot { display: flex; justify-content: flex-end; }

/* 아이 홈 */
.hello { font-size: clamp(36px, 4.5vw, 52px); color: var(--kid); }
.tasks { display: flex; flex-direction: column; gap: 16px; }
.task-card {
  background: var(--surface); border-radius: 24px; padding: 24px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  border: 3px solid transparent;
}
.task-card.done { border-color: var(--good-soft); }
.task-card.locked { background: transparent; border: 3px dashed var(--line); }
.task-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.task-info h2 { font-size: 32px; }
.task-info p { color: var(--muted); }
.tstatus { align-self: flex-start; margin-top: 6px; padding: 4px 14px; border-radius: 999px; font-size: 15px; background: var(--bg); color: var(--muted); }
.tstatus.done { background: var(--good-soft); color: var(--good); }
.tstatus.doing { background: var(--warn-soft); color: var(--warn); }

/* 연산 */
.progress { height: 14px; border-radius: 999px; background: #E2E7EF; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--kid); border-radius: 999px; transition: width .3s ease; }
.math-body {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; align-items: center;
}
.problem { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.ptype { color: var(--muted); font-size: 20px; }
.equation {
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px 18px;
  font-family: var(--display); font-size: clamp(44px, 5.2vw, 72px); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.op { color: var(--muted); }
.op.eq { color: var(--ink); }
.mixed { display: inline-flex; align-items: center; gap: .12em; }
.whole { line-height: 1; }
.frac { display: inline-flex; flex-direction: column; align-items: center; font-size: .66em; line-height: 1.05; }
.frac .num { padding: 0 .2em .06em; border-bottom: .07em solid currentColor; }
.frac .den { padding: .06em .2em 0; }
.or { font-family: var(--body); font-size: .4em; color: var(--muted); margin: 0 .3em; }

.slot {
  min-width: 2.6em; padding: .08em .3em; border-radius: 16px;
  background: var(--surface); border: 4px solid var(--line);
  font-family: var(--display); font-size: 1em; line-height: 1.15; text-align: center;
}
.slot.wide { min-width: 3.4em; }
.slot.active { border-color: var(--kid); box-shadow: 0 0 0 6px var(--kid-soft); }
.ans-frac { display: inline-flex; align-items: center; gap: .15em; }
.whole-slot { font-size: .85em; min-width: 1.6em; }
.frac-in { display: inline-flex; flex-direction: column; align-items: center; gap: .08em; }
.num-slot { font-size: .62em; min-width: 2em; }
.bar { display: block; width: 100%; height: .07em; background: var(--ink); border-radius: 2px; }
.den-fixed { font-size: .62em; line-height: 1.1; }
.ans-div { display: inline-flex; align-items: center; gap: .25em; flex-wrap: wrap; }
.ans-div .lbl { font-family: var(--body); font-size: .36em; color: var(--muted); }

.feedback { min-height: 64px; font-family: var(--display); font-size: 30px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.feedback.note { font-family: var(--body); font-size: 18px; color: var(--muted); }
.feedback.good { color: var(--good); font-size: 40px; }
.feedback.bad { color: var(--bad); }
.feedback.hint { color: var(--warn); font-size: 24px; }
.feedback.reveal {
  align-items: flex-start; background: var(--warn-soft); border-radius: 20px; padding: 18px 22px; font-size: 26px;
}
.feedback.reveal p { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.feedback.reveal .small { font-family: var(--body); font-size: 17px; color: var(--muted); }
.reveal-ans { font-size: 40px; color: var(--ink); display: inline-flex; align-items: center; }
.tip { color: var(--muted); font-size: 17px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key {
  height: 78px; border-radius: 18px; background: var(--surface); border: 2px solid var(--line);
  font-family: var(--display); font-size: 36px; box-shadow: 0 3px 0 var(--line);
  transition: transform .06s ease;
}
.key:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.key:disabled { opacity: .45; }
.key-back { font-size: 22px; color: var(--muted); }
.key-ok { grid-column: 1 / -1; height: 84px; background: var(--kid); border-color: var(--kid); color: #fff; box-shadow: none; font-size: 32px; }
.key-gap { display: block; }

/* 라운드 사이 쉬는 화면, 결과 화면 */
.pause { justify-content: center; align-items: center; }
.pause-card {
  background: var(--surface); border-radius: 32px; padding: 44px clamp(24px, 5vw, 64px);
  width: min(640px, 100%); display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center;
}
.pause-card .big { font-family: var(--display); font-size: 52px; color: var(--kid); }
.pause-card .next { font-size: 20px; }
.big-btn { min-height: 72px; font-size: 28px; width: 100%; max-width: 360px; margin-top: 8px; }
.stats { margin: 8px 0 0; width: 100%; display: flex; flex-direction: column; gap: 0; }
.stats div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-family: var(--display); font-size: 24px; font-variant-numeric: tabular-nums; }
.stats dd.small { font-family: var(--body); font-size: 18px; text-align: right; }

/* 부모 모드 */
.pin-screen { gap: 12px; }
.pin-box { margin: 0 auto; width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.pin-box h1 { font-size: 30px; }
.dots { display: flex; gap: 16px; }
.dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--muted); }
.dot.on { background: var(--ink); border-color: var(--ink); }
.pin-msg { color: var(--bad); min-height: 27px; }
.pin-pad { width: 100%; }
.parent { user-select: text; }
.tabs { display: flex; gap: 10px; flex-wrap: wrap; }
.tab { padding: 10px 26px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); font-family: var(--display); font-size: 22px; }
.tab.on { background: var(--kid); border-color: var(--kid); color: #fff; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 17px; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 400; font-size: 15px; }
td { font-variant-numeric: tabular-nums; }
.pill { padding: 3px 12px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 15px; }
.pill.done { background: var(--good-soft); color: var(--good); }
.pill.doing { background: var(--warn-soft); color: var(--warn); }
.parent-actions { display: flex; }
.confirm { background: var(--bad-soft); border-radius: 18px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.note-text { color: var(--muted); font-size: 16px; }
.pill.err { background: var(--bad-soft); color: var(--bad); }
.events { background: var(--surface); border-radius: 20px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.events-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.events h2 { font-size: 22px; }
.events ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.events li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 15px; }
.ev-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.ev-msg { min-width: 0; overflow-wrap: anywhere; }

/* 좁은 화면(폰 세로, 작은 창) */
@media (max-width: 860px) {
  .math-body { grid-template-columns: 1fr; align-items: start; }
  .keypad { max-width: 460px; width: 100%; margin: 0 auto; }
  .key { height: 64px; }
  .key-ok { height: 70px; }
  .round-title { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
