:root {
  --ink: #17233a; --ink2: #3c4d6b; --paper: #fffaf0; --sky: #2f86c4; --sun: #ffcf4a; --red: #e2453c; --leaf: #3f9a5c;
  --card: rgba(255, 255, 255, .92); --line: rgba(23, 35, 58, .14); --shadow: 0 6px 24px rgba(10, 30, 60, .18);
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Hiragino Sans", "PingFang SC", "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --gutter: 16px; --menu-gap: 0px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #bfe4f4; color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { overflow: hidden; overscroll-behavior: none; }
button, a.btn { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #ffb400; outline-offset: 3px; }

/* GameNow 메뉴(오른쪽 가장자리)를 피해 화면 내용을 둔다 */
body:has(#gamenow-exit-launcher):not(.gamenow-mobile-mode) { --menu-gap: 150px; }
body.gamenow-mobile-mode { --menu-gap: 50px; }

.screen { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + max(var(--gutter), var(--menu-gap))) calc(var(--safe-b) + 16px) calc(var(--safe-l) + var(--gutter)); }

/* ---------- 첫 화면 ---------- */
.entry { display: flex; flex-direction: column; align-items: center; background: #a6daf2; }
.entry .poster { position: fixed; inset: 0; z-index: 0; }
.entry .poster svg { width: 100%; height: 100%; display: block; }
.entry > :not(.poster) { position: relative; z-index: 1; }
.topbar { width: 100%; max-width: 720px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 800; letter-spacing: .02em; color: #fff; text-decoration: none; text-shadow: 0 1px 3px rgba(0,0,0,.35); padding: 10px 4px; min-height: 44px; display: inline-flex; align-items: center; }
.top-actions { display: flex; gap: 8px; }
.icon { min-width: 44px; min-height: 44px; border-radius: 14px; border: 1px solid rgba(255,255,255,.6); background: rgba(23,35,58,.42); color: #fff; font-size: 18px; font-weight: 800; display: inline-grid; place-items: center; backdrop-filter: blur(4px); }
.icon:hover { background: rgba(23,35,58,.6); }
.hero { margin: auto 0; width: 100%; max-width: 520px; text-align: center; padding: 18px 18px 22px; border-radius: 28px; background: rgba(255, 252, 244, .86); box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.kicker { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .28em; color: var(--sky); }
h1 { margin: 0; line-height: 1; }
h1 .logo { display: block; font-size: clamp(40px, 12vw, 64px); font-weight: 900; letter-spacing: .02em; color: var(--ink);
  background: linear-gradient(180deg, #ff7d4f 0%, #e2453c 60%, #b8302b 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 0 rgba(255,255,255,.8)); }
h1 .name { display: block; margin-top: 6px; font-size: 18px; font-weight: 800; color: var(--ink2); letter-spacing: .3em; }
.lede { margin: 12px 0 16px; white-space: pre-line; line-height: 1.55; color: var(--ink2); font-size: 15px; }
.primary, .secondary, .ghost { min-height: 48px; border-radius: 16px; padding: 10px 18px; font-weight: 800; border: 0; }
.primary { background: linear-gradient(180deg, #ff8a4c, #e2453c); color: #fff; box-shadow: 0 4px 0 #a92f29, 0 8px 18px rgba(226, 69, 60, .35); font-size: 18px; }
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #a92f29; }
.primary.big { width: 100%; min-height: 60px; font-size: 22px; letter-spacing: .04em; }
.secondary { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.secondary:hover { border-color: var(--sky); }
.ghost { background: transparent; color: var(--ink2); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.note { margin: 8px 0 0; font-size: 13px; color: var(--ink2); }
.note.keys { margin-top: 12px; font-size: 12px; opacity: .8; }
.center { text-align: center; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.row .secondary { padding: 8px 6px; font-size: 14px; }
.foot { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.foot .ghost { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5); font-size: 13px; }

/* ---------- 단계·꾸미기 ---------- */
.panel { background: linear-gradient(180deg, #8fd0f0, #d8f0e8); }
.bar { max-width: 760px; margin: 0 auto 10px; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.bar h2 { margin: 0; text-align: center; font-size: 20px; }
.bar .back { color: var(--ink); background: rgba(255,255,255,.7); }
.pill { padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.8); font-weight: 800; font-size: 14px; white-space: nowrap; }
.tabs { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tabs button { min-height: 48px; border-radius: 14px; border: 2px solid transparent; background: rgba(255,255,255,.65); font-weight: 800; font-size: 14px; padding: 6px; }
.tabs button[aria-selected="true"] { background: #fff; border-color: var(--rc, var(--sky)); box-shadow: 0 3px 0 var(--rc, var(--sky)); }
.tabs button[data-locked] { opacity: .6; }
.grid { list-style: none; padding: 0; margin: 10px auto 24px; max-width: 760px; display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.grid button { width: 100%; min-height: 78px; border-radius: 16px; border: 0; background: #fff; box-shadow: 0 3px 0 rgba(23,35,58,.16); display: grid; place-items: center; padding: 6px 4px; gap: 2px; }
.grid button b { font-size: 20px; }
.grid button small { font-size: 11px; color: var(--ink2); line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid button .stars { font-size: 14px; letter-spacing: 1px; color: #d5d9e0; }
.grid button .stars i { font-style: normal; }
.grid button .stars i.on { color: #f2b51d; }
.grid button:disabled { background: rgba(255,255,255,.45); box-shadow: none; cursor: not-allowed; }
.grid button:disabled b::after { content: ' 🔒'; font-size: 12px; }
.grid button.next { outline: 3px solid var(--rc, var(--sky)); }
.style-body { max-width: 760px; margin: 0 auto; display: grid; gap: 12px; }
.style-view { width: 100%; height: min(36vh, 260px); border-radius: 20px; background: #a6daf2; box-shadow: var(--shadow); }
.slots { display: grid; gap: 10px; padding-bottom: 20px; }
.slot h3 { margin: 4px 2px 6px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: #fff; padding: 6px 12px; font-weight: 700; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.chips button[aria-pressed="true"] { border-color: var(--red); box-shadow: 0 2px 0 var(--red); }
.chips button:disabled { opacity: .55; cursor: not-allowed; font-weight: 500; font-size: 12px; }
.chips .sw { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); }

/* ---------- 게임 화면 ---------- */
#game { position: fixed; inset: 0; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 8px) 0 calc(var(--safe-l) + 8px); display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud .where { pointer-events: none; display: flex; flex-direction: column; min-width: 0; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.55); line-height: 1.15; }
#hud .where small { font-weight: 800; font-size: 12px; opacity: .9; }
#hud .where span { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hud .meters { pointer-events: none; display: flex; gap: 6px; }
#hud .meter { min-width: 64px; padding: 4px 10px; border-radius: 12px; background: rgba(15,22,40,.45); color: #fff; text-align: right; backdrop-filter: blur(3px); }
#hud .meter small { display: block; font-size: 10px; font-weight: 700; opacity: .8; }
#hud .meter b { font-size: 17px; font-variant-numeric: tabular-nums; }
#hud .meter b.good { color: #ffe27a; }
#coach { position: absolute; left: calc(var(--safe-l) + 10px); bottom: calc(var(--safe-b) + 14px); max-width: min(320px, calc(100vw - 20px - var(--menu-gap))); padding: 10px 12px; border-radius: 16px; background: rgba(15,22,40,.72); color: #fff; font-size: 13px; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; pointer-events: none; backdrop-filter: blur(4px); }
#coach.show { opacity: 1; transform: none; }
#coach b { display: block; font-size: 12px; letter-spacing: .1em; opacity: .8; margin-bottom: 6px; }
#coach ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#coach li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; transition: opacity .3s; }
#coach li.done { opacity: .45; }
#coach li.done em::after { content: ' ✓'; color: #7dff9b; }
#coach kbd { font: 800 12px var(--font); padding: 4px 8px; border-radius: 8px; background: #fff; color: var(--ink); white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
#coach em { font-style: normal; font-weight: 800; display: block; }
#coach small { display: block; opacity: .75; font-size: 11px; }
#bubble { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); padding: 8px 14px; border-radius: 14px; background: #fff; color: var(--ink); font-weight: 900; font-size: 18px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s; white-space: nowrap; }
#bubble.show { opacity: 1; }
#bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: #fff; }
#banner { position: absolute; left: 50%; top: calc(var(--safe-t) + 96px); max-width: calc(100vw - 32px); transform: translate(-50%, 0) scale(.9); padding: 8px 18px; border-radius: 18px; background: rgba(15,22,40,.66); color: #fff; font-weight: 900; font-size: clamp(18px, 5.5vw, 26px); text-align: center; white-space: nowrap; transform-origin: 50% 0; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
#banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#banner small { display: block; font-size: 13px; font-weight: 700; opacity: .85; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(166,218,242,.9); }
#loading i { width: 42px; height: 42px; border-radius: 50%; border: 5px solid rgba(23,35,58,.15); border-top-color: var(--red); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 창 ---------- */
dialog#sheet { width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; border: 0; border-radius: 24px; padding: 20px 18px 16px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog#sheet::backdrop { background: rgba(10, 18, 34, .5); backdrop-filter: blur(2px); }
#sheet h2 { margin: 0 0 10px; text-align: center; font-size: 24px; }
#sheet p { line-height: 1.55; }
#sheet .btns { display: grid; gap: 8px; margin-top: 14px; }
#sheet .btns.two { grid-template-columns: 1fr 1fr; }
#sheet .btns.two button { font-size: 15px; padding-inline: 8px; }
#sheet .small { font-size: 13px; color: var(--ink2); }
#sheet dl { margin: 0; display: grid; gap: 4px 10px; grid-template-columns: auto 1fr; }
#sheet dt { font-weight: 800; }
#sheet dd { margin: 0 0 6px; white-space: pre-line; font-size: 14px; line-height: 1.5; }
#sheet ul { padding-left: 18px; line-height: 1.6; font-size: 13px; }
.stars3 { display: flex; justify-content: center; gap: 10px; margin: 6px 0 10px; }
.stars3 .s { width: 64px; display: grid; justify-items: center; gap: 4px; font-size: 11px; color: var(--ink2); text-align: center; line-height: 1.25; }
.stars3 .s i { font-style: normal; font-size: 44px; line-height: 1; color: #dfe3ea; transform: scale(.6); transition: transform .3s cubic-bezier(.3,1.8,.5,1), color .2s; }
.stars3 .s.on i { color: #f2b51d; transform: scale(1); text-shadow: 0 3px 0 #c98a14; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0; }
.stats div { background: #fff; border-radius: 14px; padding: 8px 4px; text-align: center; border: 1px solid var(--line); }
.stats strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--ink2); }
.badge { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 8px; background: #ffe27a; color: #6b4a00; font-size: 10px; font-weight: 800; vertical-align: middle; }
.hint { margin: 8px 0 0; padding: 8px 10px; border-radius: 12px; background: #eef6ff; font-size: 13px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 18px); transform: translate(-50%, 20px); max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 14px; background: rgba(15,22,40,.86); color: #fff; font-size: 14px; font-weight: 700; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.pad-hint { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 6px); transform: translateX(-50%); padding: 4px 10px; border-radius: 10px; background: rgba(15,22,40,.7); color: #fff; font-size: 12px; z-index: 40; pointer-events: none; }
body[data-playing] .pad-hint { display: none; }

@media (max-width: 380px) { .row { grid-template-columns: 1fr 1fr; } .row .secondary:last-child { grid-column: span 2; } .hero { padding: 14px 12px 16px; } .lede { font-size: 14px; } }
@media (max-height: 520px) and (orientation: landscape) {
  .entry { justify-content: flex-start; }
  .hero { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; text-align: left; max-width: 760px; padding: 12px 16px; margin: 6px 0; align-items: center; }
  .hero .kicker, .hero h1, .hero .lede { grid-column: 1; }
  .hero .lede { margin: 6px 0; font-size: 13px; }
  .hero #play, .hero #play-note, .hero .row, .hero .keys { grid-column: 2; }
  .hero #play { grid-row: 1 / span 2; align-self: end; }
  .hero .row { margin-top: 4px; }
  h1 .logo { font-size: 40px; }
  .foot { margin-top: 4px; }
  #hud .where span { font-size: 13px; }
  .style-body { grid-template-columns: 1fr 1fr; align-items: start; }
  .style-view { height: 60vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
@media (max-width: 480px) { #hud .where small .rg { display: none; } #hud .meter { min-width: 56px; padding: 3px 8px; } #hud .meter b { font-size: 15px; } #coach { font-size: 12px; padding: 8px 10px; } }
