:root {
  --sky: #bcecf8;
  --sky-deep: #8ed8eb;
  --paper: #fffaf0;
  --paper-bright: #fffef9;
  --ink: #143963;
  --ink-strong: #0b356d;
  --muted: #5e738a;
  --line: #e2d6be;
  --stitch: rgba(141, 111, 72, 0.26);
  --coral: #ef6758;
  --coral-dark: #bd443b;
  --mint: #2ba992;
  --mint-dark: #147d6b;
  --yellow: #ffd55a;
  --blue: #4a9fe5;
  --purple: #8d63d7;
  --slot-empty: #eee9df;
  --shadow: 0 8px 0 rgba(43, 86, 107, 0.12), 0 18px 38px rgba(33, 91, 119, 0.16);
  --press-shadow: 0 5px 0 rgba(34, 76, 98, 0.17);
  --active-character-image: url("unicorn-lena-cutout.png");
  color-scheme: light;
  font-family: ui-rounded, "SF Pro Rounded", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 0; min-height: 100%; background: var(--sky); }
body {
  min-width: 0;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 9%, rgba(255,255,255,.78) 0 3.2%, transparent 3.35%),
    radial-gradient(circle at 94% 16%, rgba(255,255,255,.68) 0 4%, transparent 4.15%),
    linear-gradient(180deg, #aee8f7 0%, #d8f5fb 63%, #eff8dd 100%);
  color: var(--ink);
}
body::after {
  content: "";
  position: fixed;
  inset: auto -8vw -8vw auto;
  z-index: -1;
  width: 58vw;
  height: 20vw;
  border-radius: 50% 50% 0 0;
  background: radial-gradient(ellipse at 50% 100%, #61c98b 0 46%, transparent 47%), radial-gradient(ellipse at 82% 100%, #a4dc76 0 52%, transparent 53%);
  opacity: .56;
  pointer-events: none;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
[hidden] { display: none !important; }
svg { display: block; }

:focus-visible { outline: 4px solid #1769b0; outline-offset: 3px; }
.screen { display: none; width: 100%; min-height: 100svh; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.screen.active { display: grid; }
.setup, .history-screen { place-items: center; }

/* 공통 노트 표면 */
.setup-card, .history-card, .progress-side, .card, .answer-panel, .side {
  border: 3px solid rgba(255,255,255,.9);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.setup-card, .history-card { position: relative; isolation: isolate; }
.setup-card::after, .history-card::after {
  content: "";
  position: absolute;
  inset: 11px;
  z-index: -1;
  border: 2px dashed var(--stitch);
  border-radius: 24px;
  pointer-events: none;
}

/* 시작 화면 */
.setup-card {
  width: min(1180px, calc(100vw - 24px));
  height: min(720px, calc(100svh - 24px));
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(250px, .34fr) minmax(0, .66fr);
  gap: clamp(22px, 3vw, 42px);
  overflow: hidden;
  border-radius: 34px;
  padding: clamp(28px, 3.8vw, 48px);
}
.setup-card::before {
  content: "";
  position: absolute;
  top: 26px;
  bottom: 26px;
  left: 34.2%;
  width: 2px;
  background: linear-gradient(transparent, rgba(123,98,63,.2), transparent);
  box-shadow: 7px 0 15px rgba(90,70,45,.08);
}
.setup-mascot {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 44%, rgba(255,255,255,.9) 0 34%, transparent 34.5%),
    linear-gradient(180deg, #dff7fc, #eaf8d9);
}
.setup-mascot::before {
  content: "";
  position: absolute;
  top: 12%;
  left: 50%;
  width: min(96%, 330px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 0 44%, rgba(141,99,215,.42) 44.5% 48%, rgba(63,132,229,.42) 48.5% 52%, rgba(67,197,158,.42) 52.5% 56%, rgba(255,213,90,.46) 56.5% 60%, rgba(255,107,95,.44) 60.5% 64%, transparent 64.5%);
  transform: translateX(-50%);
}
.mascot-challenge-trigger {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 24px;
  padding: 12px;
  background: transparent;
}
.mascot-challenge-trigger img {
  width: 100%;
  height: 100%;
  max-height: 500px;
  object-fit: contain;
  filter: drop-shadow(0 16px 14px rgba(31,91,118,.2));
  transition: transform .2s ease, filter .2s ease;
}
@media (hover:hover) and (pointer:fine) {
  .mascot-challenge-trigger:hover img { transform: translateY(-5px) scale(1.025); filter: drop-shadow(0 20px 18px rgba(31,91,118,.24)); }
}
.image-fallback { display: none; }
.image-missing img { display: none !important; }
.image-missing .image-fallback { display: grid; place-items: center; }
.setup-mascot .character-fallback { font-size: clamp(6rem, 15vw, 12rem); }

.setup-main { min-width: 0; display: grid; align-content: center; gap: 10px; }
.title { margin: 0; color: var(--ink-strong); font-size: clamp(2rem, 3.5vw, 3rem); line-height: 1.08; letter-spacing: -.055em; text-align: center; }
.subtitle { margin: -2px 0 3px; color: var(--muted); font-size: clamp(.9rem, 1.5vw, 1.05rem); font-weight: 760; text-align: center; }
.mode-choice { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.mode-choice-card {
  min-width: 0;
  min-height: 86px;
  display: grid;
  grid-template-columns: 52px minmax(0,1fr);
  align-items: center;
  gap: 10px;
  border: 3px solid #ded6c8;
  border-radius: 21px;
  padding: 10px 14px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 6px 0 rgba(84,69,48,.11);
  color: var(--ink);
  text-align: left;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.mode-choice-card.active { border-color: var(--mint); background: #e8faf4; box-shadow: 0 6px 0 var(--mint-dark), 0 0 0 4px rgba(43,169,146,.11); }
.mode-choice-card.daily.active { border-color: #8b6ad1; background: linear-gradient(115deg, #fff0ef, #fff8d8 40%, #e7faf3 68%, #eee9ff); box-shadow: 0 6px 0 #6650a3, 0 0 0 4px rgba(141,99,215,.11); }
.mode-choice-card:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(70,62,50,.15); }
.mode-choice-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 2px rgba(34,83,103,.08); font-size: 1.5rem; }
.mode-choice-copy { min-width: 0; display: grid; gap: 3px; }
.mode-choice-copy strong { font-size: clamp(1rem, 1.7vw, 1.18rem); line-height: 1.15; }
.mode-choice-copy small { color: var(--muted); font-size: clamp(.7rem, 1.15vw, .82rem); font-weight: 740; line-height: 1.3; }

.practice-config, .daily-mode-panel { min-height: 270px; border: 2px solid var(--line); border-radius: 22px; padding: 14px; background: rgba(255,255,255,.54); }
.practice-config { display: grid; align-content: center; gap: 10px; }
.practice-config-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); font-size: .95rem; }
.toolbar { display: flex; gap: 8px; }
.mini-btn { min-height: 38px; border: 2px solid #d6cebf; border-radius: 12px; padding: 6px 12px; background: #fffef9; box-shadow: 0 3px 0 rgba(72,62,48,.12); color: #426079; font-size: .78rem; font-weight: 900; }
.dan-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.dan-option { position: relative; min-width: 0; }
.dan-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dan-option span { min-height: 64px; display: grid; place-items: center; border: 3px solid #e0d6c4; border-radius: 18px; background: #fffef9; box-shadow: 0 5px 0 rgba(91,70,42,.12); color: var(--ink); font-size: clamp(1.15rem, 2vw, 1.5rem); font-weight: 950; user-select: none; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.dan-option input:checked + span { border-color: var(--mint); background: #ddf7ef; box-shadow: 0 5px 0 var(--mint-dark), inset 0 0 0 3px rgba(255,255,255,.54); }
.dan-option input:focus-visible + span { outline: 4px solid #1769b0; outline-offset: 3px; }
.dan-option:active span { transform: translateY(3px); box-shadow: 0 2px 0 rgba(60,65,55,.15); }
.selection-summary, .message { min-height: 20px; margin: 0; font-size: .82rem; font-weight: 850; text-align: center; }
.selection-summary { color: var(--mint-dark); }
.message { color: #b43f35; }
.daily-mode-panel { display: grid; grid-template-columns: 72px minmax(0,1fr) auto; align-items: center; gap: 16px; padding: 26px; background: linear-gradient(125deg, rgba(255,239,235,.9), rgba(255,249,215,.9) 38%, rgba(229,249,242,.92) 68%, rgba(238,232,255,.9)); }
.daily-mode-rainbow { font-size: 3.4rem; filter: drop-shadow(0 6px 6px rgba(69,79,132,.14)); }
.daily-mode-panel strong { color: var(--ink-strong); font-size: 1.2rem; }
.daily-mode-panel p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; font-weight: 740; }
.daily-mode-panel > span { border-radius: 999px; padding: 8px 12px; background: rgba(255,255,255,.8); color: #624a94; font-size: .78rem; font-weight: 950; white-space: nowrap; }
.setup-actions { width: min(100%, 570px); display: grid; grid-template-columns: minmax(0,1fr) 150px; gap: 11px; margin: 0 auto; }
.start-btn, .challenge-record-btn { min-height: 58px; border: 3px solid transparent; border-radius: 18px; padding: 10px 18px; font-weight: 950; }
.start-btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-color: var(--coral-dark); background: linear-gradient(180deg, #ff8277, var(--coral)); box-shadow: 0 6px 0 var(--coral-dark); color: #fff; font-size: 1.05rem; }
.start-btn.daily { border-color: #6550a0; background: linear-gradient(100deg, #ff7b70, #ffb13f, #ffe168, #66d69e, #59cae3, #8c6bd6); box-shadow: 0 6px 0 #6550a0; text-shadow: 0 1px rgba(37,48,95,.22); }
.challenge-record-btn { border-color: #d4cec2; background: #fffef9; box-shadow: 0 6px 0 rgba(65,72,68,.14); color: var(--ink); }
.start-btn:active, .challenge-record-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(55,62,58,.18); }

/* 캐릭터 선택 */
.character-picker { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; visibility: hidden; padding: 18px; background: rgba(24,61,84,.42); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); opacity: 0; pointer-events: none; transition: opacity .18s ease, visibility .18s ease; }
.character-picker.active { visibility: visible; opacity: 1; pointer-events: auto; }
.character-picker-card { position: relative; width: min(980px, 100%); max-height: calc(100svh - 28px); overflow: auto; border: 4px solid rgba(255,255,255,.92); border-radius: 32px; padding: 28px; background: var(--paper); box-shadow: 0 18px 0 rgba(82,67,45,.14), 0 30px 70px rgba(20,62,86,.3); }
.character-picker-card::after { content: ""; position: absolute; inset: 13px; border: 2px dashed var(--stitch); border-radius: 23px; pointer-events: none; }
.character-picker-head { position: relative; z-index: 1; margin-bottom: 18px; padding-inline: 60px; text-align: center; }
.character-picker-title { margin: 0; color: var(--ink); font-size: clamp(1.7rem, 3.4vw, 2.5rem); letter-spacing: -.045em; }
.character-picker-lead { margin: 5px 0 0; color: var(--muted); font-size: .9rem; font-weight: 760; }
.character-picker-close { position: absolute; top: 18px; right: 18px; z-index: 3; width: 50px; height: 50px; border: 2px solid #d9d1c4; border-radius: 16px; background: #fff; box-shadow: 0 5px 0 rgba(50,72,78,.13); color: var(--ink); font-size: 1.55rem; font-weight: 900; }
.character-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.character-option { position: relative; min-width: 0; min-height: 190px; display: grid; grid-template-rows: minmax(118px,1fr) auto; place-items: center; gap: 6px; border: 3px solid var(--line); border-radius: 23px; padding: 10px 8px 13px; background: rgba(255,255,255,.75); box-shadow: 0 6px 0 rgba(84,65,42,.11); color: var(--ink); font-weight: 950; }
.character-option img { width: 100%; height: 138px; object-fit: contain; filter: drop-shadow(0 7px 7px rgba(28,86,111,.14)); pointer-events: none; }
.character-option[aria-pressed="true"] { border-color: var(--mint); background: #e7faf3; box-shadow: 0 6px 0 var(--mint-dark), 0 0 0 4px rgba(43,169,146,.12); }
.character-option[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); box-shadow: 0 3px 0 var(--mint-dark); color: #fff; }

/* 기록 화면 */
.history-screen { overflow-y: auto; }
.history-card { width: min(1180px, calc(100vw - 24px)); height: min(720px, calc(100svh - 24px)); min-height: 0; display: grid; grid-template-rows: auto auto auto auto auto minmax(0,1fr); gap: 8px; overflow: hidden; border-radius: 32px; padding: 18px 24px 20px; }
.history-top { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr) 80px; align-items: center; gap: 16px; }
.history-top > div { text-align: center; }
.history-back-btn, .back-btn, .restart-btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 2px solid #d5cec1; border-radius: 15px; padding: 8px 13px; background: #fffef9; box-shadow: 0 4px 0 rgba(55,71,71,.14); color: var(--ink); font-size: .85rem; font-weight: 900; }
.history-back-btn svg, .back-btn svg, .restart-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.history-heading { margin: 0; color: var(--ink-strong); font-size: clamp(1.7rem,3vw,2.4rem); letter-spacing: -.045em; }
.history-lead { margin: 2px 0 0; color: var(--muted); font-size: .78rem; font-weight: 740; }
.history-mascot { width: 80px; height: 58px; object-fit: contain; justify-self: end; }
.history-filters { display: grid; grid-template-columns: repeat(9,minmax(0,1fr)); gap: 7px; }
.history-challenge-filter { display: grid; grid-template-columns: minmax(220px,330px); justify-content: center; }
.history-filter { min-height: 38px; border: 2px solid #dbd3c5; border-radius: 12px; padding: 5px 8px; background: #fffef9; box-shadow: 0 3px 0 rgba(74,67,55,.11); color: #50677e; font-size: .76rem; font-weight: 900; }
.history-filter.active { border-color: var(--mint-dark); background: var(--mint); box-shadow: 0 3px 0 var(--mint-dark); color: #fff; }
.history-filter[data-filter="challenge"] { background: linear-gradient(100deg, #fff0ed, #fff8d7, #e9faf3, #eee9ff); }
.history-filter[data-filter="challenge"].active { border-color: #7056aa; background: linear-gradient(100deg, #ff7b70, #ffb13f, #ffe168, #66d69e, #59cae3, #8c6bd6); box-shadow: 0 3px 0 #7056aa; color: #fff; }
.history-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); border: 2px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.57); overflow: hidden; }
.history-metric { min-width: 0; min-height: 60px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 8px 12px; }
.history-metric + .history-metric { border-left: 2px dashed rgba(127,99,63,.18); }
.history-metric-icon { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; background: #e6f6f2; font-size: 1.05rem; }
.history-metric > div { min-width: 0; display: grid; }
.history-metric-label { color: var(--muted); font-size: .68rem; font-weight: 800; }
.history-metric-value { overflow: hidden; color: var(--ink); font-size: clamp(.78rem,1.35vw,.98rem); text-overflow: ellipsis; white-space: nowrap; }
.history-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 20px; }
.history-note, .history-trend { margin: 0; color: var(--muted); font-size: .7rem; font-weight: 800; }
.history-trend { color: var(--mint-dark); text-align: right; }
.history-chart-stack { min-height: 0; display: grid; grid-template-rows: minmax(0,1.08fr) minmax(0,.92fr); gap: 8px; overflow: hidden; }
.history-chart-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr); overflow: hidden; border: 2px solid var(--line); border-radius: 18px; padding: 8px 10px 5px; background: rgba(255,255,255,.62); }
.history-chart-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 4px 2px; }
.history-chart-label h3 { margin: 0; color: var(--ink); font-size: .86rem; }
.history-chart-label span { color: var(--muted); font-size: .66rem; font-weight: 760; }
.history-large, .history-accuracy-chart { width: 100%; height: 100%; min-height: 0; }
.history-grid { stroke: #dce4e3; stroke-width: 1.3; stroke-dasharray: 4 6; }
.history-axis { fill: #63758a; font-size: 9px; font-weight: 760; }
.history-bar { fill: #63cfbb; stroke: #22937f; stroke-width: 2; }
.history-bar-value { fill: #167c6b; font-size: 10px; font-weight: 950; }
.history-accuracy-line { stroke: var(--coral); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.history-accuracy-dot { fill: #fffdf7; stroke: var(--coral); stroke-width: 4; }
.history-accuracy-value { fill: var(--coral-dark); font-size: 10px; font-weight: 950; }
.history-line { stroke: var(--mint); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.history-dot { fill: #fffdf7; stroke-width: 4; }
.history-value { fill: var(--mint-dark); font-size: 9px; font-weight: 900; }
.history-empty { margin: auto; color: var(--muted); font-weight: 800; text-align: center; }

/* 문제 화면 */
.game { height: 100svh; grid-template-columns: minmax(0,1fr); grid-template-rows: 52px 72px minmax(0,1fr) 88px; gap: 9px; overflow: hidden; padding: max(9px,env(safe-area-inset-top)) max(9px,env(safe-area-inset-right)) max(9px,env(safe-area-inset-bottom)) max(9px,env(safe-area-inset-left)); }
.game-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.nav-actions { display: flex; gap: 8px; }
.back-btn, .restart-btn { min-height: 46px; padding-inline: 12px; }
.mode-badge { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; justify-self: center; gap: 3px; border: 3px solid rgba(255,255,255,.9); border-radius: 16px; padding: 7px 16px; background: #fffef9; box-shadow: 0 5px 0 rgba(39,73,85,.15); color: var(--ink); font-weight: 950; white-space: nowrap; }
.mode-badge.segmented { padding: 0; overflow: hidden; }
.mode-dan { padding: 9px 11px; border-right: 1px solid #e2dacb; }
.mode-dan:last-child { border-right: 0; }
.mode-dan.active { background: #ff8175; color: #fff; }
.mode-badge.daily-challenge-badge { min-width: min(310px,42vw); border-color: rgba(255,255,255,.94); background: linear-gradient(100deg,#ff7b70,#ffad37,#ffe16a,#62d59e,#56cde1,#63a3ec,#a67be2); box-shadow: 0 5px 0 rgba(75,67,137,.24); color: #fff; text-shadow: 0 2px rgba(44,55,105,.24); }
.timer { min-width: 116px; min-height: 46px; display: grid; place-items: center; justify-self: end; border: 3px solid rgba(255,255,255,.92); border-radius: 16px; background: #e8f7ff; box-shadow: 0 5px 0 rgba(38,91,115,.15); color: #22637d; font-variant-numeric: tabular-nums; font-weight: 950; }
.timer.paused { color: var(--muted); }
.progress-side { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; border-radius: 20px; padding: 8px 12px; }
.progress-track { min-width: 0; display: grid; grid-template-columns: repeat(10,minmax(0,1fr)); gap: clamp(5px,1vw,12px); align-items: center; }
.progress-slot { position: relative; width: 100%; max-width: 54px; aspect-ratio: 1; justify-self: center; border: 2px solid rgba(105,82,52,.13); border-radius: 50%; background: var(--slot-empty); }
.progress-slot::before { content: attr(data-step); position: absolute; inset: 0; display: grid; place-items: center; color: #83909b; font-size: .72rem; font-weight: 900; }
.progress-slot.filled::before { content: attr(data-mark); color: #fff; font-size: clamp(.75rem,1.8vw,1.15rem); text-shadow: 0 1px rgba(40,50,70,.2); }
.progress-slot.filled.wrong { background: var(--coral) !important; box-shadow: 0 0 13px rgba(239,103,88,.38), inset 0 -3px rgba(108,31,27,.14) !important; }
.progress-summary { min-width: 250px; display: grid; grid-template-columns: repeat(2,max-content); gap: 3px 13px; padding-left: 13px; border-left: 2px dashed rgba(118,92,58,.2); color: #526b82; font-size: .7rem; font-weight: 850; }
.game.daily-challenge .progress-track { grid-template-columns: repeat(15,minmax(0,1fr)); grid-template-rows: repeat(2,1fr); gap: 3px 5px; }
.game.daily-challenge .progress-slot { max-width: 38px; height: 23px; aspect-ratio: auto; border-radius: 8px; }
.game.daily-challenge .progress-slot::before { font-size: .62rem; }

.play-zone { min-width: 0; min-height: 0; }
.play-stack { width: min(1180px,100%); height: 100%; margin: 0 auto; display: grid; grid-template-columns: minmax(0,1.55fr) minmax(330px,.9fr); gap: 16px; }
.card { position: relative; min-width: 0; height: 100%; overflow: hidden; border-radius: 26px; isolation: isolate; }
.card::after { content: ""; position: absolute; inset: 11px; z-index: -2; border: 2px dashed rgba(149,112,66,.27); border-radius: 18px; }
.card::before { content: ""; position: absolute; left: clamp(16px,3vw,42px); bottom: 16px; z-index: -1; width: min(35%,240px); height: 70%; background: var(--active-character-image) center bottom / contain no-repeat; filter: drop-shadow(0 10px 8px rgba(30,83,104,.18)); }
.question { position: absolute; top: 27%; left: 60%; width: 66%; transform: translate(-50%,-50%); color: #0d3d7c; font-size: clamp(4.5rem,9vw,7.2rem); font-weight: 950; letter-spacing: -.055em; text-align: center; white-space: nowrap; }
.question:focus { outline: 0; }
.card-answer { position: absolute; top: 58%; left: 61%; min-width: 160px; min-height: 86px; display: grid; place-items: center; transform: translate(-50%,-50%); border: 3px dashed #73add5; border-radius: 18px; background: rgba(255,255,255,.82); color: #0d3d7c; font-size: clamp(3rem,7vw,5rem); font-variant-numeric: tabular-nums; font-weight: 950; line-height: 1; }
.feedback { position: absolute; top: 77%; left: 61%; width: min(64%,420px); min-height: 34px; transform: translateX(-50%); color: transparent; font-size: clamp(.8rem,1.7vw,1.08rem); font-weight: 900; text-align: center; }
.feedback.good { color: var(--mint-dark); }
.feedback.bad { color: var(--coral-dark); }
.card.correct { box-shadow: 0 8px 0 rgba(43,169,146,.18), 0 18px 38px rgba(33,91,119,.16), inset 0 0 0 5px rgba(43,169,146,.14); }
.card.wrong { box-shadow: 0 8px 0 rgba(239,103,88,.17), 0 18px 38px rgba(33,91,119,.16), inset 0 0 0 5px rgba(239,103,88,.13); }
.effects { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.wrong-badge { position: absolute; top: 20px; right: 20px; border: 3px solid #fff; border-radius: 999px; padding: 8px 14px; background: var(--coral); box-shadow: 0 5px 0 var(--coral-dark); color: #fff; font-weight: 950; animation: badgePop .75s ease both; }
.answer-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0,3fr) minmax(0,1fr); gap: 10px; border-radius: 26px; padding: 12px; }
.digit-grid { min-height: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-rows: repeat(3,minmax(0,1fr)); gap: 11px; }
.digit-grid.bottom { grid-template-rows: minmax(0,1fr); }
.digit-btn, .clear-btn { min-width: 0; min-height: 62px; border: 3px solid #d9cfbb; border-radius: 18px; background: #fffdf6; box-shadow: 0 6px 0 rgba(90,68,41,.17); color: #0d3d7c; font-size: clamp(1.8rem,4vw,2.8rem); font-weight: 950; }
.digit-btn:active, .clear-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(75,61,44,.2); }
.clear-btn { border-color: var(--coral-dark); background: var(--coral); color: #fff; font-size: clamp(.78rem,1.5vw,1rem); }
.side { min-width: 0; overflow: hidden; border-radius: 20px; padding: 7px 12px; }
.session-metrics { height: 100%; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
.session-metric { min-width: 0; display: grid; grid-template-columns: 36px auto; grid-template-rows: 1fr 1fr; align-items: center; justify-content: center; column-gap: 9px; padding: 5px 12px; }
.session-metric + .session-metric { border-left: 2px dashed rgba(120,91,55,.18); }
.session-metric-icon { grid-row: 1/3; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px; background: #dcf5ef; color: var(--mint-dark); }
.session-metric-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.session-metric-label { align-self: end; color: var(--muted); font-size: .68rem; font-weight: 800; }
.session-metric-value { align-self: start; color: var(--ink); font-size: 1rem; }
.dan-detail-panel { display: none; }

/* 정답 인터랙션: 카드의 레이아웃은 고정 */
.correct-shine, .correct-ripple, .correct-star, .correct-reward-badge { position: absolute; pointer-events: none; }
.correct-shine { inset: 0; border-radius: 24px; background: radial-gradient(circle at 62% 62%, rgba(255,232,94,.5), rgba(76,216,174,.18) 28%, transparent 58%); animation: correctShine .8s ease-out both; }
.correct-ripple { left: 61%; top: 58%; width: 110px; aspect-ratio: 1; border: 5px solid var(--ring-color,var(--mint)); border-radius: 50%; transform: translate(-50%,-50%); animation: correctRipple .72s ease-out var(--delay,0s) both; }
.correct-star { left: 61%; top: 58%; color: var(--star-color,var(--yellow)); font-size: var(--star-size,1.3rem); filter: drop-shadow(0 3px 3px rgba(34,70,93,.18)); animation: correctStarScatter .78s cubic-bezier(.18,.75,.22,1) var(--delay,0s) both; }
.correct-reward-badge { top: 18px; right: 18px; min-width: 96px; border: 3px solid #fff; border-radius: 999px; padding: 8px 14px; background: linear-gradient(135deg,#fff6a8,#ffe06a 48%,#9ce9cb); box-shadow: 0 6px 0 rgba(27,129,103,.2); color: #174e63; font-weight: 950; animation: correctBadgePop .86s cubic-bezier(.18,.95,.24,1.18) both; }
.card.correct::before { transform-origin: 50% 100%; animation: correctMascotCheer .78s cubic-bezier(.2,.78,.24,1) both; }
.card.correct .card-answer { animation: correctAnswerPop .72s cubic-bezier(.2,.9,.28,1) both; }
.answer-panel.rewarding { animation: correctPanelGlow .82s ease-out both; }

/* 세레머니 */
.progress-celebration { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; visibility: hidden; overflow: hidden; background: radial-gradient(circle at 50% 48%, rgba(255,255,255,.96), rgba(197,240,248,.94) 45%, rgba(125,210,231,.94)); opacity: 0; pointer-events: none; }
.progress-celebration.active { visibility: visible; opacity: 1; pointer-events: auto; }
.celebration-canvas { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }
.celebration-inner { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.celebration-ring { position: absolute; width: min(72vmin,650px); aspect-ratio: 1; border: clamp(16px,3vw,32px) solid rgba(255,255,255,.52); border-radius: 50%; box-shadow: 0 0 0 20px rgba(255,213,90,.2), 0 0 0 42px rgba(67,197,158,.16), 0 0 0 64px rgba(63,132,229,.13); animation: ringPulse 1.5s ease-in-out infinite; }
.rainbow { position: absolute; top: 8%; left: 50%; width: min(78vw,760px); height: min(35vw,270px); border: clamp(14px,2.4vw,28px) solid #ff6b5f; border-bottom: 0; border-radius: 50% 50% 0 0; transform: translateX(-50%); box-shadow: inset 0 16px 0 #ffad37, inset 0 32px 0 #ffe16a, inset 0 48px 0 #62d59e, inset 0 64px 0 #56cde1, inset 0 80px 0 #8d63d7; opacity: .82; }
.celebration-unicorn, .celebration-inner > .image-fallback { position: absolute; z-index: 4; bottom: 24%; width: clamp(210px,32vw,390px); height: clamp(210px,40vh,430px); object-fit: contain; filter: drop-shadow(0 18px 16px rgba(28,79,108,.22)); animation: characterCelebrate 1.15s ease-in-out infinite; }
.celebration-inner > .image-fallback { font-size: clamp(8rem,24vw,17rem); }
.celebration-set-time { position: absolute; left: 50%; bottom: 11%; z-index: 5; min-width: min(520px,88vw); transform: translateX(-50%); border: 4px solid rgba(255,255,255,.94); border-radius: 22px; padding: 12px 22px; background: rgba(255,250,240,.94); box-shadow: 0 7px 0 rgba(38,86,108,.15); color: var(--ink); font-size: clamp(1rem,2.5vw,1.35rem); font-weight: 950; line-height: 1.4; text-align: center; white-space: pre-line; }
.challenge-complete-actions { position: absolute; left: 50%; bottom: 2.5%; z-index: 6; display: flex; gap: 10px; transform: translateX(-50%); }
.challenge-complete-actions button { min-width: 140px; min-height: 52px; border: 3px solid rgba(255,255,255,.94); border-radius: 17px; padding: 9px 16px; box-shadow: 0 5px 0 rgba(44,72,92,.18); font-weight: 950; }
.challenge-again-btn { background: var(--coral); color: #fff; }
.challenge-history-btn { background: var(--paper-bright); color: var(--ink); }
.progress-celebration.challenge-finish .celebration-unicorn, .progress-celebration.challenge-finish .celebration-inner > .image-fallback { bottom: 27%; width: clamp(170px,25vw,300px); height: clamp(180px,34vh,330px); }
.progress-celebration.challenge-finish .celebration-set-time { bottom: 12%; font-size: clamp(.85rem,1.9vw,1.08rem); }

@keyframes badgePop { 0%{opacity:0;transform:scale(.55) rotate(-5deg)} 32%{opacity:1;transform:scale(1.08) rotate(2deg)} 100%{opacity:0;transform:translateY(-8px)} }
@keyframes correctMascotCheer { 0%,100%{transform:translateY(0) scale(1)} 30%{transform:translateY(-16px) scale(1.04) rotate(-2deg)} 60%{transform:translateY(-6px) scale(1.02) rotate(2deg)} }
@keyframes correctAnswerPop { 0%{transform:translate(-50%,-50%) scale(1)} 35%{transform:translate(-50%,-50%) scale(1.14) rotate(-2deg);color:var(--mint-dark)} 100%{transform:translate(-50%,-50%) scale(1)} }
@keyframes correctPanelGlow { 0%,100%{filter:none} 35%{filter:drop-shadow(0 0 15px rgba(67,197,158,.45))} }
@keyframes correctShine { 0%{opacity:0;transform:scale(.72)} 28%{opacity:1} 100%{opacity:0;transform:scale(1.18)} }
@keyframes correctRipple { 0%{opacity:0;transform:translate(-50%,-50%) scale(.3)} 24%{opacity:.9} 100%{opacity:0;transform:translate(-50%,-50%) scale(1.75)} }
@keyframes correctStarScatter { 0%{opacity:0;transform:translate(-50%,-50%) scale(.35)} 22%{opacity:1} 100%{opacity:0;transform:translate(calc(-50% + var(--dx)),calc(-50% + var(--dy))) scale(1.1) rotate(var(--rotation))} }
@keyframes correctBadgePop { 0%{opacity:0;transform:scale(.45) rotate(-7deg)} 30%{opacity:1;transform:scale(1.08) rotate(2deg)} 65%{opacity:1;transform:scale(.98)} 100%{opacity:0;transform:translateY(-10px)} }
@keyframes ringPulse { 0%,100%{transform:scale(.96);opacity:.7} 50%{transform:scale(1.04);opacity:1} }
@keyframes characterCelebrate { 0%,100%{transform:translateY(0) rotate(-1deg)} 50%{transform:translateY(-18px) rotate(2deg)} }

/* iPad 세로 */
@media (orientation: portrait) and (max-width: 900px) {
  .setup-card { width: calc(100vw - 24px); height: calc(100svh - 24px); min-height: 760px; grid-template-columns: 1fr; grid-template-rows: 210px minmax(0,1fr); gap: 18px; padding: 24px 32px 26px; }
  .setup-card::before { display: none; }
  .setup-mascot { min-height: 0; }
  .mascot-challenge-trigger img { max-height: 195px; }
  .setup-main { align-content: center; gap: 10px; }
  .title { font-size: 2.25rem; }
  .practice-config, .daily-mode-panel { min-height: 258px; }
  .history-card { width: calc(100vw - 24px); height: calc(100svh - 24px); min-height: 0; padding: 20px; }
  .history-filters { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .history-chart-stack { grid-template-rows: minmax(0,1fr) minmax(0,.85fr); }
  .game { height: auto; min-height: 100svh; grid-template-rows: 52px 86px 640px 104px; overflow-y: auto; }
  .play-stack { grid-template-columns: 1fr; grid-template-rows: 255px 375px; gap: 10px; }
  .question { font-size: clamp(4.3rem,13vw,6.2rem); }
  .card::before { width: 28%; height: 72%; }
  .digit-btn, .clear-btn { min-height: 76px; }
  .progress-summary { min-width: 228px; }
}

/* 작은 휴대폰 */
@media (max-width: 700px) {
  .screen { padding: 7px; }
  .setup-card { width: 100%; height: auto; min-height: calc(100svh - 14px); grid-template-rows: 118px auto; gap: 11px; border-radius: 24px; padding: 18px 14px; }
  .setup-card::after, .history-card::after { inset: 8px; border-radius: 18px; }
  .mascot-challenge-trigger img { max-height: 108px; }
  .title { font-size: 1.72rem; }
  .subtitle { font-size: .78rem; }
  .mode-choice { gap: 8px; }
  .mode-choice-card { min-height: 78px; grid-template-columns: 38px minmax(0,1fr); gap: 7px; border-width: 2px; border-radius: 16px; padding: 8px; }
  .mode-choice-icon { width: 36px; height: 36px; border-radius: 12px; font-size: 1.12rem; }
  .mode-choice-copy strong { font-size: .88rem; }
  .mode-choice-copy small { font-size: .62rem; }
  .practice-config, .daily-mode-panel { min-height: 310px; padding: 12px; }
  .practice-config-head { align-items: flex-start; flex-direction: column; gap: 7px; }
  .toolbar { width: 100%; }
  .mini-btn { flex: 1; min-height: 40px; }
  .dan-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .dan-option span { min-height: 58px; font-size: 1.15rem; }
  .daily-mode-panel { grid-template-columns: 52px minmax(0,1fr); }
  .daily-mode-panel > span { grid-column: 1/-1; justify-self: center; }
  .daily-mode-rainbow { font-size: 2.4rem; }
  .setup-actions { grid-template-columns: minmax(0,1fr) 112px; gap: 8px; }
  .start-btn, .challenge-record-btn { min-height: 52px; border-radius: 15px; padding-inline: 8px; font-size: .86rem; }

  .character-picker { padding: 7px; }
  .character-picker-card { max-height: calc(100svh - 14px); border-radius: 24px; padding: 22px 12px 16px; }
  .character-picker-head { padding-inline: 42px; margin-bottom: 12px; }
  .character-picker-title { font-size: 1.35rem; }
  .character-picker-lead { font-size: .7rem; }
  .character-picker-close { top: 12px; right: 12px; width: 44px; height: 44px; }
  .character-grid { gap: 7px; }
  .character-option { min-height: 128px; grid-template-rows: 80px auto; border-width: 2px; border-radius: 15px; padding: 6px 3px 8px; font-size: .72rem; }
  .character-option img { height: 78px; }

  .history-screen { place-items: start center; }
  .history-card { width: 100%; height: auto; min-height: calc(100svh - 14px); display: grid; overflow: visible; border-radius: 24px; padding: 16px 12px 18px; }
  .history-top { grid-template-columns: auto minmax(0,1fr); gap: 8px; }
  .history-mascot { display: none; }
  .history-heading { font-size: 1.42rem; }
  .history-lead { display: none; }
  .history-back-btn { min-height: 44px; padding-inline: 9px; }
  .history-filters { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
  .history-filter { min-height: 36px; }
  .history-challenge-filter { grid-template-columns: 1fr; }
  .history-summary { grid-template-columns: 1fr; }
  .history-metric { min-height: 52px; justify-content: start; padding-inline: 16px; }
  .history-metric + .history-metric { border-top: 2px dashed rgba(127,99,63,.18); border-left: 0; }
  .history-chart-head { align-items: flex-start; flex-direction: column; gap: 2px; }
  .history-trend { text-align: left; }
  .history-chart-stack { grid-template-rows: 245px 210px; }
  .history-chart-label span { display: none; }

  .game { height: auto; min-height: 100svh; grid-template-rows: auto auto 650px 102px; overflow-y: auto; padding: 7px; }
  .game-header { grid-template-columns: minmax(0,1fr) auto; }
  .mode-badge { display: none; }
  .game.daily-challenge .mode-badge { grid-column: 1/-1; display: inline-flex; width: 100%; min-width: 0; }
  .back-btn, .restart-btn { min-height: 44px; padding-inline: 8px; font-size: .72rem; }
  .timer { min-width: 96px; min-height: 44px; }
  .progress-side { grid-template-columns: 1fr; padding: 8px; }
  .progress-summary { min-width: 0; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 7px 0 0; border-top: 2px dashed rgba(118,92,58,.2); border-left: 0; }
  .progress-slot { max-width: 34px; }
  .game.daily-challenge .progress-track { gap: 3px; }
  .game.daily-challenge .progress-slot { height: 20px; }
  .play-stack { grid-template-rows: 250px 390px; }
  .card::before { left: 10px; bottom: 12px; width: 31%; height: 62%; }
  .question { left: 62%; width: 72%; font-size: clamp(3.7rem,17vw,5rem); }
  .card-answer { left: 63%; min-width: 130px; min-height: 70px; font-size: 2.8rem; }
  .feedback { left: 63%; width: 68%; font-size: .7rem; }
  .digit-btn, .clear-btn { min-height: 72px; border-radius: 16px; }
  .side { padding-inline: 6px; }
  .session-metric { grid-template-columns: 30px auto; column-gap: 5px; padding-inline: 5px; }
  .session-metric-icon { width: 28px; height: 28px; }
  .session-metric-value { font-size: .84rem; }
  .celebration-unicorn, .celebration-inner > .image-fallback { bottom: 29%; width: min(62vw,240px); height: 38vh; }
  .celebration-set-time { bottom: 13%; padding: 10px 13px; font-size: .88rem; }
  .challenge-complete-actions { width: calc(100% - 22px); bottom: 3%; }
  .challenge-complete-actions button { min-width: 0; flex: 1; }
  .progress-celebration.challenge-finish .celebration-set-time { bottom: 13%; }
  .progress-celebration.challenge-finish .celebration-unicorn { bottom: 30%; }
}

@media (max-height: 700px) and (min-width: 701px) {
  .game { grid-template-rows: 48px 66px minmax(0,1fr) 78px; gap: 7px; padding-block: 7px; }
  .back-btn, .restart-btn, .mode-badge, .timer { min-height: 42px; }
  .progress-side { padding-block: 5px; }
  .side { padding-block: 4px; }
  .digit-grid { gap: 8px; }
  .answer-panel { gap: 8px; padding: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .celebration-canvas { display: none; }
  .correct-reward-badge.reduced-motion { opacity: 1; transform: none; }
}
