/* 회사 뿌개기 — UI */
:root {
  --ink: #161925;
  --card: rgba(24, 26, 36, .74);
  --card-2: rgba(24, 26, 36, .62);
  --line: rgba(255, 255, 255, .12);
  --txt: #fff;
  --muted: rgba(255, 255, 255, .8);
  --yel: #ffd23f;
  --org: #ff8a2a;
  --red: #ff4b5c;
  --blue: #3d7bff;
  --mint: #22c79a;
  --paper: #fffdf6;
  --hud-font: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --head-font: "Black Han Sans", "Noto Sans KR", sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --gap: clamp(8px, 1.3vmin, 18px);
  /* 화면 가장자리 여백 (안전 영역 포함) */
  --ex-t: calc(var(--sat) + var(--gap));
  --ex-r: calc(var(--sar) + var(--gap));
  --ex-b: calc(var(--sab) + var(--gap));
  --ex-l: calc(var(--sal) + var(--gap));
  color-scheme: dark;
}

/* HUD 크기 기준: 데스크톱 17px, 휴대폰 11px 근처 */
html { font-size: clamp(11px, min(1.02vw, 1.85vh), 17px); }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--ink); color: var(--txt);
  font-family: var(--hud-font); font-weight: 500;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--yel); outline-offset: 2px; }
[hidden] { display: none !important; }

#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
#ui > * { pointer-events: none; }

/* ---------- 공통 조각 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: .9rem;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 .35rem 1.2rem rgba(0, 0, 0, .22);
}
.pill {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 .3rem 1rem rgba(0, 0, 0, .2);
}
.kc {
  display: inline-grid; place-items: center;
  min-width: 1.75em; height: 1.75em; padding: 0 .38em; box-sizing: border-box;
  background: #fff; color: #1b1d26;
  border-radius: .38em;
  box-shadow: 0 .16em 0 #b9bdc9, 0 .2em .5em rgba(0, 0, 0, .25);
  font-weight: 900; letter-spacing: .01em; line-height: 1;
  position: relative;
}
.kc b { font-weight: 900; position: relative; z-index: 1; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "tl tc tr" ". . ." "keys keys keys";
  column-gap: var(--gap);
  padding: var(--ex-t) var(--ex-r) var(--ex-b) var(--ex-l);
  box-sizing: border-box;
  z-index: 20;
}
.hud-tl { grid-area: tl; display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; min-width: 0; }
.hud-tc { grid-area: tc; display: flex; flex-direction: column; align-items: center; gap: .45rem; }
.hud-tr { grid-area: tr; display: flex; flex-direction: column; align-items: flex-end; gap: .45rem; }
.tr-row { display: flex; gap: .5rem; align-items: stretch; }

/* 미션 카드 */
#mission { padding: .7rem 1.1rem .75rem; max-width: min(21rem, 100%); box-sizing: border-box; transition: border-color .3s, background .3s; }
#mission h2 { margin: 0; font-family: var(--head-font); font-weight: 400; font-size: 1.9rem; line-height: 1.12; letter-spacing: .01em; }
#mission p { margin: .3rem 0 0; font-size: 1.18rem; font-weight: 700; color: var(--muted); line-height: 1.3; }
#m-sub { color: #fff !important; font-weight: 500 !important; }
#m-quote { color: #fff !important; }
#m-note { border-top: 1px solid rgba(255, 255, 255, .35); padding-top: .45rem; margin-top: .5rem !important; font-weight: 500 !important; font-size: 1.05rem !important; }
#mission.rage { background: linear-gradient(135deg, rgba(120, 18, 30, .78), rgba(24, 26, 36, .74) 70%); border-color: rgba(255, 90, 100, .55); }
#mission.rage h2 { color: #fff; text-shadow: 0 0 .6rem rgba(255, 70, 80, .55); }

/* 할 일 */
#tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; max-width: min(21rem, 100%); }
#tasks li {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1.05rem .5rem .8rem;
  background: var(--card); border: 1px solid var(--line); border-radius: .75rem;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 1.22rem; font-weight: 700; line-height: 1.25;
  transition: opacity .3s;
}
#tasks li .cb {
  flex: none; width: 1.15rem; height: 1.15rem; border: 2px solid rgba(255, 255, 255, .9); border-radius: .3rem;
  display: grid; place-items: center; box-sizing: border-box;
}
#tasks li.done .cb { background: var(--mint); border-color: var(--mint); }
#tasks li.done .cb::after { content: ""; width: .32rem; height: .6rem; border: solid #fff; border-width: 0 .17rem .17rem 0; transform: translateY(-.08rem) rotate(45deg); }
#tasks li.done .tt { opacity: .62; text-decoration: line-through; text-decoration-thickness: 2px; }
#tasks li.plain { background: rgba(250, 250, 246, .9); color: #1c1e27; border-color: rgba(255, 255, 255, .7); padding-left: 1.05rem; box-shadow: 0 .25rem .8rem rgba(0, 0, 0, .18); }
#tasks li.plain.done .tt { opacity: .5; }
#tasks li.new { animation: task-in .45s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes task-in { from { transform: translateX(-1.2rem); opacity: 0; } }

