:root {
  --bg: #fff8e7;
  --card: #ffffff;
  --ink: #2b2240;
  --muted: #8a7f9e;
  --line: #f0e3c4;
  --yellow: #ffcf4a;
  --pink: #ff6b9d;
  --brand: #d4a77f;
  --brand-dark: #a87a52;
  --blue: #4d96ff;
  --green: #2ec27e;
  --red: #ff5a5f;
  --shadow: 0 4px 0 rgba(43, 34, 64, 0.12);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(circle at 10% 10%, #ffe9b3 0 60px, transparent 61px), radial-gradient(circle at 90% 30%, #ffd9e8 0 80px, transparent 81px);
  color: var(--ink);
  font-family: "Jua", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 17px;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.screen { width: min(100%, 560px); margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }

/* 홈 */
.hero { text-align: center; padding: 18px 0 8px; }
.logo { width: 120px; height: 120px; border-radius: 50%; background: #fff; box-shadow: 0 6px 0 rgba(212, 167, 127, 0.45), 0 10px 24px rgba(0, 0, 0, 0.1); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-6deg); } }
.hero h1 { margin: 8px 0 0; font-size: 34px; font-weight: 400; color: var(--brand-dark); text-shadow: 2px 2px 0 #fff; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.grade { display: flex; gap: 8px; margin: 18px 0 14px; background: #fff; padding: 6px; border-radius: 20px; box-shadow: var(--shadow); }
.grade button { flex: 1; border: 0; background: transparent; border-radius: 15px; padding: 12px 6px; font-size: 18px; color: var(--muted); }
.grade button.on { background: var(--brand); color: #fff; }
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button { flex: none; border: 0; background: #fff; border-radius: 999px; padding: 9px 16px; font-size: 16px; box-shadow: var(--shadow); color: var(--muted); }
.cats button small { margin-left: 6px; font-size: 12px; background: #f4efe4; border-radius: 99px; padding: 1px 7px; color: var(--muted); }
.cats button.on { background: var(--ink); color: #fff; }
.cats button.on small { background: rgba(255, 255, 255, 0.2); color: #fff; }
.cards { display: grid; gap: 12px; }
.gcard { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: var(--card); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); transition: transform 0.1s; }
.gcard:active { transform: scale(0.97); }
.gemoji { font-size: 38px; width: 58px; height: 58px; display: grid; place-items: center; background: #fff4d6; border-radius: 16px; flex: none; }
.gtext { flex: 1; display: flex; flex-direction: column; }
.gtext b { font-weight: 400; font-size: 20px; }
.gtext small { color: var(--muted); font-size: 14px; margin-top: 2px; }
.gstars { color: #ffb400; font-size: 18px; letter-spacing: 1px; flex: none; }
.gstars.none { color: #e2d9c4; }
.tip { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }
.copy { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--brand-dark); font-size: 13px; margin-top: 20px; }
.copy img { border-radius: 50%; }
.copy.small { font-size: 11px; opacity: 0.7; margin-top: 26px; }

/* 게임 상단 */
.bar { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: #fff; box-shadow: var(--shadow); font-size: 22px; }
.bar-title { flex: 1; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { background: #fff; border-radius: 14px; padding: 8px 12px; box-shadow: var(--shadow); font-size: 16px; }
.combo { color: #ff7a00; }
.progress { height: 12px; background: #fff; border-radius: 99px; margin: 12px 0 14px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08); }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--yellow), var(--pink)); border-radius: 99px; transition: width 0.3s; }

.stage { text-align: center; }
.ask { font-size: 21px; margin: 6px 0 12px; }
.ask b { color: var(--pink); font-weight: 400; }
.big-ask { font-size: 26px; }
.big-ask b { font-size: 34px; }
.sub-ask { color: var(--muted); font-size: 15px; min-height: 1em; }
.staff, .card-q { background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 6px; margin: 0 auto 12px; }
.staff svg, .card-q svg { display: block; width: 100%; height: auto; max-height: 260px; }
.staff.rhythm svg { max-height: 150px; }
.hint-toggle { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 15px; margin-bottom: 10px; }

.btn { border: 0; border-radius: 16px; padding: 12px 20px; background: #fff; box-shadow: var(--shadow); font-size: 18px; }
.btn.primary { background: var(--pink); color: #fff; }
.btn.ghost { background: #fff; }
.btn:disabled { opacity: 0.45; }
.btn:active, .choices button:active, .solfa button:active { transform: translateY(2px); box-shadow: none; }
.start { display: block; margin: 16px auto 0; font-size: 22px; padding: 16px 34px; }

/* 계이름 버튼 */
.solfa { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.solfa button { border: 0; border-radius: 14px; padding: 16px 0; font-size: 22px; background: var(--c); color: #fff; box-shadow: var(--shadow); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25); }
@media (max-width: 420px) { .solfa button { font-size: 19px; padding: 14px 0; } }

/* 보기 버튼 */
.choices { display: grid; gap: 10px; margin-top: 12px; grid-template-columns: repeat(2, 1fr); }
.choices.c3 { grid-template-columns: repeat(3, 1fr); }
.choices.c4 { grid-template-columns: repeat(4, 1fr); }
.choices button { border: 0; border-radius: 16px; padding: 16px 8px; background: #fff; box-shadow: var(--shadow); font-size: 18px; line-height: 1.3; }
.good { background: var(--green) !important; color: #fff !important; animation: pop 0.3s; }
.bad { background: var(--red) !important; color: #fff !important; animation: shake 0.35s; }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* 높낮이 */
.speakers { display: flex; justify-content: center; gap: 28px; margin: 10px 0 14px; }
.spk { width: 110px; height: 110px; border-radius: 30px; background: #fff; box-shadow: var(--shadow); display: grid; place-items: center; font-size: 40px; position: relative; transition: transform 0.15s, background 0.15s; }
.spk span { position: absolute; bottom: 8px; font-size: 18px; color: var(--muted); }
.spk.on { background: var(--yellow); transform: scale(1.12); }

/* 리듬 */
.marks { min-height: 32px; font-size: 22px; display: flex; gap: 6px; justify-content: center; align-items: center; }
.marks .no { color: var(--red); font-size: 16px; }
.rbtns { display: flex; gap: 10px; justify-content: center; margin: 6px 0 14px; }
.pad { width: min(78vw, 260px); height: min(78vw, 260px); border-radius: 50%; border: 0; background: radial-gradient(circle at 40% 35%, #ffe08a, #ffb627 60%, #f08c00); box-shadow: 0 8px 0 #c86f00, 0 12px 20px rgba(0, 0, 0, 0.15); font-size: 70px; display: grid; place-items: center; align-content: center; touch-action: none; }
.pad small { font-size: 15px; color: #7a4a00; }
.pad.live { outline: 6px solid rgba(255, 107, 157, 0.55); }
.pad.hit { animation: hit 0.12s; }
@keyframes hit { 50% { transform: scale(0.94); box-shadow: 0 3px 0 #c86f00; } }

/* 건반 따라치기 */
.level { font-size: 18px; color: var(--muted); margin-bottom: 10px; }
.keys { display: grid; gap: 6px; height: 240px; }
.keys.k5 { grid-template-columns: repeat(5, 1fr); }
.keys.k8 { grid-template-columns: repeat(8, 1fr); }
.keys button { border: 0; border-radius: 0 0 14px 14px; background: #fff; box-shadow: var(--shadow), inset 0 -10px 0 var(--c); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 18px; font-size: 20px; touch-action: none; }
.keys button.lit { background: var(--c); color: #fff; transform: translateY(3px); }

/* 건반 찾기 */
.piano { position: relative; height: 210px; margin: 14px 0 8px; }
.piano .w { position: relative; width: 10%; height: 100%; float: left; border: 2px solid #d9cfb8; border-radius: 0 0 10px 10px; background: #fff; margin: 0; touch-action: none; }
.piano .b { position: absolute; top: 0; width: 6.4%; height: 60%; border: 0; border-radius: 0 0 8px 8px; background: #2b2240; z-index: 2; touch-action: none; }

/* 기호 */
.sym { font-size: 110px; line-height: 1.1; padding: 16px 0; font-family: "Times New Roman", Georgia, serif; }
.sym-it { font-style: italic; font-weight: 700; }
.sym-acc { font-size: 120px; }
.sym-word { font-size: 56px; font-style: italic; }
.sym-svg { width: 70%; margin: 30px auto; display: block; }
.ear-ico { font-size: 90px; padding: 20px 0; animation: bob 1.6s ease-in-out infinite; }
.extra { margin-bottom: 4px; }

/* 알림 */
.toast { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none; background: #fff; padding: 14px 24px; border-radius: 20px; font-size: 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); transition: all 0.2s; z-index: 20; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.good { color: var(--green); }
.toast.bad { color: var(--red); font-size: 20px; }

/* 결과 */
.result-card { background: #fff; border-radius: 28px; box-shadow: var(--shadow); text-align: center; padding: 30px 18px; margin-top: 40px; }
.stars.big { font-size: 64px; letter-spacing: 6px; }
.stars.big span { color: #e8e0cc; display: inline-block; }
.stars.big span.on { color: #ffb400; animation: star 0.5s both; }
@keyframes star { from { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } to { transform: scale(1); } }
.result-card h2 { font-weight: 400; font-size: 26px; margin: 10px 0 6px; }
.result-card p { color: var(--muted); margin: 0 0 20px; line-height: 1.6; }
.result-btns { display: flex; gap: 10px; justify-content: center; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -40px; font-size: 26px; font-style: normal; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }

/* 놀이 시간 */
.timer-line { text-align: center; color: var(--brand-dark); font-size: 16px; margin-top: 10px; }
.timer-line b { font-weight: 400; font-size: 20px; color: var(--pink); }
.gtimer { font-size: 15px; color: var(--brand-dark); white-space: nowrap; }
.gtimer.warn { color: var(--red); animation: pop 1s infinite; }
.moon { font-size: 70px; }
.pin-box { margin-top: 10px; }
.pin-label { font-size: 18px; color: var(--brand-dark); }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 14px 0 6px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--brand); }
.pin-dots i.on { background: var(--brand); }
.pin-dots.shake { animation: shake 0.35s; }
.pin-msg { min-height: 22px; font-size: 15px; color: var(--muted); }
.pin-msg.bad { color: var(--red); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; justify-content: center; margin-top: 8px; }
.pin-pad button { height: 64px; border: 0; border-radius: 18px; background: #fff4e6; box-shadow: var(--shadow); font-size: 26px; }
.pin-pad button:active { transform: translateY(2px); box-shadow: none; }
.pin-pad button.blank { visibility: hidden; }

/* 아이패드·넓은 화면: 카드 2열, 큰 버튼 */
@media (min-width: 700px) {
  .cats { justify-content: center; }
  .cats button { font-size: 19px; padding: 11px 20px; }
  body { font-size: 19px; }
  .screen { width: min(100%, 920px); padding: 24px 28px 32px; }
  .logo { width: 150px; height: 150px; }
  .hero h1 { font-size: 44px; }
  .grade { max-width: 560px; margin-left: auto; margin-right: auto; }
  .grade button { font-size: 22px; padding: 16px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 16px; }
  .gcard { padding: 18px; }
  .gemoji { width: 72px; height: 72px; font-size: 46px; }
  .gtext b { font-size: 24px; }
  .gtext small { font-size: 16px; }
  .stage { max-width: 760px; margin: 0 auto; }
  .ask { font-size: 26px; }
  .staff svg, .card-q svg { max-height: 330px; }
  .solfa { gap: 10px; }
  .solfa button { font-size: 30px; padding: 24px 0; border-radius: 18px; }
  .choices button { font-size: 22px; padding: 22px 10px; }
  .spk { width: 150px; height: 150px; font-size: 56px; }
  .pad { width: 320px; height: 320px; font-size: 90px; }
  .keys { height: 320px; }
  .keys button { font-size: 26px; }
  .piano { height: 280px; }
  .btn { font-size: 21px; padding: 14px 26px; }
  .bar-title { font-size: 24px; }
  .toast { font-size: 30px; }
}

/* 선생님 초기화 */
.reset-btn { display: block; margin: 14px auto 0; border: 2px dashed var(--brand); background: transparent; color: var(--brand-dark); border-radius: 14px; padding: 10px 18px; font-size: 15px; }
.modal { position: fixed; inset: 0; background: rgba(43, 34, 64, 0.45); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { position: relative; background: #fff; border-radius: 26px; padding: 26px 20px 22px; text-align: center; width: min(100%, 380px); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.modal-card h3 { margin: 0; font-weight: 400; font-size: 24px; }
.muted-p { color: var(--muted); font-size: 15px; margin: 6px 0 10px; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border: 0; border-radius: 12px; background: #f4efe4; font-size: 18px; }
