/* style.css — 빙글스텝 화면 (글자·단추 = DOM · 무대 = 캔버스) · 색 토큰은 키트 --gb-* 만 덮는다 */
:root {
  --gb-bg: #13263d;
  --gb-panel: rgba(255, 255, 255, 0.08);
  --gb-panel-2: rgba(255, 255, 255, 0.14);
  --gb-line: rgba(255, 255, 255, 0.16);
  --gb-text: #f6f9ff;
  --gb-dim: rgba(246, 249, 255, 0.68);
  --gb-accent: #ffcf4d;
  --gb-accent-ink: #3a2400;
  --gb-gold: #ffd34d;
  --p0: #ff6b6b; --p1: #4dabf7; --p2: #69db7c; --p3: #ffa94d; --p4: #b197fc; --p5: #f783ac;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--gb-bg); color: var(--gb-text); font-family: var(--gb-font); overflow: hidden;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font-family: inherit; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#tapLayer { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; display: none; }
body[data-screen="hud"] #tapLayer { display: block; }
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.ic { width: 1.2em; height: 1.2em; vertical-align: -0.22em; }
.gb-icon .ic { width: 22px; height: 22px; }

/* 화면 공통 */
.screen { position: absolute; inset: 0; overflow-y: auto; padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); z-index: 10; }
#home { background: linear-gradient(180deg, rgba(19, 38, 61, 0.72) 0%, rgba(19, 38, 61, 0.35) 55%, rgba(19, 38, 61, 0.78) 100%); }
.gb-brand .brand-mark { width: 34px; height: 34px; border-radius: 50%; background: conic-gradient(#e8463b 0 20%, #f7c531 0 40%, #4cb050 0 60%, #2f7fd8 0 80%, #8a4fc1 0); box-shadow: 0 0 0 3px rgba(255,255,255,.85) inset; }
.home-next { margin: -4px 0 0; text-align: center; font-size: 13px; color: var(--gb-dim); }
.panel { max-width: 720px; margin: 0 auto; background: rgba(13, 27, 45, 0.86); border: 1px solid var(--gb-line); border-radius: 20px; padding: 12px 14px 18px; backdrop-filter: blur(6px); }
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; min-height: 48px; }
.bar h2 { margin: 0; font-size: 20px; flex: 1; }
.wallet { font-weight: 800; color: var(--gb-gold); font-size: 15px; }
.gb-icon.back::before { content: ''; width: 12px; height: 12px; border-left: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: rotate(45deg); margin-left: 4px; }
.btn { min-height: 48px; border-radius: 14px; border: 1px solid var(--gb-line); background: var(--gb-panel-2); color: var(--gb-text); font: 700 15px var(--gb-font); padding: 0 16px; cursor: pointer; }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row > * { flex: 1; }
.dim { color: var(--gb-dim); }
.seg { display: inline-flex; background: var(--gb-panel); border: 1px solid var(--gb-line); border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { min-height: 44px; min-width: 64px; border: 0; border-radius: 11px; background: transparent; color: var(--gb-dim); font: 800 15px var(--gb-font); cursor: pointer; padding: 0 12px; }
.seg button[aria-checked="true"] { background: var(--gb-accent); color: var(--gb-accent-ink); }
.opts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.stars { display: inline-flex; gap: 1px; }
.stars .ic { width: 16px; height: 16px; }
.stars .on { color: var(--gb-gold); }
.stars .off { color: rgba(255,255,255,.35); }
.ic.gold { color: var(--gb-gold); }

/* 여정 지도 */
.worlds { display: flex; flex-direction: column; gap: 10px; }
.world { border-radius: 16px; padding: 10px; background: linear-gradient(135deg, color-mix(in srgb, var(--sky) 38%, #13263d), color-mix(in srgb, var(--ground) 30%, #13263d)); border: 1px solid var(--gb-line); }
.world-head b { font-size: 16px; }
.world-head small { display: block; color: var(--gb-dim); font-size: 12.5px; margin: 2px 0 8px; }
.stage-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stage { min-height: 88px; border-radius: 14px; border: 1px solid var(--gb-line); background: rgba(0,0,0,.22); color: var(--gb-text); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 4px; }
.st-n { font-weight: 900; font-size: 15px; }
.st-t { font-size: 12px; color: var(--gb-dim); text-align: center; line-height: 1.2; }

/* 곡 목록 */
.song-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.song { min-height: 88px; text-align: left; border-radius: 14px; border: 1px solid var(--gb-line); background: var(--gb-panel); color: var(--gb-text); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.sg-t { font-weight: 800; font-size: 15.5px; }
.sg-g { font-size: 12.5px; color: var(--gb-dim); }
.sg-b { font-size: 12.5px; color: var(--gb-gold); }
.sg-b.new { color: var(--gb-dim); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.rule { min-height: 96px; border-radius: 16px; border: 1px solid var(--gb-line); background: var(--gb-panel); color: var(--gb-text); text-align: left; padding: 12px 14px; cursor: pointer; }
.rule b { display: block; font-size: 17px; margin-bottom: 4px; }
.rule small { color: var(--gb-dim); font-size: 13px; }

/* 판 HUD */
.hud { pointer-events: none; padding: max(10px, env(safe-area-inset-top)) 12px; overflow: hidden; }
.hud button { pointer-events: auto; }
.hud-top { display: flex; align-items: center; gap: 10px; }
.hud-mid { flex: 1; min-width: 0; text-align: center; }
.hud-title { font-weight: 800; font-size: 15px; text-shadow: 0 2px 6px rgba(0,0,0,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog { height: 6px; border-radius: 4px; background: rgba(0,0,0,.3); margin-top: 6px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--gb-accent); border-radius: 4px; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.hud-acc { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.hud-modebar { font-size: 14px; }
.count { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font: 900 96px var(--gb-font); color: #fff; text-shadow: 0 6px 20px rgba(0,0,0,.45); }
.count.go { animation: countpop .5s ease-out; }
@keyframes countpop { from { transform: scale(1.6); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); } }
.hint { position: absolute; left: 16px; right: 16px; top: 74px; text-align: center; font-weight: 800; font-size: 16px; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.heat { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(60vw, 320px); height: 14px; border-radius: 8px; background: rgba(0,0,0,.35); overflow: hidden; }
.heat i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff8a5b, #ffd34d); transition: width .12s; }
.heat i.on { background: linear-gradient(90deg, #ffd34d, #fff6c2, #ffd34d); animation: heatglow .6s infinite alternate; }
@keyframes heatglow { to { filter: brightness(1.3); } }
.heat span { position: absolute; inset: 0; font-size: 10.5px; font-weight: 800; text-align: center; line-height: 14px; color: rgba(255,255,255,.85); }
.combo { position: absolute; right: 18px; bottom: 44px; transform-origin: 100% 100%; display: flex; flex-direction: column; align-items: center; line-height: .9; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; --c: #fff; color: var(--c); }
.combo.on { opacity: 1; transform: scale(1); }
.combo b { font: 900 44px var(--gb-font); text-shadow: 0 3px 0 rgba(0,0,0,.45), 0 0 18px var(--c); }
.combo small { font-weight: 900; font-size: 14px; letter-spacing: .1em; text-shadow: 0 2px 4px rgba(0,0,0,.6); }
.combo[data-tier="1"] { --c: #ffd34d; } .combo[data-tier="1"] b { font-size: 52px; }
.combo[data-tier="2"] { --c: #ff9a3c; } .combo[data-tier="2"] b { font-size: 60px; }
.combo[data-tier="3"] { --c: #ff5fa2; } .combo[data-tier="3"] b { font-size: 68px; }
.combo[data-tier="4"] b { font-size: 76px; }
/* 50 연속부터 숫자가 무지개로 흐른다 · 100 연속은 더 빠르게 */
.combo[data-tier="3"] b, .combo[data-tier="4"] b { background: linear-gradient(90deg, #ff6b6b, #ffd34d, #8be36b, #6bd1ff, #c08bff, #ff6b6b); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)) drop-shadow(0 0 10px #fff8); animation: comboRain 1.2s linear infinite; }
.combo[data-tier="4"] { --c: #fff6c2; } .combo[data-tier="4"] b { animation-duration: .6s; }
@keyframes comboRain { to { background-position: 200% 0; } }
/* 끊김 — 깨져서 떨어진다 */
.combo.break { animation: comboBreak .7s ease-in forwards; }
.combo.break b { color: #ff7b7b; background: none; -webkit-background-clip: border-box; background-clip: border-box; filter: none; text-shadow: 0 3px 0 rgba(0,0,0,.45); }
@keyframes comboBreak { 0% { transform: translateX(0) rotate(0); opacity: 1; } 15% { transform: translateX(-8px) rotate(-6deg); } 30% { transform: translateX(8px) rotate(6deg); } 45% { transform: translateX(-4px) rotate(-3deg); opacity: 1; } 100% { transform: translateY(70px) rotate(24deg) scale(.7); opacity: 0; } }
/* 화면 테두리 빛 — 연속 단계 색으로 맞힐 때마다 숨쉰다 */
.aura { position: absolute; inset: 0; pointer-events: none; opacity: 0; --c: #ffd34d; box-shadow: inset 0 0 60px 16px var(--c); transition: opacity .3s; }
.aura[data-tier="1"] { opacity: .35; --c: #ffd34d; } .aura[data-tier="2"] { opacity: .5; --c: #ff9a3c; } .aura[data-tier="3"] { opacity: .6; --c: #ff5fa2; } .aura[data-tier="4"] { opacity: .7; --c: #fff1a8; }
.aura.beat { animation: auraBeat .32s ease-out; }
@keyframes auraBeat { from { box-shadow: inset 0 0 110px 34px var(--c); } to { box-shadow: inset 0 0 60px 16px var(--c); } }
@media (prefers-reduced-motion: reduce) { .aura.beat, .combo.break, .combo b { animation: none !important; } }
.turn { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); padding: 8px 18px; border-radius: 999px; font-weight: 900; font-size: 20px; background: rgba(0,0,0,.45); white-space: nowrap; }
.turn.dok { background: #2f8f86; }
.turn.me { background: #c2410c; }
.turn.p0 { background: var(--p0); } .turn.p1 { background: var(--p1); } .turn.p2 { background: var(--p2); color: #10301a; } .turn.p3 { background: var(--p3); } .turn.p4 { background: var(--p4); } .turn.p5 { background: var(--p5); }
.relay-who { padding: 1px 8px; border-radius: 8px; color: #fff; }
.relay-who.p0 { background: var(--p0); } .relay-who.p1 { background: var(--p1); } .relay-who.p2 { background: var(--p2); color: #10301a; } .relay-who.p3 { background: var(--p3); } .relay-who.p4 { background: var(--p4); } .relay-who.p5 { background: var(--p5); }
.duo-labels { position: absolute; left: 0; right: 0; top: 70px; display: flex; justify-content: space-around; font-weight: 900; font-size: 18px; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.duo-labels small { display: block; font-size: 11.5px; font-weight: 700; color: var(--gb-dim); text-align: center; }
body.duo #app::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: rgba(255,255,255,.75); z-index: 5; pointer-events: none; }
body.big .hud-title { font-size: 22px; } body.big .hud-acc { font-size: 30px; } body.big .count { font-size: 150px; } body.big .gbj-pop { font-size: 1.6em; }

/* 모달 */
.modal { display: flex; align-items: center; justify-content: center; background: rgba(8, 16, 28, 0.55); z-index: 20; }
.card { width: min(440px, 100%); background: rgba(16, 32, 52, 0.96); border: 1px solid var(--gb-line); border-radius: 22px; padding: 20px 18px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.card h2 { margin: 6px 0 12px; font-size: 21px; }
.card .gb-play { width: 100%; }
.res-stars .ic { width: 44px; height: 44px; }
.res-grade { display: flex; align-items: baseline; justify-content: center; gap: 12px; }
.res-grade b { font: 900 52px var(--gb-font); color: var(--gb-gold); }
.res-grade span { font-size: 18px; font-weight: 800; }
.res-verdict { margin: 6px 0 10px; color: var(--gb-dim); }
.res-counts { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.cnt { flex: 1; background: var(--gb-panel); border-radius: 12px; padding: 6px 2px; }
.cnt b { display: block; font-size: 20px; color: var(--c); }
.cnt small { font-size: 12px; color: var(--gb-dim); }
.res-line { margin: 6px 0; font-weight: 700; }
.res-line.big { font-size: 22px; color: var(--gb-gold); }
.res-line.new { color: var(--gb-gold); }
.res-tip { font-size: 13.5px; color: var(--gb-dim); }
.duo-res { display: flex; gap: 8px; }
.duo-res span { flex: 1; background: var(--gb-panel); border-radius: 12px; padding: 8px; }
.relay-tab { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 15px; }
.relay-tab th { color: var(--gb-dim); font-weight: 700; font-size: 12.5px; }
.relay-tab td, .relay-tab th { padding: 5px; }
.relay-tab tr.mvp td { color: var(--gb-gold); font-weight: 800; }
.gb-link { background: none; border: 0; color: var(--gb-accent); font: 700 14px var(--gb-font); text-decoration: underline; cursor: pointer; min-height: 44px; }

/* 박자 맞추기 */
.cal-pad { height: 150px; border-radius: 18px; background: var(--gb-panel); border: 1px dashed var(--gb-line); display: flex; align-items: center; justify-content: center; position: relative; touch-action: none; margin: 10px 0; cursor: pointer; }
.cal-pad b { position: absolute; bottom: 10px; font-size: 14px; color: var(--gb-dim); }
.cal-dot { width: 64px; height: 64px; border-radius: 50%; background: var(--gb-accent); opacity: .5; }
.cal-dot.go { animation: calgo .25s ease-out; }
@keyframes calgo { from { transform: scale(1.4); opacity: 1; } to { transform: scale(1); opacity: .5; } }

/* 설정 · 만든 사람 */
.set-body { display: flex; flex-direction: column; gap: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--gb-panel); border-radius: 14px; padding: 10px 12px; flex-wrap: wrap; }
.set-row label { font-weight: 800; display: block; }
.set-row small { color: var(--gb-dim); font-size: 12.5px; }
.set-row input[type=range] { width: min(240px, 50vw); height: 44px; accent-color: var(--gb-accent); }
.credit-body { font-size: 14.5px; line-height: 1.55; }
.credit-body h3 { margin: 14px 0 4px; font-size: 16px; }
.credit-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.credit-list li b { margin-right: 8px; }
.credit-list small { color: var(--gb-dim); }

/* 불러오기 · 알림 */
.loading { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(8, 16, 28, 0.6); }
.spin { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255,255,255,.2); border-top-color: var(--gb-accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 45; background: rgba(0,0,0,.75); padding: 10px 16px; border-radius: 12px; font-weight: 700; max-width: 90vw; text-align: center; }
@media (min-width: 900px) { .gb-home { max-width: 520px; } }
/* @gb-juice-css v2 — kit/juice/juice.css. 게임 스타일시트 끝에 그대로 붙인다(CSP style-src 'self' 라 JS 가 <style> 을 넣지 않는다). */
.gbj-layer{position:fixed;inset:0;pointer-events:none;z-index:40;overflow:hidden}
.gbj-pop{position:absolute;transform:translate(-50%,-50%) scale(var(--s));font:900 22px/1 system-ui,sans-serif;text-shadow:0 2px 0 #0008,0 0 12px currentColor;white-space:nowrap;animation:gbjPop .9s cubic-bezier(.2,1.6,.4,1) forwards}
@keyframes gbjPop{0%{opacity:0;transform:translate(-50%,-50%) scale(calc(var(--s)*.3))}15%{opacity:1;transform:translate(-50%,-80%) scale(calc(var(--s)*1.35))}35%{transform:translate(calc(-50% + var(--dx)),-120%) scale(var(--s))}100%{opacity:0;transform:translate(calc(-50% + var(--dx)),-260%) scale(calc(var(--s)*.9))}}
.gbj-punch{animation:gbjPunch .32s cubic-bezier(.2,2,.4,1)}
@keyframes gbjPunch{0%{transform:scale(1)}30%{transform:scale(var(--gbj-p))}100%{transform:scale(1)}}
.gbj-flash{position:absolute;inset:0;opacity:0}
.gbj-flash.gbj-go{animation:gbjFlash .35s ease-out forwards}
@keyframes gbjFlash{to{opacity:0}}
/* 가운데 큰 글자 — 자리는 게임이 --gbj-banner-top 으로 옮긴다(HUD 배너·선택 카드와 겹치지 않게 · 2026-10-12 끝까지 진화 실측). 좁은 화면에서 넘치지 않게 vw 로 줄인다  · 튀어나올 때 1.25배라 폭은 76vw(2026-10-14 술래가 번진다: 92vw 면 412px 폰에서 양옆이 잘렸다 — banner-fit 실측) */
.gbj-banner{position:absolute;left:50%;top:var(--gbj-banner-top,40%);transform:translate(-50%,-50%);font:900 clamp(20px,6.4vw,40px)/1.1 system-ui,sans-serif;text-align:center;opacity:0;text-shadow:0 3px 0 #000a,0 0 24px currentColor;max-width:76vw;width:max-content}
.gbj-banner.gbj-go{animation:gbjBan var(--d,1.4s) cubic-bezier(.2,1.5,.4,1) forwards}
@keyframes gbjBan{0%{opacity:0;transform:translate(-50%,-50%) scale(.2) rotate(-8deg)}15%{opacity:1;transform:translate(-50%,-50%) scale(1.25) rotate(2deg)}30%{transform:translate(-50%,-50%) scale(1)}80%{opacity:1}100%{opacity:0;transform:translate(-50%,-70%) scale(1.05)}}
@media (prefers-reduced-motion:reduce){.gbj-pop,.gbj-banner.gbj-go,.gbj-punch{animation-duration:.01s}}
/* 전자칠판(큰 마당): 누르는 곳 ≥ 88px (kingsmath-track 터치 규칙) */
body.big .gb-icon, body.big .btn, body.big .gb-play { min-height: 88px; min-width: 88px; font-size: 22px; }

/* 판정 글자: 돌 바로 위 · 크게(교실 뒤에서도) */
#fx .gbj-pop { font-size: 30px; }
/* 연속 배너는 인형 위(가운데)가 아니라 그 위쪽 — 판정 글자(딱!)와 겹쳐 둘 다 안 읽혔다(2026-10-15 실측) · 크게 */
#fx { --gbj-banner-top: 25%; }
#fx .gbj-banner { font-size: clamp(24px, 7.2vw, 54px); }
/* 끝없는 여정 — 4칸 촘촘히 · 고개 색을 이어받는다 */
.world.endless { --sky: #7b5fa6; --ground: #2f4f4a; }
.inf-go { width: 100%; margin: 0 0 8px; }
.inf-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.stage.inf { min-height: 72px; padding: 4px 3px; background: linear-gradient(160deg, color-mix(in srgb, var(--sky) 45%, #13263d), color-mix(in srgb, var(--ground) 40%, #13263d)); }
.stage.inf .st-n { font-size: 18px; font-weight: 900; }
.stage.inf .st-t { font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage.inf.boss { border-color: var(--gb-gold); }
.inf-more { width: 100%; margin-top: 8px; }
body.big .inf-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }

