:root {
  --bg: #1b2233;
  --ink: #ffffff;
  --ink-dim: #c9d2e6;
  --panel: rgba(18, 22, 36, 0.92);
  --accent: #ffcf3a;
  --accent-ink: #2a1a00;
  --good: #3ad07a;
  --bad: #ff5a4a;
  --fever: #19e6ff;
  --sugar: #ff5fb0;
  --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);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input { font: inherit; }

.ico-book {
  display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em;
  /* 펼친 책: 파란 표지 테두리 + 흰 두 페이지 + 글줄 */
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 7.2C9 5.2 5 4.8 1.2 5.6V20.4C5 19.6 9 20 12 21.6 15 20 19 19.6 22.8 20.4V5.6C19 4.8 15 5.2 12 7.2Z' fill='%232f6fd6'/%3E%3Cpath d='M11.2 7.6C8.6 6.1 5.6 5.8 2.7 6.3V18.8C5.6 18.4 8.6 18.8 11.2 20.2ZM12.8 7.6C15.4 6.1 18.4 5.8 21.3 6.3V18.8C18.4 18.4 15.4 18.8 12.8 20.2Z' fill='%23fffaf0'/%3E%3Cpath d='M4.5 10C6.4 9.7 8 9.9 9.6 10.6M4.5 13.4C6.4 13.1 8 13.3 9.6 14M14.4 10.6C16 9.9 17.6 9.7 19.5 10M14.4 14C16 13.3 17.6 13.1 19.5 13.4' stroke='%237d766a' stroke-width='1.3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

.btn {
  border: 0; border-radius: 14px; padding: 12px 18px; min-height: 48px; background: #34405e; color: #fff;
  font-weight: 700; box-shadow: 0 3px 0 rgba(0,0,0,.35); transition: transform .06s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.gold { background: linear-gradient(#ffd96a, #f2a83a); color: #3a2000; }
.btn.big { font-size: 1.25rem; padding: 16px 28px; min-height: 58px; width: 100%; }
.btn.small { min-height: 40px; padding: 8px 14px; }
.btn[disabled] { opacity: .45; cursor: default; }
.icon-btn {
  border: 0; border-radius: 12px; min-width: 48px; min-height: 48px; padding: 0 12px;
  background: rgba(0,0,0,.45); color: #fff; font-weight: 800; font-size: 0.95rem;
}
.top-right { position: fixed; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); z-index: 30; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.small { font-size: .85rem; color: var(--ink-dim); }

.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); }
.screen:not(.show) { display: none; }
.panel-screen { background: rgba(8, 10, 18, .55); }
.panel { background: var(--panel); border-radius: 20px; padding: 20px; width: min(420px, 100%); max-height: 100%; overflow: auto;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.5); touch-action: pan-y; }
.panel.wide { width: min(760px, 100%); }
.panel h2 { margin: 4px 0 12px; font-size: 1.5rem; }

/* 타이틀 */
#scr-title { align-items: flex-end; background: linear-gradient(to top, rgba(10,12,22,.85) 0%, rgba(10,12,22,.1) 55%, rgba(0,0,0,0) 100%); }
.title-box { width: min(420px, 100%); text-align: center; padding-bottom: 10px; }
.logo { font-size: clamp(3.2rem, 16vw, 5.5rem); margin: 0; letter-spacing: -0.04em; font-weight: 900;
  color: var(--accent); text-shadow: 0 5px 0 #b5531a, 0 10px 24px rgba(0,0,0,.6); transform: rotate(-3deg); }
.tagline { margin: 6px 0 14px; font-size: 1.1rem; color: #ffe9c0; text-shadow: 0 2px 6px #000; }
.title-stats { display: flex; justify-content: center; gap: 18px; margin-bottom: 12px; font-size: 1.05rem; }
@media (orientation: landscape) and (max-height: 520px) {
  #scr-title { align-items: center; justify-content: flex-end; }
  .title-box { width: min(360px, 50%); }
  .logo { font-size: 3.4rem; }
}

table.help { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: .92rem; }
table.help th { text-align: left; padding: 6px; color: var(--accent); white-space: nowrap; }
table.help td { text-align: left; padding: 6px; }
ul.rules { text-align: left; padding-left: 18px; font-size: .9rem; line-height: 1.5; }

#btn-skip { position: fixed; z-index: 25; right: calc(14px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); background: rgba(0,0,0,.55); }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l)); }
#hud button { pointer-events: auto; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hud-right { display: flex; gap: 8px; align-items: center; margin-right: 92px; }
.score { font-size: 2.1rem; font-weight: 900; text-shadow: 0 2px 0 #000, 0 0 10px rgba(0,0,0,.5); transition: color .2s; }
.score.frozen { color: #bfe8ff; text-shadow: 0 0 10px #6fd0ff, 0 2px 0 #24506a; filter: saturate(.3); }
.score.fever { color: var(--fever); }
.hud-sub { font-size: 1rem; text-shadow: 0 1px 2px #000; }
/* 속도 단계(작게) + 단계가 오를 때 잠깐 「속도 UP」 — 왼쪽 위 점수 묶음 안이라 다른 HUD·가운데 글자와 안 겹침 */
.hud-speed { font-size: .78rem; font-weight: 700; color: #cfe9ff; text-shadow: 0 1px 2px #000; margin-top: 1px; }
.speed-up { display: inline-block; margin-top: 3px; padding: 2px 9px; border-radius: 9px; font-size: .9rem; font-weight: 900; color: #10233a;
  background: linear-gradient(90deg, #7fe3ff, #ffe66a); box-shadow: 0 2px 0 rgba(0,0,0,.35); opacity: 0; transform: translateX(-6px); pointer-events: none; }
.speed-up.on { animation: speedup 1s ease-out forwards; }
@keyframes speedup { 0% { opacity: 0; transform: translateX(-6px) scale(.9); } 12% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-4px); } }
.shot .speed-up.on { animation: none; opacity: 1; transform: none; }
.books { background: rgba(0,0,0,.45); border-radius: 12px; padding: 8px 12px; font-size: 1.15rem; font-weight: 800; position: relative; }
/* 스타강사 책 2배: 책 수 옆에 잠깐 「×2」 */
.books .x2 { position: absolute; right: -6px; top: -10px; padding: 1px 6px; border-radius: 8px; font-size: .8rem; font-weight: 900; color: #3a2000; background: #ffb43a; box-shadow: 0 2px 0 rgba(0,0,0,.35); opacity: 0; pointer-events: none; }
.books .x2.on { animation: x2 .8s ease-out forwards; }
@keyframes x2 { 0% { opacity: 0; transform: scale(.6); } 15% { opacity: 1; transform: scale(1.15); } 70% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }
.shot .books .x2.on { animation: none; opacity: 1; }
.sugar-bar { display: none; width: 140px; height: 18px; border-radius: 9px; background: rgba(0,0,0,.5); position: relative; overflow: hidden; margin: 2px 0; }
.sugar-bar.on { display: block; }
.sugar-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #ff9ad5, var(--sugar)); }
.sugar-bar span { position: relative; font-size: .75rem; font-weight: 800; padding-left: 8px; line-height: 18px; }
.chase { position: absolute; left: 50%; transform: translateX(-50%); top: calc(12px + var(--safe-t)); display: flex; gap: 6px; align-items: center;
  font-size: .8rem; font-weight: 800; text-shadow: 0 1px 2px #000; }
.chase-bar { width: 90px; height: 10px; border-radius: 5px; background: rgba(0,0,0,.5); overflow: hidden; }
.chase-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd23a, var(--bad)); }
.chase.heat { animation: blink .4s infinite alternate; }
@keyframes blink { to { opacity: .35; } }
.district { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 1.6rem; font-weight: 900; opacity: 0;
  text-shadow: 0 3px 0 #000; white-space: nowrap; }
.district.show { animation: district 2.2s ease-out; }
@keyframes district { 0% { opacity: 0; transform: translate(-50%, 10px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.prompt { position: absolute; left: 50%; top: calc(46px + var(--safe-t)); transform: translateX(-50%); padding: 10px 18px; border-radius: 14px;
  font-size: 1.25rem; font-weight: 900; background: rgba(0,0,0,.6); border: 3px solid var(--accent); white-space: nowrap; }
.prompt.green { border-color: var(--good); color: #c8ffd8; }
.prompt.red { border-color: var(--bad); color: #ffd0cc; animation: blink .35s infinite alternate; }
.prompt.zone { font-size: 1.5rem; }
.prompt .picked { color: var(--accent); }
.toasts { position: absolute; left: 0; right: 0; top: 40%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { padding: 6px 14px; border-radius: 10px; background: rgba(0,0,0,.6); font-weight: 800; animation: toast 1.6s ease-out forwards; }
.toast.fever { color: var(--fever); } .toast.bad { color: #ffb0a8; } .toast.good { color: #b8ffd0; } .toast.ready { color: var(--accent); }
@keyframes toast { 0% { opacity: 0; transform: scale(.8); } 12% { opacity: 1; transform: scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
.hud-bottom { position: absolute; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(14px + var(--safe-b));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.gauge { flex: 1; max-width: 360px; }
.gauge-label { font-size: .8rem; font-weight: 800; text-shadow: 0 1px 2px #000; margin-bottom: 4px; }
.gauge-bar { height: 16px; border-radius: 8px; background: rgba(0,0,0,.5); overflow: hidden; border: 2px solid rgba(255,255,255,.35); }
.gauge-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6a7cff, var(--fever)); }
.skill-btn { width: 92px; height: 92px; border-radius: 50%; border: 4px solid rgba(255,255,255,.3); background: rgba(40,50,80,.7);
  font-weight: 900; font-size: .95rem; line-height: 1.1; color: #9aa6c8; }
.skill-btn.ready { background: radial-gradient(circle, #6ff4ff, #1b8fd6); color: #00222e; border-color: #fff; animation: pulse .6s infinite alternate; }
.skill-btn.active { background: radial-gradient(circle, #fff, var(--fever)); color: #003; }
@keyframes pulse { to { transform: scale(1.08); box-shadow: 0 0 24px var(--fever); } }

/* 효과 */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 9; opacity: 0; transition: opacity .25s; }
#fx-fever { background:
  repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,0) 0deg 5deg, rgba(160,250,255,.5) 5deg 6deg),
  radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(25,230,255,.45) 100%);
  -webkit-mask: radial-gradient(ellipse at center, transparent 42%, #000 75%); mask: radial-gradient(ellipse at center, transparent 42%, #000 75%); }
#fx-fever.on { opacity: 1; animation: speedlines .25s linear infinite; }
/* 상시 속도선: 약하게, 속도에 비례(불투명도는 JS 가 정함) */
#fx-speed { inset: -15%; transition: none; z-index: 8;
  background: repeating-conic-gradient(from 2deg at 50% 50%, rgba(255,255,255,0) 0deg 7deg, rgba(255,255,255,.55) 7deg 7.6deg);
  -webkit-mask: radial-gradient(ellipse at center, transparent 38%, #000 72%); mask: radial-gradient(ellipse at center, transparent 38%, #000 72%);
  animation: speedflick .14s steps(2) infinite; }
@keyframes speedflick { 50% { transform: rotate(3.5deg); } }
@keyframes speedlines { 50% { filter: hue-rotate(40deg) brightness(1.2); } }
#fx-hit { background: radial-gradient(ellipse at center, rgba(255,0,0,0) 40%, rgba(255,40,30,.6) 100%); }
#fx-hit.on { animation: hit .5s ease-out; }
@keyframes hit { 0% { opacity: 1; } 100% { opacity: 0; } }
#fx-sugar { display: flex; align-items: center; justify-content: center; z-index: 11; background: radial-gradient(circle, rgba(255,95,176,.35), rgba(255,210,58,.0) 70%); }
#fx-sugar span { font-size: clamp(3rem, 15vw, 6rem); font-weight: 900; color: #fff; -webkit-text-stroke: 3px #c2187a;
  text-shadow: 0 6px 0 #ff9a3c, 0 0 30px #ff5fb0; transform: rotate(-6deg); }
#fx-sugar.on { animation: sugar 1.4s ease-out forwards; }
#fx-sugar.on span { animation: bounce 1.4s cubic-bezier(.3,1.6,.5,1); }
@keyframes sugar { 0% { opacity: 0; } 8% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bounce { 0% { transform: scale(.2) rotate(-20deg); } 25% { transform: scale(1.25) rotate(4deg); } 40% { transform: scale(.9) rotate(-8deg); }
  55% { transform: scale(1.08) rotate(-4deg); } 70% { transform: scale(1) rotate(-6deg); } 100% { transform: scale(1.1) rotate(-6deg) translateY(-30px); } }
.sound-row .btn { min-width: 120px; }
.sound-row .btn.off { opacity: .6; }
/* 추격대 살짝 보이기 */
.pip { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(76px + var(--safe-b)); width: min(30vw, 230px); aspect-ratio: 16 / 10;
  border: 3px solid #fff; border-radius: 10px; box-shadow: 0 0 0 2px rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.5);
  opacity: 0; transform: scale(.6); transform-origin: left bottom; transition: opacity .15s, transform .18s cubic-bezier(.3,1.5,.5,1); pointer-events: none; }
.pip.on { opacity: 1; transform: scale(1); }
.pip-tag { position: absolute; left: 6px; top: 4px; font-size: .7rem; font-weight: 900; color: #fff; background: rgba(220,30,30,.85); padding: 1px 6px; border-radius: 6px; }
.bubble { position: absolute; top: 50%; max-width: 40vw; padding: 8px 14px; border-radius: 16px; background: #fff; color: #1a1a1a;
  font-weight: 900; font-size: 1.15rem; border: 3px solid #1a1a1a; opacity: 0; transform: scale(.4); transition: opacity .12s, transform .2s cubic-bezier(.3,1.6,.5,1);
  pointer-events: none; white-space: nowrap; z-index: 2; }
.bubble.left { left: calc(10px + var(--safe-l)); transform-origin: left bottom; }
.bubble.right { right: calc(10px + var(--safe-r)); transform-origin: right bottom; }
.bubble::after { content: ''; position: absolute; bottom: -12px; width: 0; height: 0; border: 8px solid transparent; border-top: 12px solid #1a1a1a; }
.bubble.left::after { left: 14px; } .bubble.right::after { right: 14px; }
.bubble.on { opacity: 1; transform: scale(1); }
#fx-camflash { background: radial-gradient(ellipse at center, rgba(255,255,255,0) 30%, rgba(255,255,255,.75) 100%); z-index: 10; }
#fx-camflash.on { animation: hit .35s ease-out; }
/* 감옥 엔딩: 하얀 플래시로 넘어가고, 결과 패널은 장면을 가리지 않게 한쪽으로 */
#fx-white { background: #fff; z-index: 30; }
#fx-white.on { animation: whiteflash .55s ease-out; }
@keyframes whiteflash { 0% { opacity: 1; } 35% { opacity: 1; } 100% { opacity: 0; } }
body.jailed #scr-result { background: linear-gradient(90deg, rgba(8,10,18,0) 35%, rgba(8,10,18,.55)); justify-content: flex-end;
  padding-right: calc(4vw + var(--safe-r)); }
body.jailed #scr-result .panel { animation: panelup .35s ease-out; }
@keyframes panelup { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
@media (orientation: portrait), (max-aspect-ratio: 9/10) {
  body.jailed #scr-result { background: linear-gradient(180deg, rgba(8,10,18,0) 40%, rgba(8,10,18,.6)); align-items: flex-end; justify-content: center;
    padding-right: 12px; padding-bottom: calc(10px + var(--safe-b)); }
  body.jailed #scr-result .panel { max-height: 58%; padding: 14px; }
  body.jailed #scr-result .panel h2 { margin: 0 0 4px; }
}
.shot #fx-white.on { animation: none; opacity: 0; }
.shot body.jailed #scr-result .panel, .shot.jailed #scr-result .panel { animation: none; }
body.sugar canvas#game { filter: saturate(1.6) hue-rotate(-20deg); }
body.fever canvas#game { filter: saturate(1.3) contrast(1.05); }

/* 결과 */
.reason { margin: -4px 0 12px; color: var(--ink-dim); }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.res-grid div { background: rgba(255,255,255,.06); border-radius: 12px; padding: 10px; }
.res-grid small { display: block; color: var(--ink-dim); }
.res-grid b { font-size: 1.5rem; }
.res-grid em { color: var(--accent); font-weight: 900; margin-left: 4px; font-style: normal; }
#res-form input { flex: 1; min-width: 0; min-height: 48px; border-radius: 12px; border: 0; padding: 0 12px; font-size: 1rem; user-select: text; -webkit-user-select: text; }

/* 상점 */
.wallet { font-size: 1rem; margin-left: 8px; background: rgba(0,0,0,.35); padding: 4px 10px; border-radius: 10px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.card { background: rgba(255,255,255,.06); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: center; border: 2px solid transparent; }
.card.equipped { border-color: var(--accent); }
.card .fig { width: 64px; height: 92px; position: relative; }
.card .fig i { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 3px; }
/* 스킨 아우라 미리보기(상점 카드): 발밑 빛 고리 + 위로 떠오르는 빛 점 */
.card .fig.aura b { position: absolute; pointer-events: none; }
.card .fig.aura .a-ring { left: 50%; top: 82px; width: 66px; height: 16px; margin-left: -33px; border-radius: 50%; border: 2px solid var(--aura); box-shadow: 0 0 10px var(--aura), inset 0 0 8px var(--aura); opacity: .75; animation: aring 1.6s ease-in-out infinite; }
.card .fig.aura .a-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--aura); box-shadow: 0 0 8px var(--aura); opacity: 0; animation: adot 1.8s linear infinite; }
.card .fig.aura .d1 { left: 2px; } .card .fig.aura .d2 { left: 56px; animation-delay: .6s; } .card .fig.aura .d3 { left: 30px; animation-delay: 1.2s; }
@keyframes aring { 50% { transform: scale(1.08); opacity: 1; } }
@keyframes adot { 0% { top: 84px; opacity: 0; } 20% { opacity: 1; } 100% { top: 4px; opacity: 0; } }
.shot .card .fig.aura .a-dot { animation: none; opacity: 1; } .shot .card .fig.aura .d1 { top: 60px; } .shot .card .fig.aura .d2 { top: 30px; } .shot .card .fig.aura .d3 { top: 8px; }
.card .fig.aura { filter: drop-shadow(0 0 6px rgba(255, 201, 74, .45)); }
.card .name { font-weight: 800; }
.card .desc { font-size: .75rem; color: var(--ink-dim); min-height: 2.4em; }
.card .tag { font-size: .8rem; font-weight: 800; color: var(--accent); }
.card .btn { width: 100%; min-height: 42px; padding: 8px; }
.card .btn.up { min-height: 36px; font-size: .85rem; background: #3a2f6a; }
.card .btn.up:disabled { opacity: .5; }
.card .eff { font-size: .78rem; color: #e8ecff; border-left: 4px solid var(--c, #888); padding-left: 6px; text-align: left; align-self: stretch; }
.card .eff.none { color: var(--ink-dim); border-color: #555; }
.card .lv { display: flex; gap: 2px; }
.card .lv i { width: 9px; height: 9px; border-radius: 2px; background: rgba(255,255,255,.15); }
.card .lv i.on { background: var(--accent); }
.card .next { font-size: .72rem; color: var(--ink-dim); }
/* 스킨 효과 발동 연출 */
#fx-perk { display: flex; align-items: center; justify-content: center; z-index: 12; box-shadow: inset 0 0 0 0 var(--c, #fff); }
#fx-perk span { font-size: clamp(2.4rem, 11vw, 4.6rem); font-weight: 900; color: #fff; -webkit-text-stroke: 3px var(--c, #333); text-shadow: 0 5px 0 rgba(0,0,0,.35); transform: rotate(-4deg); }
#fx-perk.on { animation: perk 1s ease-out forwards; }
@keyframes perk { 0% { opacity: 0; box-shadow: inset 0 0 0 40px var(--c); } 10% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; box-shadow: inset 0 0 0 0 var(--c); } }
.shot #fx-perk.on { animation: none; opacity: 1; box-shadow: inset 0 0 0 18px var(--c); }

/* 고속(Lv.7~10) 가장자리 속도선: 주황·흰, 화면 가장자리에만 — 브레인 악셀(하늘색)과 다른 색 */
#fx-speed-hi { inset: -15%; transition: none; z-index: 8;
  background: repeating-conic-gradient(from 4deg at 50% 50%, rgba(255,150,40,0) 0deg 9deg, rgba(255,160,60,.7) 9deg 9.5deg, rgba(255,240,210,0) 9.5deg 13deg, rgba(255,235,200,.45) 13deg 13.3deg);
  -webkit-mask: radial-gradient(ellipse at center, transparent 52%, #000 80%); mask: radial-gradient(ellipse at center, transparent 52%, #000 80%);
  animation: speedflick .1s steps(2) infinite; }
.hud-speed.max { color: #ffb347; }
.speed-up.max { background: linear-gradient(90deg, #ff9a3c, #ffd36b); }
.prompt.yellow { border-color: #ffc21a; color: #fff1b8; animation: blink .18s infinite alternate; }
.shot .prompt.yellow { animation: none; }
/* 길고양이와 부딪힘 「야옹!」 */
#fx-meow { display: flex; align-items: flex-start; justify-content: center; padding-top: 30vh; z-index: 12; }
#fx-meow span { font-size: clamp(2rem, 9vw, 3.6rem); font-weight: 900; color: #fff; -webkit-text-stroke: 3px #ff7a1a; text-shadow: 0 4px 0 rgba(0,0,0,.35); transform: rotate(5deg); }
#fx-meow.on { animation: meow .9s ease-out forwards; }
@keyframes meow { 0% { opacity: 0; transform: scale(.6); } 12% { opacity: 1; transform: scale(1.08); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.shot #fx-meow.on { animation: none; opacity: 1; }

/* 랭킹 */
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.tab { border: 0; border-radius: 10px; padding: 8px 14px; min-height: 42px; background: #2a3350; font-weight: 700; }
.tab.on { background: var(--accent); color: var(--accent-ink); }
.rank-list { text-align: left; padding-left: 0; list-style: none; margin: 0 0 8px; counter-reset: r; }
.rank-list li { counter-increment: r; display: flex; gap: 8px; padding: 7px 8px; border-radius: 8px; }
.rank-list li:nth-child(odd) { background: rgba(255,255,255,.05); }
.rank-list li::before { content: counter(r); width: 26px; font-weight: 900; color: var(--accent); }
.rank-list li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list li .s { font-weight: 800; }
.rank-list li.me { outline: 2px solid var(--accent); }
#scr-rank .rank-list { max-height: 52vh; overflow-y: auto; }
.rank-sub { font-size: .7em; color: var(--ink-dim); font-weight: 700; }
.notice { opacity: .7; font-size: .72rem; margin: 2px 0 6px; }


.boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 60; background: var(--bg); font-size: 1.2rem; }
#errlog { position: fixed; left: 0; right: 0; bottom: 0; max-height: 40%; overflow: auto; z-index: 99; background: rgba(120,0,0,.85); color: #fff; font-size: 12px; margin: 0; padding: 8px; white-space: pre-wrap; }

/* 캡처 모드: 움직이는 효과를 보이는 상태로 멈춤 */
.shot .toast { animation: none; }
.shot .prompt.red, .shot .chase.heat { animation: none; }
.shot .district.show { animation: none; opacity: 1; }
.shot #fx-sugar.on { animation: none; opacity: 1; }
.shot #fx-sugar.on span { animation: none; transform: scale(1.1) rotate(-6deg); }
.shot #fx-hit.on { animation: none; opacity: .8; }
.shot .pip, .shot .bubble { transition: none; }

@media (max-width: 520px) {
  .chase { left: auto; right: calc(12px + var(--safe-r)); transform: none; top: calc(66px + var(--safe-t)); }
  .hud-right { margin-right: 84px; }
}
@media (max-width: 420px) {
  .score { font-size: 1.8rem; }
  .prompt { font-size: 1.05rem; top: calc(96px + var(--safe-t)); }
  .prompt.zone { font-size: 1.2rem; }
  .skill-btn { width: 96px; height: 96px; }
  .pip { width: 40vw; bottom: calc(80px + var(--safe-b)); }
  .bubble { font-size: 1rem; top: 54%; }
}

/* 후원 단추(링크 하나) — 모든 화면에서 항상 보임. 창(상점·랭킹·결과·일시정지)·소리 단추보다 위(z-index 40).
   타이틀·시작 연출·결과·상점·랭킹·감옥: 왼쪽 위 모서리 알약(소리 단추와 좌우 대칭, 창은 그 아래부터 시작).
   달리는 중·일시정지: 오른쪽 가장자리, 화면 높이 30% 쯤의 작고 옅은 알약 — 점수·책·일시정지·소리(위), 추격 게이지,
   가운데 방향 안내·구역 이름·알림, 양옆 말풍선(50% 아래), 뒤쪽 창·게이지·브레인 악셀 단추(아래)와 겹치지 않는 자리. */
.donate-pill {
  position: fixed; z-index: 40; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l));
  min-height: 40px; padding: 0 14px; border-radius: 999px; text-decoration: none;
  font-size: .9rem; font-weight: 800; color: #3a2000; background: linear-gradient(#ffd96a, #f2a83a);
  box-shadow: 0 2px 0 rgba(0,0,0,.35), 0 2px 10px rgba(0,0,0,.25); touch-action: manipulation; transition: opacity .2s;
}
.donate-pill:active { transform: translateY(1px); }
body[data-mode="run"] .donate-pill, body[data-mode="paused"] .donate-pill {
  top: max(calc(70px + var(--safe-t)), 30%); left: auto; right: calc(6px + var(--safe-r));
  min-height: 26px; padding: 0 9px; font-size: .72rem; font-weight: 800; gap: 2px;
  background: rgba(20, 24, 40, .5); color: #ffe6a8; box-shadow: 0 0 0 1px rgba(255, 217, 106, .45);
}
body[data-mode="run"] .donate-pill { opacity: .6; }
body[data-mode="run"] .donate-pill:hover, body[data-mode="run"] .donate-pill:focus-visible { opacity: 1; }
body[data-mode="paused"] .donate-pill { opacity: 1; background: linear-gradient(#ffd96a, #f2a83a); color: #3a2000; }
/* 창이 왼쪽 위 후원 단추·오른쪽 위 소리 단추 밑에서 시작하게 */
body .panel-screen { padding-top: calc(60px + var(--safe-t)); }
/* 후원 고르기 창(링크 2개 이상): 화면 가운데 작은 카드, 모든 창·단추 위(z 50). 바깥(어두운 곳)을 누르면 닫힘 */
.donate-pop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(6, 8, 14, .5);
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); touch-action: none; }
.donate-card { width: min(340px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 2px solid rgba(255, 217, 106, .55);
  border-radius: 18px; padding: 12px 14px 10px; box-shadow: 0 10px 40px rgba(0,0,0,.55); text-align: left; }
.donate-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 1.05rem; color: var(--accent); }
.donate-x { border: 0; background: rgba(255,255,255,.1); border-radius: 10px; min-width: 40px; min-height: 40px; font-size: 1rem; font-weight: 800; }
.donate-list { display: flex; flex-direction: column; gap: 8px; }
.donate-link { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; min-height: 52px; border-radius: 12px; text-decoration: none; color: #fff;
  background: #34405e; box-shadow: 0 3px 0 rgba(0,0,0,.35); touch-action: manipulation; }
.donate-link:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.donate-link b { font-size: 1rem; }
.donate-link b::after { content: ' ↗'; color: var(--accent); font-weight: 800; }
.donate-link small { font-size: .78rem; color: var(--ink-dim); }
.donate-note { margin: 10px 0 0; font-size: .75rem; color: var(--ink-dim); text-align: center; }

/* 쿠팡 파트너스 배너 자리(src/ads.js) — 타이틀 아래·결과/랭킹 창 아래에만 붙고, 달리는 중·일시정지·시작 연출에는 DOM 에서 빠진다(아래는 이중 안전장치).
   「달리기 시작」「다시 달리기」 단추와 16px 이상 떨어짐(margin-top). 크기는 설정값으로만 확보(광고가 안 떠도 그 크기). */
.ad-slot { display: flex; flex-direction: column; align-items: center; width: 100%; margin: 16px auto 0; touch-action: manipulation; }
.ad-box { position: relative; overflow: hidden; max-width: 100%; border-radius: 6px; }
.ad-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ad-inner iframe { display: block; border: 0; }
.ad-inner img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ad-box.ad-test, .ad-inner.ad-test { background: repeating-linear-gradient(45deg, #8a8f99 0 10px, #7a7f88 10px 20px); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 800; text-shadow: 0 1px 2px #000; }
.ad-notice { margin: 4px auto 0; font-size: .66rem; line-height: 1.35; color: var(--ink-dim); text-align: center; opacity: .85; }
body[data-mode="run"] .ad-slot, body[data-mode="paused"] .ad-slot, body[data-mode="intro"] .ad-slot { display: none !important; }
/* 가로 폰 타이틀: 오른쪽 타이틀 묶음과 겹치지 않게 왼쪽 아래 구석에 */
@media (orientation: landscape) and (max-height: 520px) {
  #scr-title .ad-slot { position: fixed; left: calc(12px + var(--safe-l)); bottom: calc(8px + var(--safe-b)); width: min(340px, 44vw); margin: 0; }
}
