:root {
  --coral: #ff7359;
  --coral-dark: #e7543d;
  --coral-soft: #fff0e9;
  --yellow: #ffd76a;
  --mint: #62c8ae;
  --blue: #66a5db;
  --purple: #9a83d4;
  --ink: #2e2926;
  --muted: #817772;
  --line: #eee3dc;
  --paper: #fff;
  --bg: #fff9f5;
  --shadow: 0 12px 32px rgba(91, 63, 46, .09);
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 10% 0, #fff2df 0, transparent 30%), var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 900px; min-height: 100vh; margin: auto; padding-bottom: 92px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 10px; position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); }
.brand { border: 0; background: none; display: flex; gap: 10px; align-items: center; color: var(--ink); text-align: left; padding: 0; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--coral-soft); font-size: 22px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: -.04em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.parent-button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 10px 14px; box-shadow: 0 4px 14px rgba(91,63,46,.05); font-size: 13px; font-weight: 700; }
.cloud-button { border: 1px solid #cce8dd; background: #effaf6; color: #26745f; border-radius: 999px; padding: 10px 14px; font-size: 13px; font-weight: 800; }
.cloud-button.syncing { opacity: .65; }

#main-content { padding: 12px 22px 32px; outline: none; }
.hero { padding: 22px; border-radius: 28px; background: linear-gradient(135deg, #ff8367, #ff6b71); color: white; box-shadow: 0 18px 36px rgba(231,84,61,.2); overflow: hidden; position: relative; }
.hero::after { content: ""; position: absolute; width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,.12); right: -50px; top: -50px; }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; z-index: 1; }
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 800; opacity: .85; }
h1, h2, h3, p { margin-top: 0; }
.hero h1 { font-size: clamp(24px, 5vw, 34px); letter-spacing: -.05em; margin-bottom: 8px; }
.hero p { margin-bottom: 0; opacity: .92; }
.progress-ring { flex: 0 0 86px; width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(white var(--progress, 0%), rgba(255,255,255,.25) 0); position: relative; }
.progress-ring::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: #ff7070; }
.progress-ring strong { position: relative; z-index: 1; font-size: 19px; }

.child-tabs { display: flex; gap: 9px; overflow-x: auto; padding: 4px 1px 18px; scrollbar-width: none; }
.child-tabs::-webkit-scrollbar { display: none; }
.child-chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--paper); color: var(--muted); border-radius: 999px; padding: 9px 14px 9px 9px; font-weight: 750; display: flex; align-items: center; gap: 7px; }
.child-chip.active { color: var(--coral-dark); border-color: #ffc1b2; background: var(--coral-soft); }
.avatar { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: var(--avatar, #ffd76a); color: white; font-size: 13px; font-weight: 900; }

.section { margin-top: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: -.04em; }
.section-head small { color: var(--muted); }
.card { background: var(--paper); border: 1px solid rgba(238,227,220,.9); border-radius: 22px; box-shadow: var(--shadow); }
.task-list { overflow: hidden; }
.task { display: flex; align-items: center; gap: 13px; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task-check { appearance: none; width: 25px; height: 25px; flex: 0 0 25px; border: 2px solid #dacbc3; border-radius: 8px; display: grid; place-items: center; background: white; }
.task-check:checked { background: var(--mint); border-color: var(--mint); }
.task-check:checked::after { content: "✓"; color: white; font-weight: 900; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-icon { width: 39px; height: 39px; flex: 0 0 39px; border-radius: 13px; display: grid; place-items: center; background: var(--coral-soft); }
.task-copy { min-width: 0; flex: 1; }
.task-title { display: block; font-weight: 800; overflow-wrap: anywhere; }
.task-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.points { color: var(--coral-dark); font-weight: 850; font-size: 12px; white-space: nowrap; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty span { font-size: 34px; display: block; margin-bottom: 10px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat { padding: 15px; border-radius: 18px; background: rgba(255,255,255,.17); backdrop-filter: blur(4px); }
.stat small, .stat strong { display: block; }
.stat small { font-size: 11px; opacity: .82; }
.stat strong { margin-top: 4px; font-size: 18px; }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(100px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.day-column { min-height: 250px; }
.day-title { text-align: center; font-weight: 850; font-size: 13px; margin-bottom: 8px; color: var(--muted); }
.day-title.today { color: var(--coral-dark); }
.schedule-item { padding: 11px; border-radius: 14px; margin-bottom: 8px; font-size: 12px; background: var(--coral-soft); border-left: 4px solid var(--coral); }
.schedule-item.academy { background: #eef7ff; border-color: var(--blue); }
.schedule-item.school { background: #f1fbf7; border-color: var(--mint); }
.schedule-item strong, .schedule-item span { display: block; }
.schedule-item span { color: var(--muted); margin-top: 3px; }

.reward-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 13px; }
.reward-card { padding: 18px; position: relative; overflow: hidden; }
.reward-card .reward-emoji { font-size: 32px; }
.reward-card h3 { margin: 11px 0 4px; font-size: 16px; }
.reward-card p { color: var(--muted); font-size: 13px; min-height: 38px; }
.reward-price { font-weight: 900; color: var(--coral-dark); }
.reward-card button { width: 100%; margin-top: 13px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; background: var(--coral-soft); color: var(--coral-dark); }
.badge.pending { background: #fff7d8; color: #8d6d00; }
.badge.approved { background: #e9f8f2; color: #26745f; }
.badge.used { background: #eee; color: #666; }

.exam-list { display: grid; gap: 13px; }
.exam-card { padding: 18px; }
.exam-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.exam-card h3 { margin-bottom: 4px; }
.exam-score { display: flex; align-items: baseline; gap: 4px; margin-top: 14px; }
.exam-score strong { font-size: 30px; color: var(--coral-dark); }
.exam-score span { color: var(--muted); }
.score-bar { height: 9px; background: #f1e9e4; border-radius: 99px; overflow: hidden; margin: 10px 0; }
.score-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--coral)); width: var(--score); }

.btn { border: 0; border-radius: 13px; padding: 11px 15px; font-weight: 800; background: var(--coral); color: white; }
.btn:hover { filter: brightness(.98); }
.btn:disabled { background: #d8cfca; cursor: not-allowed; }
.btn.secondary { background: var(--coral-soft); color: var(--coral-dark); }
.btn.ghost { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fff0ef; color: #c43d3d; }
.text-button { border: 0; background: none; color: var(--coral-dark); font-weight: 800; padding: 4px; }

.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 900px); min-height: calc(72px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); box-shadow: 0 -6px 22px rgba(61,43,32,.07); border: 1px solid rgba(238,227,220,.95); border-bottom: 0; border-radius: 22px 22px 0 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px 10px max(7px, env(safe-area-inset-bottom)); z-index: 20; backdrop-filter: blur(18px); }
.bottom-nav button { border: 0; background: none; color: var(--muted); border-radius: 18px; display: grid; place-items: center; gap: 1px; padding: 4px; }
.bottom-nav button span { font-size: 20px; line-height: 1; }
.bottom-nav button small { font-size: 11px; font-weight: 750; }
.bottom-nav button.active { color: var(--coral-dark); background: var(--coral-soft); box-shadow: inset 0 0 0 1px rgba(255,115,89,.08); }

.modal { border: 0; padding: 0; background: transparent; width: min(92%, 560px); max-height: 88vh; }
.modal::backdrop { background: rgba(45,35,30,.45); backdrop-filter: blur(3px); }
.modal-card { background: var(--paper); border-radius: 25px; padding: 24px; position: relative; max-height: 88vh; overflow-y: auto; }
.modal-close { position: absolute; top: 13px; right: 13px; width: 35px; height: 35px; border-radius: 50%; border: 0; background: #f5efeb; font-size: 23px; color: var(--muted); }
.modal h2 { padding-right: 35px; font-size: 21px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; color: var(--ink); background: white; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.check-days { display: flex; flex-wrap: wrap; gap: 7px; }
.check-days label { position: relative; }
.check-days input { position: absolute; opacity: 0; }
.check-days span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; font-weight: 800; }
.check-days input:checked + span { background: var(--coral); color: white; border-color: var(--coral); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.admin-header { padding: 22px; background: linear-gradient(135deg, #3c3a50, #585377); color: white; border-radius: 26px; }
.admin-header h1 { margin-bottom: 7px; }
.admin-header p { margin: 0; opacity: .8; }
.admin-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 17px 0; padding-bottom: 3px; }
.admin-tabs button { white-space: nowrap; border: 1px solid var(--line); background: white; border-radius: 999px; padding: 9px 13px; font-weight: 750; color: var(--muted); }
.admin-tabs button.active { background: #4a4665; color: white; border-color: #4a4665; }
.admin-list { display: grid; gap: 9px; }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 14px; }
.admin-row > div { flex: 1; min-width: 0; }
.admin-row strong, .admin-row small { display: block; }
.admin-row small { color: var(--muted); margin-top: 3px; }
.admin-row-actions { display: flex; gap: 6px; }
.admin-row-actions button { border: 0; border-radius: 9px; padding: 7px 9px; background: #f5efeb; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; }
.quick-action { text-align: left; padding: 16px; border: 1px solid var(--line); background: white; border-radius: 18px; color: var(--ink); font-weight: 800; }
.quick-action span { display: block; font-size: 26px; margin-bottom: 8px; }
.notice { border-radius: 15px; padding: 13px; background: #fff8dd; color: #725d12; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 15px); background: #302c2a; color: white; padding: 11px 17px; border-radius: 999px; z-index: 100; opacity: 0; pointer-events: none; transition: .25s; font-size: 13px; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

.game-hero { background: linear-gradient(145deg, #153d35, #1e6f58); }
.game-wrap { max-width: 460px; margin: 18px auto 0; }
.player-name-card { max-width: 460px; margin: 14px auto 0; padding: 14px; display: flex; align-items: end; gap: 9px; }
.player-name-card .field { flex: 1; margin: 0; }
.player-name-card .btn { flex: 0 0 auto; }
.game-scoreboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.game-scoreboard div { background: #15221f; color: white; border-radius: 14px; padding: 10px; text-align: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.game-scoreboard small, .game-scoreboard strong { display: block; }
.game-scoreboard small { color: #a8c0b9; font-size: 10px; }
.game-scoreboard strong { margin-top: 3px; font-size: 18px; color: #ffe484; }
.game-canvas-shell { position: relative; border-radius: 24px; overflow: hidden; background: #7cc9ee; box-shadow: 0 18px 36px rgba(25,67,57,.18); border: 5px solid white; }
#home-run-canvas { width: 100%; aspect-ratio: 360 / 460; display: block; touch-action: manipulation; }
.game-result { position: absolute; left: 50%; top: 22%; transform: translate(-50%,-50%) scale(.9); min-width: 170px; padding: 12px 18px; border-radius: 999px; background: rgba(20,31,28,.88); color: white; text-align: center; font-weight: 950; opacity: 0; transition: .2s; pointer-events: none; }
.game-result.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.swing-button { width: 100%; border: 0; border-radius: 20px; padding: 17px; margin-top: 11px; background: linear-gradient(135deg, #ff785c, #ff4f62); color: white; font-size: 21px; font-weight: 950; letter-spacing: -.03em; box-shadow: 0 10px 22px rgba(220,71,65,.25); touch-action: manipulation; }
.swing-button:active { transform: translateY(2px); }
.game-note { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.locked-game { padding: 28px 20px; text-align: center; }
.locked-game .lock-emoji { font-size: 58px; display: block; margin-bottom: 12px; }
.locked-game h2 { margin-bottom: 8px; }
.locked-game p { color: var(--muted); }
.locked-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }

@media (max-width: 560px) {
  .topbar { padding: 14px 16px 8px; }
  #main-content { padding: 10px 16px 28px; }
  .parent-button { padding: 9px 11px; }
  .parent-button span, .cloud-button span { display: none; }
  .cloud-button { padding: 9px 11px; }
  .hero { padding: 19px; border-radius: 23px; }
  .hero-row { align-items: flex-start; }
  .progress-ring { width: 72px; height: 72px; flex-basis: 72px; }
  .stats { gap: 7px; }
  .stat { padding: 12px 9px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .player-name-card { align-items: stretch; flex-direction: column; }
}

@media (min-width: 800px) {
  .app-shell { padding-bottom: 105px; }
  .topbar { padding-top: 24px; }
}