/* 스트레스 */
#stress { display: flex; align-items: center; gap: .75rem; height: 2.65rem; padding: 0 1.1rem; box-sizing: border-box; width: clamp(15rem, 34vw, 34rem); position: relative; transition: width .35s, padding .35s; }
.s-lbl { font-weight: 900; font-size: 1.2rem; white-space: nowrap; }
#stress-pct { font-weight: 900; font-size: 1.3rem; min-width: 3.1em; text-align: right; font-variant-numeric: tabular-nums; }
.s-bar { position: relative; flex: 1; height: 1.15rem; border-radius: 999px; background: rgba(0, 0, 0, .45); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55); overflow: hidden; }
#stress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ffd84a, #ffae38 45%, #ff6a4a 80%, #ff4b6a); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12), inset 0 2px 0 rgba(255, 255, 255, .35); }
.s-in { display: none; }
#stress.hot .s-bar { animation: hot 1s ease-in-out infinite; }
@keyframes hot { 50% { box-shadow: inset 0 0 0 2px #ffb2a0, 0 0 .8rem rgba(255, 90, 70, .6); } }
#stress.full { padding: .25rem; gap: 0; }
#stress.full .s-lbl, #stress.full #stress-pct { display: none; }
#stress.full .s-bar { height: 100%; box-shadow: none; }
#stress.full #stress-fill { width: 100% !important; background: linear-gradient(90deg, #ffd23f, #ff9b3a 45%, #ff6a5c 75%, #ff4f78); }
#stress.full .s-in { display: flex; position: absolute; inset: 0; align-items: center; justify-content: center; gap: .6em; color: #2a1305; font-weight: 900; font-size: 1.2rem; white-space: nowrap; }
#stress.full .s-in b { font-weight: 900; font-variant-numeric: tabular-nums; }
#stress.pulse { animation: s-pulse .5s ease-out; }
@keyframes s-pulse { 30% { transform: scale(1.06); box-shadow: 0 0 1.4rem rgba(255, 90, 70, .75); } }

/* 기력 (하트 5개): 싸움이 시작되면 스트레스 막대 아래에 */
#hearts { display: flex; align-items: center; gap: .2rem; height: 1.75rem; padding: 0 .55rem; box-sizing: border-box; align-self: center; }
#hearts i { width: 1.12rem; height: 1rem; background: rgba(255, 255, 255, .22); -webkit-mask: var(--heart) center / contain no-repeat; mask: var(--heart) center / contain no-repeat; }
#hearts i.on { background: linear-gradient(180deg, #ff8197, #ff3d62); }
#hearts.low i.on { animation: heart-low .7s ease-in-out infinite; }
#hearts.down { opacity: .7; }
#hearts.down i.on { background: #9aa0b4; }
@keyframes heart-low { 50% { transform: scale(1.25); } }
:root { --heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 18'%3E%3Cpath d='M10 17.5 8.6 16.2C3.4 11.6 0 8.6 0 5 0 2.2 2.2 0 5 0c1.9 0 3.7.9 5 2.3C11.3.9 13.1 0 15 0c2.8 0 5 2.2 5 5 0 3.6-3.4 6.6-8.6 11.2z'/%3E%3C/svg%3E"); }

/* 남은 시간 */
#timer {
  font-family: var(--head-font); font-size: 2.3rem; line-height: 1; padding: .3rem 1rem .35rem;
  background: var(--card); border: 1px solid var(--line); border-radius: .8rem; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
#timer.low { color: #fff; background: linear-gradient(180deg, #ff5a63, #d81f3a); border-color: #ff9aa2; }
#timer.tick { animation: tick .35s ease-out; }
@keyframes tick { 0% { transform: scale(1.22); } }

/* 피해액 */
#money { display: flex; align-items: baseline; gap: .8rem; padding: 0 1.15rem; height: 2.65rem; box-sizing: border-box; align-items: center; border-radius: .8rem; }
#money-lbl { font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
#money-val { font-weight: 900; font-size: 1.5rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
#money.big #money-val { color: var(--yel); }
.sq { width: 2.65rem; height: 2.65rem; border-radius: .8rem; background: var(--card); border: 1px solid var(--line); display: flex; gap: .3rem; align-items: center; justify-content: center; pointer-events: auto; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sq i { width: .32rem; height: 1.05rem; border-radius: 2px; background: #fff; }
.sq:active { transform: scale(.94); }
#combo {
  font-weight: 900; font-size: 1.05rem; padding: .22rem .7rem; border-radius: .6rem; color: #2b1300;
  background: linear-gradient(180deg, #ffe26a, #ffb12e); box-shadow: 0 .2rem .6rem rgba(0, 0, 0, .25);
  font-variant-numeric: tabular-nums; margin-right: 3.15rem;
}
#combo b { font-size: 1.25rem; }
#combo { transform-origin: 85% 50%; transition: background .2s, color .2s; }
#combo[data-tier="1"] { background: linear-gradient(180deg, #ffcf4a, #ff8a1e); }
#combo[data-tier="2"] { background: linear-gradient(180deg, #ff9a3a, #f0442a); color: #fff; text-shadow: 0 .08rem 0 #7a1405; }
#combo[data-tier="3"] { background: linear-gradient(180deg, #ff5a8a, #b326d6); color: #fff; text-shadow: 0 .08rem 0 #4a0a52; box-shadow: 0 .2rem .6rem rgba(0, 0, 0, .25), 0 0 1rem rgba(255, 90, 200, .6); }

/* 협찬 광고판 앞 QR 카드 (adqr.js) — 흰 바탕 · 칸이 또렷하게 (폰으로 화면을 찍어 읽는다) */
#adqr { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .5rem .5rem .45rem; background: #fff; color: #1b1d1c; border-radius: .8rem; box-shadow: 0 .3rem 1rem rgba(0, 0, 0, .28); animation: adqrIn .25s ease-out; }
#adqr canvas { display: block; width: 180px; height: 180px; image-rendering: pixelated; }
.touch #adqr canvas { width: 135px; height: 135px; }
#adqr .aq-t { font-weight: 800; font-size: .85rem; white-space: nowrap; }
#adqr .aq-t b { display: inline-block; margin-right: .3rem; padding: 0 .3rem; border-radius: .3rem; background: #2a2d2b; color: #fff; font-size: .7rem; font-weight: 700; vertical-align: .08rem; }
#adqr .aq-s { font-size: .72rem; color: #5b605d; white-space: nowrap; }
@keyframes adqrIn { from { opacity: 0; transform: translateY(-.4rem); } }
@media (prefers-reduced-motion: reduce) { #adqr { animation: none; } }

/* 키 안내 */
#keys { grid-area: keys; display: flex; gap: .55rem; align-items: center; align-self: end; flex-wrap: wrap; }
#keys .kh { display: flex; align-items: center; gap: .45rem; padding: .3rem .75rem .3rem .3rem; border-radius: .6rem; background: var(--card-2); font-weight: 700; font-size: 1.05rem; }
#keys .kc { font-size: .95rem; }
#keys .kc.charge::before { content: ""; position: absolute; left: 0; bottom: 0; height: 100%; width: calc(var(--c, 0) * 100%); border-radius: inherit; background: linear-gradient(90deg, #ffe680, #ffc21f); }
#keys .kc.ready { box-shadow: 0 .16em 0 #c08a00, 0 0 .9em rgba(255, 205, 50, .95); animation: ready 1s ease-in-out infinite; }
@keyframes ready { 50% { transform: translateY(-2px); } }

/* ---------- 월드 위 표시 ---------- */
#world { position: absolute; inset: 0; overflow: hidden; z-index: 5; }
#world > * { position: absolute; left: 0; top: 0; will-change: transform; }
.prompt { display: flex; align-items: center; gap: .55rem; padding: .28rem 1rem .28rem .3rem; border-radius: .75rem; background: rgba(24, 26, 36, .8); font-weight: 900; font-size: 1.25rem; white-space: nowrap; box-shadow: 0 .3rem 1rem rgba(0, 0, 0, .25); }
.prompt .kc { font-size: 1.05rem; }
.prompt { overflow: hidden; }
.prompt.hold::after { content: ""; position: absolute; left: 0; bottom: 0; height: .22rem; width: 100%; background: var(--yel); transform-origin: left; transform: scaleX(var(--h, 0)); }
.bubble { padding: .45rem .95rem; background: #fff; color: #1d1f28; border-radius: 1.1rem; font-weight: 700; font-size: 1.12rem; white-space: nowrap; box-shadow: 0 .25rem .9rem rgba(0, 0, 0, .22); max-width: 18rem; }
.bubble::after { content: ""; position: absolute; left: calc(50% - .2rem); bottom: -.7rem; border-style: solid; border-width: .75rem .2rem 0 .65rem; border-color: #fff transparent transparent transparent; }
.bubble.long { white-space: normal; width: max-content; }
.pop { pointer-events: none; }
.pop span { display: block; font-family: var(--hud-font); font-weight: 900; font-size: 1.8rem; color: var(--yel); white-space: nowrap; transform: translate(-50%, -50%) rotate(-6deg); -webkit-text-stroke: .14rem #3a2400; paint-order: stroke fill; text-shadow: 0 .16rem 0 #3a2400, 0 .35rem .6rem rgba(0, 0, 0, .35); font-style: italic; }
/* colour steps by amount (size comes from the pop animation): <10k pale, 10k yellow, 50k orange-gold, 200k hot pink */
.pop[data-tier="0"] span { color: #fff6c8; -webkit-text-stroke-width: .11rem; }
.pop[data-tier="2"] span { color: #ffb52e; -webkit-text-stroke-color: #4a1800; text-shadow: 0 .16rem 0 #4a1800, 0 0 .9rem rgba(255, 170, 40, .65); }
.pop[data-tier="3"] span { color: #ff6fae; -webkit-text-stroke-color: #3d0628; text-shadow: 0 .18rem 0 #3d0628, 0 0 1.2rem rgba(255, 90, 170, .8), 0 0 2.4rem rgba(255, 220, 90, .5); }

/* special wind-up: speed lines from the screen edges */
#speed { position: absolute; inset: -10%; z-index: 7; pointer-events: none; display: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, .0) 0deg 4deg, rgba(255, 246, 200, .55) 4deg 5deg, rgba(255, 255, 255, 0) 5deg 9deg);
  -webkit-mask: radial-gradient(ellipse at center, transparent 38%, #000 72%); mask: radial-gradient(ellipse at center, transparent 38%, #000 72%); }
#speed.soft { background: radial-gradient(ellipse at center, transparent 50%, rgba(255, 220, 120, .35) 90%); -webkit-mask: none; mask: none; }

/* ---------- 화면 효과 ---------- */
#vignette { position: absolute; inset: 0; z-index: 6; opacity: 0; background: radial-gradient(ellipse at center, transparent 52%, rgba(200, 0, 20, .55) 85%, rgba(140, 0, 10, .85)); transition: opacity .25s; }
#vignette.beat { animation: beat .9s ease-in-out infinite; }
@keyframes beat { 50% { filter: brightness(1.35); } }
#flash { position: absolute; inset: 0; z-index: 35; opacity: 0; }

#subtitle {
  position: absolute; left: 50%; bottom: calc(var(--ex-b) + 3.8rem); transform: translateX(-50%); z-index: 30;
  max-width: min(46rem, calc(100vw - 2 * var(--side, 1rem))); box-sizing: border-box; width: max-content;
  padding: .55rem 1.2rem; border-radius: .8rem; background: rgba(16, 18, 26, .82);
  font-size: 1.28rem; font-weight: 700; line-height: 1.4; text-align: center; text-wrap: balance;
}
#subtitle .sp { color: var(--yel); margin-right: .55em; font-weight: 900; }
#subtitle .sp:empty { display: none; }
#toast {
  position: absolute; left: 50%; bottom: calc(var(--ex-b) + 7.6rem); transform: translateX(-50%); z-index: 31;
  padding: .45rem 1.05rem; border-radius: 999px; background: #fff; color: #1b1d26; font-weight: 900; font-size: 1.1rem;
  box-shadow: 0 .3rem 1rem rgba(0, 0, 0, .3); white-space: nowrap; max-width: calc(100vw - 2rem); overflow: hidden; text-overflow: ellipsis;
}
#banner { position: absolute; left: 0; right: 0; top: 30%; z-index: 32; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 1rem; }
#banner strong {
  font-family: var(--head-font); font-weight: 400; font-size: clamp(2.6rem, 7.5vmin, 5.6rem); line-height: 1.05;
  color: var(--yel); -webkit-text-stroke: .2rem #2a1300; paint-order: stroke fill;
  text-shadow: 0 .3rem 0 #c2341d, 0 .55rem 1.2rem rgba(0, 0, 0, .45);
}
#banner span { margin-top: .6rem; padding: .3rem 1rem; border-radius: 999px; background: rgba(16, 18, 26, .8); font-weight: 900; font-size: 1.35rem; }
#banner span:empty { display: none; }

/* ---------- 터치 ---------- */
#touch { position: absolute; inset: 0; z-index: 10; pointer-events: auto; touch-action: none; }
#look-zone { position: absolute; inset: 0; }
#joy { position: absolute; left: calc(var(--sal) + 1.2rem); bottom: calc(var(--sab) + 1.2rem); width: 8.4rem; height: 8.4rem; pointer-events: none; }
#joy-base { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-radius: 50%; background: rgba(20, 22, 32, .35); border: 2px solid rgba(255, 255, 255, .45); box-sizing: border-box; transition: opacity .2s; opacity: .75; }
#joy.on #joy-base { opacity: 1; transition: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 44%; height: 44%; margin: -22% 0 0 -22%; border-radius: 50%; background: rgba(255, 255, 255, .88); box-shadow: 0 .2rem .6rem rgba(0, 0, 0, .3); }
#tbtns { position: absolute; right: calc(var(--sar) + 1rem); bottom: calc(var(--sab) + 1rem); width: 16rem; height: 12rem; pointer-events: none; }
.tbtn {
  position: absolute; pointer-events: auto; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 1.05rem; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  background: rgba(24, 26, 36, .55); border: 2px solid rgba(255, 255, 255, .55); box-sizing: border-box;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.tbtn.on { transform: scale(.92); filter: brightness(1.25); }
.t-attack { right: 0; bottom: 0; width: 6.6rem; height: 6.6rem; font-size: 1.35rem; background: radial-gradient(circle at 50% 35%, #ff7a5c, #e2343f); border-color: #ffd0c4; }
/* 때리기 둘레로 반원: 발차기·막기는 바로 옆(엄지가 미끄러지는 자리), 행동·필살기는 그 위, 점프는 때리기 위 */
.t-kick { right: 6.9rem; bottom: .1rem; width: 4.5rem; height: 4.5rem; font-size: .98rem; background: radial-gradient(circle at 50% 35%, #ffb35c, #f07a12); border-color: #ffe2bf; }
/* 막기: 꾹 누르는 동안 막기 (누르면 주인공 앞에 민트색 방패) */
.t-guard { right: 11.6rem; bottom: .1rem; width: 4.5rem; height: 4.5rem; background: radial-gradient(circle at 50% 35%, #7cf0cc, #1fb386); border-color: #e3fff4; color: #053b2b; text-shadow: none; }
.t-guard.on { box-shadow: 0 0 1.1rem rgba(95, 240, 196, .95); }
.t-interact { right: 6.85rem; bottom: 5.1rem; width: 4.3rem; height: 4.3rem; background: rgba(255, 255, 255, .92); color: #1b1d26; text-shadow: none; }
.t-jump { right: .9rem; bottom: 7rem; width: 4.4rem; height: 4.4rem; background: rgba(61, 123, 255, .7); }
.t-special { right: 11.2rem; bottom: 5.1rem; width: 4.3rem; height: 4.3rem; overflow: hidden; }
.t-special::before { content: ""; position: absolute; inset: 0; background: conic-gradient(var(--yel) calc(var(--c, 0) * 360deg), transparent 0); opacity: .75; }
.t-special::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: rgba(24, 26, 36, .8); }
.t-special span { position: relative; z-index: 1; }
.t-special.ready { border-color: #fff3b0; box-shadow: 0 0 1.1rem rgba(255, 210, 63, .9); animation: ready 1s ease-in-out infinite; }
.t-special.ready::after { background: radial-gradient(circle at 50% 35%, #ffe680, #ffb21f); }
.t-special.ready span { color: #2b1300; text-shadow: none; }

/* 터치일 때 HUD 조정 */
.touch #keys { display: none; }
.touch #subtitle { --side: 14rem; bottom: calc(var(--ex-b) + 1rem); }
.touch #toast { bottom: calc(var(--ex-b) + 5rem); }

/* ---------- 모달 공통 ---------- */
.modal { position: absolute; inset: 0; display: grid; place-items: center; grid-template-rows: 100%; /* definite row: max-height:100% on the cards now holds */ background: rgba(10, 12, 20, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: var(--ex-t) var(--ex-r) var(--ex-b) var(--ex-l); box-sizing: border-box; pointer-events: auto !important; }
.btn {
  display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 20px; border-radius: 14px;
  font-size: 16px; font-weight: 900; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); color: #fff;
  transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #ffe066, #ffc21f); color: #2a1600; border-color: #fff0a8; box-shadow: 0 4px 0 #c98a00; }
.btn.warn { background: linear-gradient(180deg, #ff6b6b, #e23a48); border-color: #ffb3b3; box-shadow: 0 4px 0 #9e1a2a; }
.btn.share { background: linear-gradient(180deg, #4e8cff, #2f64e0); border-color: #a9c6ff; box-shadow: 0 4px 0 #1b3f9c; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, .35); }

/* 엘리베이터 */
#elevator { z-index: 40; background: rgba(10, 12, 20, .35); }
.ev-panel { width: min(340px, 100%); max-height: 100%; overflow: auto; box-sizing: border-box; padding: 18px; border-radius: 20px; background: linear-gradient(160deg, #3a3f4d, #23262f); border: 2px solid #8b93a5; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 16px 40px rgba(0, 0, 0, .45); touch-action: pan-y; }
.ev-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ev-head h3 { margin: 0; font-size: 18px; font-weight: 900; }
.ev-arrow { width: 0; height: 0; border: 9px solid transparent; border-bottom: 13px solid var(--yel); margin-top: -10px; filter: drop-shadow(0 0 6px rgba(255, 210, 63, .8)); }
#ev-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.ev-btn { display: flex; align-items: center; gap: 12px; padding: 5px 10px 5px 6px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .12); text-align: left; }
.ev-btn .fl { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-family: var(--head-font); font-size: 18px; background: radial-gradient(circle at 50% 35%, #f4f6fa, #c4c9d4); color: #22252e; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 0 0 3px #6b7282; }
.ev-btn .tx { flex: 1; min-width: 0; }
.ev-btn .tx b { display: block; font-size: 15px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-btn .tx small { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-btn .ev-key { flex: none; font-size: 11px; opacity: .8; }
.ev-btn.sel { border-color: var(--yel); background: rgba(255, 210, 63, .14); }
.ev-btn.sel .fl { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 0 0 3px var(--yel), 0 0 14px rgba(255, 210, 63, .7); }
.ev-btn:hover .fl { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 0 0 3px var(--yel), 0 0 14px rgba(255, 210, 63, .7); }
.ev-btn.cur { opacity: .7; cursor: default; }
.ev-btn.cur .fl { background: radial-gradient(circle at 50% 35%, #fff3b0, #ffc21f); box-shadow: 0 0 0 3px #fff3b0, 0 0 14px rgba(255, 210, 63, .8); }
.ev-panel > .btn { width: 100%; }

/* ---------- 첫 화면 ---------- */
#title { position: absolute; inset: 0; z-index: 50; pointer-events: auto !important; background: linear-gradient(90deg, rgba(14, 16, 26, .86) 0, rgba(14, 16, 26, .6) 30rem, rgba(14, 16, 26, 0) 46rem); }
.t-panel {
  position: absolute; left: 0; top: 0; bottom: 0; width: min(420px, 100%); box-sizing: border-box;
  padding: calc(var(--sat) + clamp(18px, 4vh, 44px)) 24px calc(var(--sab) + 18px) calc(var(--sal) + clamp(20px, 3.4vw, 56px));
  display: flex; flex-direction: column; gap: clamp(10px, 2.2vh, 20px); overflow-y: auto; touch-action: pan-y;
  scrollbar-width: none;
}
.t-panel::-webkit-scrollbar { display: none; }
.logo { margin: 0; font-family: var(--head-font); font-weight: 400; line-height: .95; letter-spacing: -.01em; font-size: clamp(54px, 9vh, 88px); display: flex; flex-wrap: wrap; gap: 0 .18em; transform: rotate(-3deg); transform-origin: left bottom; }
.logo .l1 { color: #fff; text-shadow: 0 .06em 0 #2b2f3d, 0 .12em .3em rgba(0, 0, 0, .4); }
.logo .l2 { color: var(--yel); -webkit-text-stroke: .045em #2a1300; paint-order: stroke fill; text-shadow: .05em .07em 0 var(--red), 0 .14em .35em rgba(0, 0, 0, .45); }
.tagline { margin: 10px 0 0; font-size: 17px; font-weight: 700; color: #ffe9a8; display: inline-block; padding: 4px 12px; border-radius: 999px; background: rgba(255, 75, 92, .22); border: 1px solid rgba(255, 120, 120, .45); }
.t-menu { display: flex; flex-direction: column; gap: 10px; }
.mbtn { position: relative; display: block; text-align: left; padding: 12px 16px; border-radius: 16px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .1); transition: transform .12s, filter .12s; }
button.mbtn:hover { filter: brightness(1.1); transform: translateY(-1px); }
button.mbtn:active { transform: scale(.98); }
.mbtn b { display: block; font-family: var(--head-font); font-weight: 400; font-size: 25px; line-height: 1.15; }
.mbtn small { display: block; margin-top: 2px; font-size: 13.5px; font-weight: 700; opacity: .85; }
.mbtn em { position: absolute; right: 14px; top: 12px; font-style: normal; font-size: 12px; font-weight: 900; padding: 3px 9px; border-radius: 999px; background: rgba(42, 22, 0, .85); color: #ffe066; }
.m-story { background: linear-gradient(135deg, #ffe066, #ffb81f); color: #2a1600; border-color: #fff0a8; box-shadow: 0 5px 0 #c98a00, 0 10px 24px rgba(0, 0, 0, .3); }
.m-story b { font-size: 30px; }
.m-rush { background: linear-gradient(135deg, #ff6f61, #e2304a); border-color: #ffb3a8; box-shadow: 0 4px 0 #9e1a2a; }
.m-free { background: linear-gradient(135deg, rgba(78, 140, 255, .9), rgba(47, 100, 224, .9)); border-color: #a9c6ff; box-shadow: 0 4px 0 #1b3f9c; }
.floors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 9px; }
.floors button { min-height: 40px; padding: 0 6px; border-radius: 11px; background: rgba(255, 255, 255, .95); color: #1c3d8f; font-weight: 900; font-size: 13.5px; box-shadow: 0 3px 0 rgba(20, 40, 110, .55); transition: transform .12s; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 5px; overflow: hidden; }
.floors button i { flex: none; font-style: normal; font-weight: 900; font-size: 11px; letter-spacing: -.02em; line-height: 1; min-width: 20px; height: 18px; padding: 0 4px; box-sizing: border-box; display: inline-grid; place-items: center; border-radius: 6px; background: #1c3d8f; color: #fff; }
.floors button:hover { background: #fff; }
.floors button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(20, 40, 110, .55); }
.t-opts { display: flex; flex-direction: column; gap: 9px; }
.t-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.t-row .nm-btn { flex: 1 1 auto; }
.t-row .seg-lbl { white-space: nowrap; }
.t-row .seg button { min-width: 44px; }
.seg { display: flex; align-items: center; gap: 6px; }
.seg-lbl { font-size: 14px; font-weight: 700; color: var(--muted); margin-right: 4px; }
.seg button { min-width: 50px; min-height: 36px; border-radius: 10px; font-weight: 900; font-size: 15px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); }
.seg button[aria-pressed="true"] { background: #fff; color: #1b1d26; border-color: #fff; }
/* 난이도 칩 (첫 화면 맨 위 · 레벨 선택 창): 쉬움 초록 / 보통 노랑 / 어려움 빨강 */
.t-diff { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.dchip { min-height: 42px; padding: 4px 6px; border-radius: 12px; text-align: center; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22); color: rgba(255, 255, 255, .78); transition: transform .12s, filter .12s; min-width: 0; }
.dchip b { display: block; font-size: 15px; font-weight: 900; line-height: 1.15; }
.dchip small { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 700; line-height: 1.2; opacity: .8; overflow: hidden; word-break: keep-all; }
.dchip small:empty { display: none; }
.dchip:hover { filter: brightness(1.15); }
.dchip:active { transform: scale(.97); }
.dchip[aria-checked="true"] { color: #10251c; background: #7ef0c8; border-color: #c9ffe9; box-shadow: 0 3px 0 #17a57c; }
.dchip.d-normal[aria-checked="true"] { color: #2a1600; background: #ffe066; border-color: #fff0a8; box-shadow: 0 3px 0 #c98a00; }
.dchip.d-hard[aria-checked="true"] { color: #fff; background: #e2304a; border-color: #ffb3a8; box-shadow: 0 3px 0 #8f1424; }
.dchip[aria-checked="true"] small { opacity: .9; }
/* 1분 난동: 제목 옆에 일반 · 보스전 두 갈래 (한 줄) */
.m-rush { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; }
.r-hd { min-width: 0; }
.r-hd small { white-space: nowrap; }
.rush2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.rush2 button { min-height: 46px; padding: 5px 10px; border-radius: 11px; text-align: left; background: rgba(255, 255, 255, .95); color: #8f1424; box-shadow: 0 3px 0 rgba(110, 16, 30, .55); transition: transform .12s; min-width: 0; }
.rush2 button b { display: block; font-family: var(--head-font); font-weight: 400; font-size: 19px; line-height: 1.1; }
.rush2 button small { display: block; margin-top: 1px; font-size: 11.5px; font-weight: 700; color: #6b2a33; opacity: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rush2 button[data-mode="boss"] b::after { content: ""; display: inline-block; width: 17px; height: 12px; margin-left: 5px; vertical-align: 1px; background: #d92335; -webkit-mask: var(--crown) center / contain no-repeat; mask: var(--crown) center / contain no-repeat; }
.rush2 button:hover { background: #fff; }
.rush2 button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(110, 16, 30, .55); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.tg { min-height: 34px; padding: 0 12px 0 10px; border-radius: 999px; font-size: 13.5px; font-weight: 700; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22); display: inline-flex; align-items: center; gap: 7px; color: rgba(255, 255, 255, .75); }
.tg::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .3); }
.tg[aria-pressed="true"] { background: rgba(34, 199, 154, .22); border-color: rgba(70, 230, 180, .7); color: #fff; }
.tg[aria-pressed="true"]::before { background: #3ff0b8; box-shadow: 0 0 6px #3ff0b8; }
/* 화질: 토글과 같은 알약 높이의 세 칸 고르기 */
.gq { display: inline-flex; align-items: center; gap: 2px; min-height: 34px; box-sizing: border-box; padding: 2px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22); }
.gq-lbl { padding: 0 5px 0 9px; font-size: 13.5px; font-weight: 700; color: rgba(255, 255, 255, .75); white-space: nowrap; }
.gq button { min-height: 28px; padding: 0 9px; border-radius: 999px; font-size: 13px; font-weight: 800; color: rgba(255, 255, 255, .78); white-space: nowrap; }
.gq button:hover { background: rgba(255, 255, 255, .12); }
.gq button[aria-checked="true"] { background: #fff; color: #1b1d26; }
.t-help { margin: 0; font-size: 12.5px; line-height: 1.6; color: rgba(255, 255, 255, .7); }
.t-help .hi { white-space: nowrap; }
.ev-btn .fl.long { font-size: 15px; }
.t-help .kc { font-size: 11px; min-width: 1.6em; height: 1.6em; margin-right: 3px; }
/* 이름 정하기 (첫 화면 작은 버튼) */
.nm-btn { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 12px 4px 8px; border-radius: 12px; text-align: left; background: linear-gradient(135deg, rgba(34, 199, 154, .3), rgba(34, 199, 154, .12)); border: 1px solid rgba(70, 230, 180, .6); transition: transform .12s, filter .12s; min-width: 0; }
.nm-btn::before { content: ""; flex: none; width: 22px; height: 16px; background: var(--yel); -webkit-mask: var(--crown) center / contain no-repeat; mask: var(--crown) center / contain no-repeat; }
.nm-btn b { flex: none; font-size: 14px; font-weight: 900; }
.nm-btn small { min-width: 0; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-btn:hover { filter: brightness(1.12); }
.nm-btn:active { transform: scale(.98); }
:root { --crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 16'%3E%3Cpath d='M1 4l5 4 5-7 5 7 5-4-2 11H3z'/%3E%3C/svg%3E"); }
/* 이름 정하기 창 */
#names { z-index: 70; }
.n-card { width: min(380px, 100%); max-height: 100%; overflow-y: auto; touch-action: pan-y; box-sizing: border-box; padding: 20px; border-radius: 22px; background: rgba(28, 30, 42, .96); border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 10px; }
.n-card h3 { margin: 0 0 4px; font-family: var(--head-font); font-weight: 400; font-size: 30px; color: var(--yel); }
.n-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 10px; border-radius: 14px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14); }
.n-ic { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; }
.n-ic::after { content: ""; width: 17px; height: 13px; background: #2a1600; -webkit-mask: var(--crown) center / contain no-repeat; mask: var(--crown) center / contain no-repeat; }
.n-boss .n-ic { background: radial-gradient(circle at 50% 35%, #ffe680, #ffb81f); }
.n-mid .n-ic { background: radial-gradient(circle at 50% 35%, #8db4ff, #2f64e0); }
.n-mid .n-ic::after { width: 14px; height: 14px; background: #fff; -webkit-mask: var(--star) center / contain no-repeat; mask: var(--star) center / contain no-repeat; }
.n-me .n-ic { background: radial-gradient(circle at 50% 35%, #7ef0c8, #17a57c); }
.n-me .n-ic::after { width: 13px; height: 13px; background: #0b3d2c; border-radius: 50% 50% 40% 40%; -webkit-mask: none; mask: none; }
:root { --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 19'%3E%3Cpath d='M10 0l3 6.3 7 .9-5.1 4.8 1.3 6.9L10 15.6 3.8 18.9 5.1 12 0 7.2l7-.9z'/%3E%3C/svg%3E"); }
.n-lbl { flex: none; width: 62px; font-size: 14px; font-weight: 900; }
.n-row input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; box-sizing: border-box; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .25); background: #fff; color: #1b1d26; font: 700 16px var(--hud-font); user-select: text; -webkit-user-select: text; touch-action: manipulation; pointer-events: auto; }
.n-row input:focus { outline: none; border-color: var(--yel); box-shadow: 0 0 0 3px rgba(255, 210, 63, .35); }
.n-row input::placeholder { color: #9a9daa; font-weight: 500; }
.n-note { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.45; }
.n-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.n-btns .btn { min-height: 44px; font-size: 15px; padding: 0 10px; }

/* ---------- 레벨 선택 ---------- */
#levels { z-index: 65; }
.lv-card-wrap { width: min(560px, 100%); max-height: 100%; box-sizing: border-box; padding: 18px; border-radius: 22px; background: rgba(28, 30, 42, .96); border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.lv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.lv-head h3 { margin: 0; font-family: var(--head-font); font-weight: 400; font-size: 30px; color: var(--yel); }
.lv-stars { font-size: 15px; font-weight: 900; color: #ffe066; white-space: nowrap; }
.lv-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; touch-action: pan-y; margin: 0 -4px; padding: 2px 4px 4px; }
.lv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lv-card { position: relative; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 8px 10px 8px 8px; border-radius: 14px; text-align: left; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18); transition: transform .12s, filter .12s; min-width: 0; }
.lv-card:hover { filter: brightness(1.15); }
.lv-card:active { transform: scale(.98); }
.lv-n { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-family: var(--head-font); font-size: 22px; color: #2a1600; background: radial-gradient(circle at 50% 35%, #fff3b0, #ffc21f); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.lv-card.mid .lv-n { color: #fff; background: radial-gradient(circle at 50% 35%, #8db4ff, #2f64e0); }
.lv-card.boss .lv-n { color: #fff; background: radial-gradient(circle at 50% 35%, #ff8a7c, #d92335); }
.lv-tx { flex: 1; min-width: 0; }
.lv-tx b { display: block; font-size: 15px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-tx small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-st { display: flex; align-items: center; gap: 6px; margin-top: 3px; min-width: 0; }
.lv-st .stars { flex: none; font-style: normal; font-size: 15px; letter-spacing: 1px; color: #ffd23f; line-height: 1; text-shadow: 0 1px 0 #2a1600; }
.lv-st em { font-style: normal; font-size: 11.5px; font-weight: 700; color: rgba(255, 255, 255, .72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lv-st .lock { flex: none; width: 12px; height: 14px; background: rgba(255, 255, 255, .6); -webkit-mask: var(--lock) center / contain no-repeat; mask: var(--lock) center / contain no-repeat; }
.lv-tag { position: absolute; top: -7px; right: 8px; padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 900; background: #2f64e0; color: #fff; border: 1px solid rgba(255, 255, 255, .5); }
.lv-card.boss .lv-tag { background: #d92335; }
.lv-card.next { border-color: var(--yel); background: rgba(255, 210, 63, .14); box-shadow: 0 0 0 2px rgba(255, 210, 63, .35); }
.lv-card.locked { opacity: .5; filter: saturate(.3); cursor: not-allowed; }
.lv-card.locked:hover { filter: saturate(.3); }
.lv-card.locked .lv-n { background: rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .8); }
.lv-card-wrap > .btn { width: 100%; min-height: 44px; }
:root { --lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 20'%3E%3Cpath d='M4 8V6a5 5 0 0 1 10 0v2h1.5A1.5 1.5 0 0 1 17 9.5v9a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 1 18.5v-9A1.5 1.5 0 0 1 2.5 8zm2.5 0h5V6a2.5 2.5 0 0 0-5 0z'/%3E%3C/svg%3E"); }

/* ---------- 멈춤 ---------- */
#pause { z-index: 60; }
.p-card { width: min(380px, 100%); max-height: 100%; overflow-y: auto; touch-action: pan-y; box-sizing: border-box; padding: 22px; border-radius: 22px; background: rgba(28, 30, 42, .94); border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.p-card h3 { margin: 0 0 14px; font-family: var(--head-font); font-weight: 400; font-size: 32px; color: var(--yel); }
.p-btns { display: flex; flex-direction: column; gap: 10px; }
.p-keys { list-style: none; margin: 18px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.p-keys li { display: flex; align-items: center; gap: 7px; }
.p-keys .kc { font-size: 11px; flex: none; }

/* ---------- 청구서 ---------- */
#bill { z-index: 60; background: rgba(10, 12, 20, .7); }
.b-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; width: min(400px, 100%); max-height: 100%; }
.receipt { position: relative; width: 100%; min-height: 0; flex: 0 1 auto; display: flex; background: var(--paper); color: #24242c; border-radius: 6px 6px 0 0; box-shadow: 0 18px 40px rgba(0, 0, 0, .45); animation: print .7s cubic-bezier(.2, .8, .3, 1); transform-origin: top; margin-bottom: 12px; }
.receipt::after { content: ""; position: absolute; left: 0; right: 0; bottom: -12px; height: 12px; background: linear-gradient(-45deg, transparent 8px, var(--paper) 0) 0 0 / 16px 12px repeat-x, linear-gradient(45deg, transparent 8px, var(--paper) 0) 0 0 / 16px 12px repeat-x; }
@keyframes print { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 -20px 0); } }
.r-scroll { flex: 1; overflow-y: auto; touch-action: pan-y; padding: 22px 24px 18px; font-variant-numeric: tabular-nums; }
.r-co { margin: 0; text-align: center; font-size: 13px; font-weight: 700; color: #777; letter-spacing: .02em; }
.r-h { margin: 4px 0 2px; text-align: center; font-family: var(--head-font); font-weight: 400; font-size: 30px; color: #1b1b22; }
.r-meta { margin: 0 0 12px; text-align: center; font-size: 12.5px; color: #888; padding-bottom: 12px; border-bottom: 2px dashed #cfcabb; }
.r-items { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.r-items td { padding: 5px 0; vertical-align: top; }
.r-items td.n { font-weight: 700; }
.r-items td.c { color: #888; text-align: right; padding: 5px 10px; white-space: nowrap; width: 1%; }
.r-items td.a { text-align: right; font-weight: 900; white-space: nowrap; width: 1%; }
.r-items tr.empty td { color: #999; text-align: center; padding: 14px 0; }
.r-items tr.sec td { padding: 10px 0 3px; border-top: 1px dashed #c9c2b4; color: #a4452c; font-weight: 900; font-size: 12.5px; }
.r-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 12px; border-top: 2px dashed #cfcabb; }
.r-total span { font-weight: 900; font-size: 16px; }
.r-total b { font-family: var(--head-font); font-weight: 400; font-size: 32px; color: #d92335; }
.r-best { margin: 4px 0 0; text-align: right; font-size: 13px; font-weight: 700; color: #777; }
.r-best .nb { display: inline-block; margin-right: 6px; padding: 2px 8px; border-radius: 999px; background: #ffd23f; color: #2a1600; font-weight: 900; animation: ready 1s ease-in-out infinite; }
.r-relief { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13.5px; font-weight: 700; }
.r-relief .rb { flex: 1; height: 10px; border-radius: 99px; background: #ebe6d6; overflow: hidden; }
.r-relief .rb i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #22c79a, #6be0b8); transition: width 1s .5s cubic-bezier(.2, .8, .3, 1); }
.r-relief b { min-width: 3em; text-align: right; color: #148a69; font-weight: 900; }
.r-rank { text-align: center; margin: 16px 0 6px; }
.stamp { display: inline-block; padding: 6px 16px 4px; border: 3px solid #d92335; border-radius: 10px; color: #d92335; font-family: var(--head-font); font-size: 26px; transform: rotate(-5deg); box-shadow: inset 0 0 0 2px rgba(217, 35, 53, .25); animation: stamp .45s .55s cubic-bezier(.3, 1.6, .5, 1) both; }
.stamp:empty { display: none; }
@keyframes stamp { from { transform: rotate(-5deg) scale(2.2); opacity: 0; } }
.r-comment { margin: 6px 0 0; text-align: center; font-size: 14px; font-weight: 700; color: #555; line-height: 1.5; }
.r-comment:empty { display: none; }
.b-btns { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.b-btns .primary { grid-column: 1 / -1; min-height: 54px; font-size: 18px; }
/* 레벨 결과: 별 세 개 (빈 별 → 하나씩 찍힘), 실패 통지서는 빨간 제목 */
.r-stars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 12px; padding-bottom: 12px; border-bottom: 2px dashed #cfcabb; text-align: center; }
.r-stars .rs i { display: block; font-style: normal; font-size: 34px; line-height: 1; color: #d6cfbd; }
.r-stars .rs.on i { color: #ffb81f; text-shadow: 0 2px 0 #9a6200; animation: starIn .45s var(--d, .7s) cubic-bezier(.3, 1.6, .5, 1) both; }
.r-stars .rs small { display: block; margin-top: 3px; font-size: 11.5px; font-weight: 700; color: #888; line-height: 1.25; }
.r-stars .rs.on small { color: #6b4a00; }
@keyframes starIn { from { transform: scale(2.4) rotate(-20deg); opacity: 0; } }
#bill.fail .r-h { color: #d92335; }
#bill.lv.next .b-btns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#bill.lv.fail .b-btns { grid-template-columns: 1fr; }
#bill.lv .b-btns .btn { padding-left: 6px; padding-right: 6px; }

/* ---------- 장면 전환 ---------- */
#fade { position: absolute; inset: 0; z-index: 80; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #2b3350, #12141e 70%); opacity: 0; pointer-events: auto !important; }
#fade.blank .f-card { display: none; }
.f-card { text-align: center; padding: 0 24px; }
.clock { position: relative; width: clamp(88px, 18vmin, 150px); aspect-ratio: 1; margin: 0 auto 18px; border-radius: 50%; background: #fffdf6; box-shadow: 0 0 0 6px var(--yel), 0 0 0 11px #2a1600, 0 14px 30px rgba(0, 0, 0, .45); }
.clock::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; background: repeating-conic-gradient(from -1deg, #2a2a33 0 2deg, transparent 2deg 30deg); -webkit-mask: radial-gradient(circle, transparent 80%, #000 81%); mask: radial-gradient(circle, transparent 80%, #000 81%); }
.clock i { position: absolute; left: 50%; bottom: 50%; transform-origin: 50% 100%; border-radius: 99px; background: #22232b; transition: transform 1.1s cubic-bezier(.3, .8, .3, 1); }
.clock .h { width: 7%; height: 26%; margin-left: -3.5%; }
.clock .m { width: 4.5%; height: 38%; margin-left: -2.25%; background: var(--red); }
.clock .dot { position: absolute; left: 50%; top: 50%; width: 10%; height: 10%; margin: -5% 0 0 -5%; border-radius: 50%; background: #22232b; }
.f-time { margin: 0; font-family: var(--head-font); font-size: clamp(30px, 7vmin, 56px); color: var(--yel); line-height: 1.1; }
.f-title { margin: 8px 0 0; font-size: clamp(20px, 4vmin, 30px); font-weight: 900; }
.f-sub { margin: 6px 0 0; font-size: clamp(14px, 2.6vmin, 18px); font-weight: 700; color: var(--muted); }
.f-time:empty, .f-title:empty, .f-sub:empty { display: none; }
/* 레벨 카드: 위에 "레벨 3 · 7층 · 보통", 아래에 목표 */
.f-lv { display: inline-block; margin: 0 0 14px; padding: 4px 14px; border-radius: 999px; font-size: clamp(14px, 2.6vmin, 18px); font-weight: 900; color: #2a1600; background: var(--yel); box-shadow: 0 3px 0 #c98a00; }
.f-goal { margin: 14px auto 0; max-width: 34em; font-size: clamp(13px, 2.3vmin, 16px); font-weight: 700; color: #ffe9a8; padding: 6px 14px; border-radius: 12px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); }
.f-lv:empty, .f-goal:empty { display: none; }

/* ---------- 불러오는 중 ---------- */
#boot { position: absolute; inset: 0; z-index: 90; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #2b3350, #12141e 70%); text-align: center; transition: opacity .5s; pointer-events: auto !important; }
#boot.out { opacity: 0; pointer-events: none !important; }
.logo.sm { font-size: 56px; justify-content: center; }
.boot-t { margin: 18px 0 0; font-weight: 700; color: var(--muted); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .4; } }

/* ---------- 휴대폰 세로: HUD 두 줄 ---------- */
@media (max-aspect-ratio: 4/5) {
  html { font-size: clamp(11px, 2.9vw, 15px); }
  #hud { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto 1fr auto; grid-template-areas: "tc tr" "tl tl" ". ." "keys keys"; row-gap: .55rem; }
  .hud-tc { align-items: stretch; }
  #stress { width: auto; min-width: 0; padding: 0 .8rem; gap: .5rem; }
  .s-lbl { font-size: 1.05rem; }
  #stress-pct { font-size: 1.1rem; min-width: 2.8em; }
  #timer { align-self: center; }
  #money { padding: 0 .8rem; gap: .5rem; }
  #money-lbl { font-size: 1rem; }
  #money-val { font-size: 1.25rem; }
  #mission { max-width: 72%; }
  #tasks { max-width: 72%; }
  .touch #subtitle { --side: 1rem; bottom: calc(var(--ex-b) + 13.5rem); }
  .touch #toast { bottom: calc(var(--ex-b) + 17.5rem); }
  #banner { top: 36%; }

  /* 첫 화면 → 아래쪽 시트 */
  #title { background: linear-gradient(180deg, rgba(14, 16, 26, .55), rgba(14, 16, 26, 0) 22%, rgba(14, 16, 26, 0) 40%, rgba(14, 16, 26, .82) 62%); }
  .t-panel { top: auto; width: 100%; max-height: 100%; padding: 0 calc(var(--sar) + 18px) calc(var(--sab) + 16px) calc(var(--sal) + 18px); gap: 12px; }
  .t-brand { position: fixed; left: calc(var(--sal) + 20px); top: calc(var(--sat) + 26px); }
  .logo { font-size: clamp(52px, 15vw, 76px); }
  .t-menu { padding: 16px; margin: 0 -6px; border-radius: 22px 22px 18px 18px; background: rgba(20, 22, 34, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); }
  .t-help { display: none; }
}
@media (max-aspect-ratio: 4/5) and (max-height: 700px) {
  .t-brand { position: static; }
}
@media (max-width: 460px) {
  .lv-grid { grid-template-columns: 1fr; }
  .lv-card-wrap { padding: 14px; }
  .dchip small { white-space: normal; font-size: 10.5px; }
}

/* ---------- 낮은 가로 화면 (휴대폰 가로) ---------- */
@media (max-height: 520px) and (min-aspect-ratio: 4/5) {
  #mission h2 { font-size: 1.7rem; }
  #mission { padding: .5rem .9rem .55rem; }
  #tasks li { padding: .38rem .9rem .38rem .7rem; font-size: 1.12rem; }
  .t-panel { width: min(560px, 100%); padding-top: calc(var(--sat) + 14px); gap: 10px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto 1fr; align-content: start; align-items: start; column-gap: 14px; }
  .t-menu { grid-row: 2 / span 2; }
  .t-brand { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
  .logo { font-size: 44px; }
  .tagline { margin: 0; font-size: 13px; }
  .t-menu { gap: 8px; }
  .mbtn { padding: 8px 12px; border-radius: 13px; }
  .mbtn b, .m-story b { font-size: 21px; }
  .mbtn small { font-size: 12px; }
  .floors { margin-top: 6px; gap: 5px; }
  .floors button { min-height: 34px; font-size: 12px; gap: 3px; padding: 0 3px; }
  .floors button i { display: none; }
  .t-opts { gap: 8px; }
  .tg { min-height: 32px; }
  .gq { min-height: 32px; }
  .gq button { min-height: 26px; }
  .t-help { grid-column: 2; font-size: 11.5px; }
  #title { background: linear-gradient(90deg, rgba(14, 16, 26, .88) 0, rgba(14, 16, 26, .6) 520px, rgba(14, 16, 26, 0) 640px); }
  .p-card { padding: 16px; }
  .p-card h3 { font-size: 24px; margin-bottom: 10px; }
  .p-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .p-btns .btn { min-height: 42px; font-size: 14.5px; padding: 0 10px; }
  .p-card { width: min(520px, 100%); }
  .p-keys { grid-template-columns: repeat(3, 1fr); margin-top: 12px; padding-top: 10px; gap: 6px 10px; font-size: 12px; }
  .b-wrap { flex-direction: row; align-items: stretch; width: min(640px, 100%); height: 100%; }
  .receipt { flex: 1 1 auto; max-height: calc(100% - 12px); }
  .r-scroll { padding: 14px 18px; }
  .r-h { font-size: 24px; }
  .b-btns { width: 170px; grid-template-columns: 1fr; align-content: center; }
  .b-btns .primary { grid-column: auto; }
  .touch #subtitle { --side: 16rem; }
  #banner { top: 26%; }
  .ev-panel { padding: 12px; }
  .ev-head { margin-bottom: 8px; }
  #ev-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
  .ev-panel { width: min(520px, 100%); }
  .ev-btn .fl { width: 36px; height: 36px; font-size: 16px; }
  .ev-btn { padding: 3px 8px 3px 4px; }
  .ev-btn .tx small { display: none; }
  .n-card { width: min(560px, 100%); padding: 12px 16px; gap: 6px; }
  .n-card h3 { font-size: 22px; margin: 0; }
  .n-row { padding: 3px 6px 3px 8px; }
  .n-row input { height: 34px; }
  .n-note { font-size: 11.5px; }
  .n-btns { grid-template-columns: repeat(4, 1fr); margin-top: 2px; }
  .n-btns .btn { min-height: 38px; font-size: 14px; }
  .nm-btn { min-height: 32px; }
  #hearts { height: 1.6rem; }
  .dchip { min-height: 36px; padding: 3px 4px; }
  .dchip b { font-size: 13.5px; }
  .dchip small { display: none; } /* (좁은 가로 화면: 설명은 레벨 선택 창 · 툴팁에) */
  .m-rush { display: block; }
  .lv-diff .dchip small { display: block; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
  .rush2 { gap: 5px; margin-top: 6px; }
  .rush2 button { min-height: 38px; padding: 3px 8px; }
  .rush2 button b { font-size: 16px; }
  .lv-card-wrap { width: min(640px, 100%); padding: 10px 14px; gap: 7px; }
  .lv-head h3 { font-size: 22px; }
  .lv-card { min-height: 50px; padding: 5px 8px 5px 6px; }
  .lv-n { width: 32px; height: 32px; font-size: 18px; }
  .lv-card-wrap > .btn { min-height: 36px; }
  .clock { width: clamp(60px, 14vmin, 90px); margin-bottom: 10px; }
  .f-lv { margin-bottom: 8px; }
  .f-goal { margin-top: 8px; }
  .r-stars .rs i { font-size: 26px; }
  #bill.lv.next .b-btns { grid-template-columns: 1fr; }
  .b-btns .btn { min-height: 40px; }
}

/* 흔들림 약하게 / 움직임 줄이기 */
.calm #vignette.beat, .calm .ready, .calm #stress.hot .s-bar { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 낮은 화질 단계 (느린 컴퓨터: gfx.js 가 html 에 .lowgfx): HUD 뒤 흐림은 3D 화면이 바뀔 때마다 다시 계산돼서 끈다 */
.lowgfx * { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
