/* Layout: 한 화면 포인트앤클릭. 위 = 장면(3:4), 아래 = 소지품 트레이, 확대 보기는 종이 카드 오버레이.
   램프 아래 어두운 상점 한 가지 분위기로 고정(단일 테마). */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --night: #17130f;
  --wall: #2a2420;
  --brass: #c9a35a;
  --paper: #efe4cc;
  --ink: #2b2119;
  --fg: #efe4cc;
  --muted: #a8977c;
  --rose: #b8706a;
  --display: "Nanum Myeongjo", "Batang", "AppleMyungjo", serif;
  --body: "Gowun Dodum", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--night); color: var(--fg); font-family: var(--body); }
img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap { max-width: 480px; margin: 0 auto; padding-inline: calc(16px + var(--safe-left)) calc(16px + var(--safe-right)); padding-block: calc(12px + var(--safe-top)) calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; }
.top { display: flex; align-items: flex-end; gap: 10px; }
.top .titles { flex: 1; min-width: 0; }
.back { background: none; border: 1px solid #c9a35a55; color: var(--brass); width: 36px; height: 36px; border-radius: 50%; font-size: 1.05rem; cursor: pointer; flex: none; align-self: center; }
#game { display: flex; flex-direction: column; gap: 10px; }

/* 목록 화면 */
#home { display: flex; flex-direction: column; gap: 14px; }
.brand h1 { font-size: 1.6rem; letter-spacing: .02em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.player-name { display: block; margin-top: 6px; min-height: 44px; max-width: 100%; border: 0; padding: 4px 0; background: none; color: var(--brass); font: inherit; font-size: .8rem; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.nickname-setup { border: 1px solid #c9a35a66; border-radius: 14px; padding: 18px; background: linear-gradient(145deg, #29332c, #1b211d); box-shadow: 0 12px 28px #0004, inset 0 1px #ffffff0a; }
.nickname-eyebrow { color: var(--brass); font-size: .7rem; letter-spacing: .12em; }
.nickname-setup h2 { margin: 8px 0; font-family: var(--display); font-size: 1.1rem; color: var(--paper); }
.nickname-setup p { margin: 8px 0; color: #c6bda8; font-size: .8rem; line-height: 1.6; }
.nickname-setup form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.nickname-setup input { flex: 1 1 130px; min-width: 0; width: 100%; min-height: 48px; border: 1px solid #c9a35a66; border-radius: 8px; padding: 10px 12px; color: var(--paper); background: #111913; font: inherit; font-size: 16px; }
.nickname-setup input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.nickname-setup form button { flex: 1 1 130px; min-height: 48px; border: 1px solid #d7bb7f; border-radius: 8px; padding: 10px 12px; color: var(--ink); background: linear-gradient(#eeddb4, #c9a35a); font: inherit; cursor: pointer; }
.nickname-setup form button:disabled { opacity: .6; cursor: wait; }
.nickname-setup .nickname-skip { min-height: 44px; border: 0; padding: 4px 0; color: #c6bda8; background: none; font: inherit; font-size: .78rem; text-decoration: underline; cursor: pointer; }
.nickname-setup #nicknameMsg { margin: 4px 0 0; color: #ffd0bd; }
.brand .ai-notice, .ai-art-label { margin: 0; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.card .ai-art-label { color: #6b5a48; }
.legal-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 16px; }
.legal-links button { min-height: 44px; border: 0; padding: 4px 0; background: none; color: var(--muted); font: inherit; font-size: .72rem; text-decoration: underline; cursor: pointer; }
.policy-body { overflow-wrap: anywhere; }
.policy-body .tw { max-width: 100%; overflow-x: auto; }
.policy-body .license-text { white-space: pre-wrap; font-family: system-ui, sans-serif; font-size: .78rem; }
.policy-body table { border-collapse: collapse; width: 100%; font-size: .8rem; }
.policy-body th, .policy-body td { padding: 6px; border-bottom: 1px solid #2b211933; text-align: left; vertical-align: top; }
.policy-body a, .card a[href^="mailto:"] { color: var(--ink); }
.concepts { display: flex; flex-direction: column; gap: 14px; }
.concept { border: 1px solid #c9a35a33; border-radius: 8px; padding: 16px; background: linear-gradient(160deg, #2a2219, #1c1712); display: flex; flex-direction: column; gap: 10px; }
.concept .meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .75rem; color: var(--muted); letter-spacing: .06em; }
.concept .genre { color: var(--accent, var(--brass)); }
.concept { overflow: hidden; border-radius: 16px; box-shadow: 0 14px 28px #0003, inset 0 1px #ffffff08; }
.concept-cover { position: relative; height: 156px; margin: -16px -16px 4px; isolation: isolate; background: #151917; }
.concept-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, #1e1916 0%, #17161100 80%); z-index: -1; }
.concept-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; z-index: -2; }
.concept-cover > span { position: absolute; left: 18px; bottom: 14px; color: #f1d9a6; font-size: .67rem; letter-spacing: .2em; }
.concept-cover i { display: block; font-size: .7rem; letter-spacing: .02em; font-style: normal; margin-top: 6px; color: #d2c6b7; }
.scene-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .7rem; color: var(--muted); }
.scene-tools .pill { min-height: 44px; font-size: .72rem; }
.scene-tools [aria-pressed="true"] { color: var(--brass); border-color: var(--brass); background: #c9a35a18; }
.scene.show-targets .hs::before { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; transform: translate(-50%, -50%); border: 1px solid #ffe7b0; border-radius: 50%; background: #e0b667; box-shadow: 0 0 0 5px #1b1b2188, 0 0 12px #f5d39299; pointer-events: none; }
.scene { border: 1px solid #c9a35a4a; border-radius: 12px; box-shadow: 0 14px 32px #0009, 0 0 0 4px #2c272055; }
.back, .pill, .icon-btn, .row button, .btn { min-height: 44px; min-width: 44px; }
.concept h2 { font-family: var(--display); font-size: 1.25rem; margin: 0; text-wrap: balance; }
.concept p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.stages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stage { border: 1px solid #c9a35a44; border-radius: 6px; background: #0003; color: var(--fg); font: inherit; text-align: left; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-height: 64px; }
.stage .no { font-size: .68rem; letter-spacing: .08em; color: var(--brass); }
.stage .nm { font-family: var(--display); font-weight: 700; font-size: .9rem; word-break: keep-all; }
.stage .st { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stage.boss { border-color: #b8706a88; }
.stage.boss .no { color: var(--rose); }
.stage.clear { background: #c9a35a14; }
.stage.clear .st { color: var(--brass); }
.stage:disabled { opacity: .45; cursor: default; }
.sub { font-family: var(--display); font-size: 1rem; margin: 6px 0 0; }
.upcoming { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.upcoming li { border: 1px dashed #a8977c44; border-radius: 6px; padding: 8px 10px; font-size: .85rem; display: flex; flex-direction: column; gap: 2px; }
.upcoming small { color: var(--muted); font-size: .7rem; }
.room-name { font-size: .72rem; letter-spacing: .14em; color: var(--brass); }
h1 { font-family: var(--display); font-weight: 800; font-size: 1.2rem; margin: 2px 0 0; text-wrap: balance; }
.timer { font-variant-numeric: tabular-nums; color: var(--brass); font-size: .95rem; }
.msg { min-height: 3em; font-size: .92rem; color: var(--muted); line-height: 1.5; margin: 0; }

.scene { position: relative; width: 100%; max-width: 100%; aspect-ratio: 3 / 4; border-radius: 6px; overflow: hidden; background: var(--wall); box-shadow: 0 10px 30px #0009; touch-action: manipulation; }
.scene .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.layer { position: absolute; inset: 0; }
#overlays img { position: absolute; pointer-events: none; }
#clues { pointer-events: none; }
#clues svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hs { position: absolute; background: transparent; border: 0; padding: 0; cursor: pointer; border-radius: 6px; transition: box-shadow .15s, background .15s; }
.scene:not(.debugging) .hs { min-width: 44px; min-height: 44px; }
#hotspots { z-index: 1; }
#ff { z-index: 2; }
.hs:hover, .hs:focus-visible { background: #c9a35a1f; box-shadow: 0 0 0 2px #c9a35a88, 0 0 18px #c9a35a55; outline: none; }
.hs.go::after { content: attr(data-arrow); position: absolute; inset: 0; display: grid; place-items: center; color: var(--brass); font-size: 1.4rem; text-shadow: 0 0 6px #000; }

/* 편집 모드 */
.scene.debugging .hs { box-shadow: inset 0 0 0 2px #7fd4ff; background: #7fd4ff22; }
.scene.debugging .hs::before { content: attr(data-id); position: absolute; left: 2px; top: 1px; font: 10px/1 monospace; color: #fff; background: #0009; padding: 1px 3px; border-radius: 2px; }
.scene.drawing .hs { pointer-events: none; }
.scene.drawing { cursor: crosshair; }
.draw-box { position: absolute; border: 2px dashed #ffe08a; background: #ffe08a22; pointer-events: none; }
.debug { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px dashed #7fd4ff88; border-radius: 6px; font-size: .85rem; }
.debug code { font-size: .8rem; color: #ffe08a; word-break: break-all; }
.debug-rooms { display: flex; gap: 6px; flex-wrap: wrap; }

.tray { display: flex; flex-direction: column; gap: 8px; }
.tray-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.label { font-size: .75rem; letter-spacing: .1em; color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inv { display: flex; gap: 8px; flex-wrap: wrap; min-height: 56px; align-items: center; }
.inv .empty { font-size: .8rem; color: var(--muted); }
.slot { width: 54px; height: 54px; border: 1px solid #c9a35a55; border-radius: 6px; background: #0004; display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--fg); }
.slot.sel { border-color: var(--brass); box-shadow: 0 0 0 2px #c9a35a77; background: #c9a35a1a; }
.slot svg, .slot img { width: 36px; height: 36px; }
.slot .emo, .fly .emo { font-size: 28px; line-height: 1; }
.pill { background: none; border: 1px solid #c9a35a77; color: var(--brass); font: inherit; font-size: .82rem; border-radius: 20px; padding: 6px 12px; cursor: pointer; }
.pill.ghost { border-color: #a8977c55; color: var(--muted); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.ov { position: fixed; inset: 0; background: #000c; display: grid; place-items: center; padding: max(16px, var(--safe-top)) max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left)); z-index: 10; overflow-y: auto; }
.card { background: var(--paper); color: var(--ink); border-radius: 12px; max-width: 380px; width: 100%; max-height: calc(100vh - max(16px, var(--safe-top)) - max(16px, var(--safe-bottom))); max-height: calc(100dvh - max(16px, var(--safe-top)) - max(16px, var(--safe-bottom))); overflow-y: auto; overscroll-behavior: contain; padding: 20px; box-shadow: 0 20px 50px #000a; display: flex; flex-direction: column; gap: 12px; }
.card > * { flex-shrink: 0; }
.object-art { display: inline-block; width: 38px; height: 38px; vertical-align: middle; }
.balance .pan .object-art { width: 22px; height: 22px; }
.order button .object-art, .balance .items .object-art { display: block; margin: 0 auto 4px; }
.card { border: 1px solid #d6b57e; background-image: radial-gradient(ellipse at top, #fff6df, transparent 65%), linear-gradient(135deg, #ffffff22, #8b60340d); }
.ov { backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.puzzle-status { min-height: 1.6em; font-size: .8rem !important; text-align: center; color: #685844; }
.simon button:disabled { cursor: default; }
.card h2 { font-family: var(--display); margin: 0; font-size: 1.1rem; text-wrap: balance; }
.card p { margin: 0; line-height: 1.6; font-size: .95rem; }
.card .pre { white-space: pre-line; font-family: var(--display); line-height: 1.85; font-size: .97rem; }
.card svg.view, .card img.view { width: 100%; height: auto; display: block; border-radius: 2px; }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.row button, .btn { font: inherit; border: 0; border-radius: 4px; padding: 8px 14px; cursor: pointer; background: var(--ink); color: var(--paper); }
.row button.ghost { background: none; color: var(--ink); border: 1px solid #2b211955; }

.dial { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dial input { width: 46px; height: 56px; text-align: center; font-family: var(--display); font-size: 1.6rem; font-weight: 700; border: 1px solid #2b211955; border-radius: 4px; background: #ffffffa0; color: var(--ink); }
.word input { width: 100%; height: 48px; font-family: var(--display); font-size: 1.3rem; text-align: center; border: 1px solid #2b211955; border-radius: 4px; background: #ffffffa0; color: var(--ink); }
.cycle { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cycle button { width: 64px; height: 76px; border: 1px solid #2b211955; border-radius: 6px; background: #ffffff90; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font: inherit; color: var(--ink); padding: 4px; }
.cycle .sym { font-size: 1.8rem; line-height: 1; }
.cycle .dot { width: 28px; height: 28px; border-radius: 50%; border: 1px solid #0003; }
.cycle .cap { font-size: .7rem; }
.clockctl { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.clockctl span { text-align: center; font-size: .85rem; }
.shake { animation: sh .35s; }
@keyframes sh { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.end { text-align: center; }
.end .big { font-family: var(--display); font-size: 1.6rem; font-weight: 800; }

/* ── 손맛·연출 ── */
#overlays img.full { left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; }
#overlays img.flicker { animation: flicker 2.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flicker { 0%, 100% { opacity: 1; } 30% { opacity: .82; } 55% { opacity: .95; } 70% { opacity: .78; } }
.scene.enter .bg, .scene.enter #overlays { animation: roomIn .45s ease-out; }
@keyframes roomIn { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
.fx { pointer-events: none; overflow: hidden; }
.fx i { position: absolute; width: calc(3px * var(--s)); height: calc(3px * var(--s)); border-radius: 50%; background: #ffe9b0; opacity: 0; animation: mote var(--d) linear var(--dl) infinite; }
@keyframes mote { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: .55; } 85% { opacity: .35; } 100% { transform: translate(24px, -140px); opacity: 0; } }
.fx.stars i { background: #dff3ff; animation-name: twinkle; }
@keyframes twinkle { 0%, 100% { opacity: 0; } 50% { opacity: .8; transform: scale(1.4); } }
.fx.bubbles i { width: calc(6px * var(--s)); height: calc(6px * var(--s)); background: none; border: 1px solid #bfe8ffaa; animation-name: bubble; }
@keyframes bubble { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: .7; } 100% { transform: translate(8px, -260px); opacity: 0; } }
.fx.petals i { width: calc(5px * var(--s)); height: calc(3px * var(--s)); background: #f0c0d8; border-radius: 50% 0; animation-name: petal; }
@keyframes petal { 0% { transform: translate(0, -60px) rotate(0); opacity: 0; } 20% { opacity: .7; } 100% { transform: translate(-40px, 160px) rotate(360deg); opacity: 0; } }
.fx.snow i { width: calc(4px * var(--s)); height: calc(4px * var(--s)); background: #ffffff; box-shadow: 0 0 4px #ffffffaa; animation-name: snow; }
@keyframes snow { 0% { transform: translate(0, -120px); opacity: 0; } 15% { opacity: .85; } 50% { transform: translate(14px, 40px); } 100% { transform: translate(-6px, 220px); opacity: 0; } }
.fx.steam i { width: calc(110px * var(--s)); height: calc(60px * var(--s)); background: #ffffff; filter: blur(18px); animation-name: steam; }
@keyframes steam { 0% { transform: translate(0, 0); opacity: 0; } 30% { opacity: .14; } 100% { transform: translate(-30px, -220px); opacity: 0; } }

/* 반딧불이 */
#ff { pointer-events: none; }
.ff { position: absolute; pointer-events: auto; background: none; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center; }
.ff i { width: 38%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, #fffbd8 0 25%, #f1dc6a 45%, #f1dc6a00 70%); box-shadow: 0 0 10px 3px #f1dc6a55; animation: glow 3.4s ease-in-out var(--dl) infinite; }
@keyframes glow { 0%, 100% { opacity: .12; transform: translate(0, 0) scale(.8); } 50% { opacity: .7; transform: translate(2px, -3px) scale(1); } }
.ff.caught i { animation: caught .7s ease-out forwards; }
@keyframes caught { 0% { opacity: 1; transform: scale(1.4); } 100% { opacity: 0; transform: translate(10px, -60px) scale(.4); } }
.scene.debugging .ff { box-shadow: inset 0 0 0 2px #ffe08a; }
.concept .ffc { color: #e8d06a; }
.concept-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stage .stars { color: var(--brass); font-weight: 400; letter-spacing: -.05em; }

/* 소지품 날아가기 */
.fly { position: fixed; left: 0; top: 0; width: 40px; height: 40px; z-index: 30; pointer-events: none; filter: drop-shadow(0 0 8px #c9a35a); }
.fly svg, .fly img { width: 100%; height: 100%; }
.slot.pop { animation: pop .35s ease-out; }
@keyframes pop { 40% { transform: scale(1.18); } }

/* 자물쇠 풀림·실패 */
#dial.ok { animation: unlock .48s ease-out forwards; }
@keyframes unlock { 0% { filter: none; transform: none; } 35% { transform: scale(1.06); filter: drop-shadow(0 0 14px #c9a35a) brightness(1.15); } 100% { transform: scale(.96); opacity: .4; filter: drop-shadow(0 0 4px #c9a35a); } }
.card.bad { animation: bad .45s; }
@keyframes bad { 30% { box-shadow: 0 0 0 3px #a0453e, 0 20px 50px #000a; } }

/* 소리 순서 퍼즐 */
.pads { display: flex; gap: 10px; justify-content: center; align-items: flex-end; flex-wrap: wrap; }
.pads button { min-width: 60px; min-height: 72px; border: 1px solid #2b211955; border-radius: 8px; background: #ffffff90; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; font: inherit; font-family: var(--display); font-weight: 700; color: var(--ink); padding: 6px; }
.pads button svg { width: calc(46px * var(--sz)); height: auto; }
.pads button.hit { animation: hit .5s ease-out; }
@keyframes hit { 0% { background: var(--c); transform: translateY(2px) rotate(-4deg); } 50% { transform: rotate(3deg); } 100% { background: #ffffff90; } }
.seq { display: flex; gap: 6px; justify-content: center; }
.seq i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #2b211977; }
.seq i.on { background: var(--ink); }

/* 밀어 맞추기 */
.slide { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px; background: #2b2119; padding: 3px; border-radius: 4px; aspect-ratio: 1; }
.slide button { border: 0; padding: 0; background: #e9dcc0; cursor: pointer; aspect-ratio: 1; display: block; }
.slide button.blank { background: #2b2119; cursor: default; }
.slide button svg { width: 100%; height: 100%; display: block; }
.mir { cursor: pointer; }

/* 새 퍼즐 */
.wires { position: relative; display: grid; grid-template-columns: 1fr 1fr; column-gap: 34%; }
.wires .wl { position: absolute; left: 30%; width: 40%; top: 0; height: 100%; pointer-events: none; }
.wires .col { display: flex; flex-direction: column; gap: 8px; }
.wires button, .sliders .btn, .order button, .balance .items button, .simon button { font: inherit; border: 1px solid #2b211955; border-radius: 6px; background: #ffffff90; color: var(--ink); cursor: pointer; padding: 6px 8px; }
.wires button { height: 36px; border-left: 6px solid var(--c); }
.wires .col:last-child button { border-left-width: 1px; border-right: 6px solid var(--c); }
.wires button.on, .order button.on, .balance .items button.on { background: #c9a35a55; }
.sliders { display: flex; gap: 10px; justify-content: center; }
.sliders .sl { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 54px; }
.sliders b { font-family: var(--display); font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.sliders span { font-size: .72rem; text-align: center; }
#pv { pointer-events: none; overflow: hidden; margin-bottom: 4px; }
#pv:empty { display: none; }
.simon { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.simon button { height: 64px; background: color-mix(in srgb, var(--c) 45%, #fff); }
.simon button.hit { animation: shine .45s; }
@keyframes shine { 0% { background: var(--c); box-shadow: 0 0 18px var(--c); } 100% { } }
.rotate button svg { transition: transform .18s; }
.maze, .lights { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px; background: #2b2119; padding: 3px; border-radius: 4px; aspect-ratio: 1; max-width: 260px; margin: 0 auto; width: 100%; }
.maze i { background: #3a3428; border-radius: 2px; }
.maze i.seen { background: #6a5c44; } .maze i.wall { background: #120d08; }
.maze i.goal { background: #2f6b5a; box-shadow: inset 0 0 0 2px #8fe0c0; }
.maze i.me { background: #ffd36a; box-shadow: 0 0 10px #ffd36a; }
.mazectl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lights button { border: 0; border-radius: 4px; background: #3a3428; color: #ffffff55; font-size: 1.2rem; cursor: pointer; }
.lights button.on { background: #ffd36a; color: #5a4020; box-shadow: 0 0 12px #ffd36a99; }
.balance .beam { display: flex; justify-content: space-between; border-bottom: 4px solid #7a5a34; padding: 0 6px 4px; transition: transform .3s; min-height: 48px; align-items: flex-end; margin: 6px 18px 26px; }
.balance .pan { font-size: 1.4rem; display: flex; flex-direction: column; align-items: center; }
.balance .pan small, .balance .items small, .order small { font-size: .68rem; display: block; }
.balance .items, .order { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.balance .items button, .order button { min-width: 58px; font-size: 1.3rem; }
.morse .mout { font-size: 1.3rem; letter-spacing: .15em; text-align: center; min-height: 1.6em; font-family: var(--display); }
.spot svg { cursor: crosshair; }
.safedial svg { width: 190px; height: 190px; display: block; margin: 0 auto; }
.safedial svg g { transition: transform .15s; }
.safedial .dlog { text-align: center; font-family: var(--display); min-height: 1.4em; font-size: .9rem; }

/* 탈출 성공 */
.end { position: relative; }
.sparks { position: absolute; left: 50%; top: 45%; pointer-events: none; }
.sparks i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #c9a35a; animation: spark 1.1s ease-out forwards; transform: rotate(var(--a)) translateX(0); }
@keyframes spark { 0% { opacity: 1; transform: rotate(var(--a)) translateX(0) scale(1); } 100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--r)) scale(.3); } }
.stars-big { font-size: 1.8rem; letter-spacing: .1em; }
.stars-big span { color: #2b211933; display: inline-block; }
.stars-big span.on { color: #c9a35a; animation: starIn .5s ease-out both; animation-delay: calc(.35s + var(--i) * .25s); }
@keyframes starIn { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 70% { transform: scale(1.3); } 100% { transform: none; opacity: 1; } }
.card .star-help { text-align: center; font-size: .75rem; opacity: .6; }
#endText { min-height: 3.6em; cursor: pointer; }

@media (prefers-reduced-motion: reduce) { .shake { animation: none; } .hs { transition: none; } .ff i { animation: none; opacity: .45; } #overlays img.flicker { animation: none; } }

/* ── 플랫폼 공통 ── */
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
html:not(.ready) .wrap { visibility: hidden; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.brand h1 { white-space: nowrap; } /* 버튼이 많아 자리가 모자라면 제목 대신 버튼 줄이 아래로 내려가요 */
.brand-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid #c9a35a55; background: none; color: var(--brass); font-size: 1.05rem; cursor: pointer; }
.brand-meta { display: flex; gap: 8px; align-items: center; margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.brand-meta:empty { display: none; }
.rating { border: 1px solid #c9a35a88; color: var(--brass); border-radius: 4px; padding: 1px 6px; font-size: .72rem; letter-spacing: .04em; }
.card .tog { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #2b211922; font-size: .95rem; }
.card .tog { cursor: pointer; min-height: 44px; }
.card .tog em { margin-left: auto; margin-right: 10px; font-style: normal; font-size: .8rem; color: #2b211999; }
.card .tog input:checked + i + em, .card .tog em.on { color: var(--ink); font-weight: 700; }
.card .tog input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.card .tog i { order: 3; position: relative; flex: none; width: 50px; height: 28px; border-radius: 14px; background: #2b211926; border: 1px solid #2b211955; transition: background .2s; }
.card .tog i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0005; transition: transform .2s; }
.card .tog input:checked + i { background: var(--ink); border-color: var(--ink); }
.card .tog input:checked + i::after { transform: translateX(22px); background: #f0c060; }
.card .tog input:focus-visible + i { outline: 2px solid #f0c060; outline-offset: 2px; }
.card .info p { font-size: .82rem; opacity: .75; margin: 4px 0 0; }
button:disabled { opacity: .6; cursor: default; }

/* 앱인토스: 게임 화면 오른쪽 위에 토스 닫기 버튼이 겹쳐 떠 있으므로 그 자리를 비워 둬요. */
[data-platform="toss"] .wrap { padding-top: calc(var(--safe-top) + 8px); }
[data-platform="toss"] .brand-row, [data-platform="toss"] #game .top { padding-right: 92px; }
@media (max-width: 360px) {
  [data-platform="toss"] #game .top { display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; }
  [data-platform="toss"] #game .timer { grid-column: 2; justify-self: start; }
  [data-platform="toss"] #game h1 { font-size: 1rem; word-break: keep-all; }
}

/* ---------- 보상형 광고 · 친구 초대 ---------- */
.invite-notice { margin: 0 0 20px; padding: 18px; background: linear-gradient(135deg, #203a30, #14251f); border: 1px solid #c9a35a66; border-radius: 12px; box-shadow: 0 6px 20px #0003, inset 0 1px #eadcb61a; }
.invite-notice h2 { margin: 6px 0; font-size: 1.1rem; color: var(--paper); }
.invite-notice p { margin: 8px 0; font-size: .88rem; line-height: 1.7; }
.invite-notice small { display: block; margin-top: 8px; color: #d1c7a8; font-size: .76rem; line-height: 1.6; }
.invite-notice .code { color: #f0cf7f; letter-spacing: .1em; white-space: nowrap; }
.invite-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.invite-actions > button { min-height: 44px; padding: 8px 14px; font: inherit; font-size: .88rem; cursor: pointer; border-radius: 6px; border: 1px solid #c9a35a88; background: #dfc68b; color: #241f17; }
.invite-actions > .nickname-skip { background: none; color: #dfc68b; }
.card .pending-invite { margin: 12px 0; padding: 12px; border: 1px solid #a77c3b80; border-radius: 6px; background: #eadab3; }
.card .pending-invite p { margin: 4px 0 8px; font-size: .86rem; }
.card .invite-link { box-sizing: border-box; width: 100%; margin-top: 8px; min-height: 44px; font: 16px ui-monospace, monospace; padding: 8px; border: 1px solid #2b211966; border-radius: 4px; color: var(--ink); background: #fffaf0; }
.stage.early { border-style: dashed; opacity: 1; cursor: pointer; }
.stage.early .st em { display: block; margin-top: 2px; font-style: normal; font-weight: 700; color: var(--accent, #c9a35a); }
.card .bonus { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 4px; padding: 10px; border: 1px dashed #2b211944; border-radius: 6px; }
.card .bonus p { margin: 0 0 2px; font-size: .78rem; letter-spacing: .08em; color: #2b2119aa; text-align: center; }
.card .bonus button { font: inherit; font-size: .9rem; min-height: 44px; border-radius: 4px; padding: 8px 12px; cursor: pointer; border: 0; background: var(--ink); color: var(--paper); }
.card .bonus button.ghost { background: none; color: var(--ink); border: 1px solid #2b211955; }
.card .bonus button:disabled { opacity: .7; cursor: default; }
.card .ad-note, .card .invite-gift { font-size: .85rem; color: #2b2119cc; }

/* ---------- 친구 · 랭킹 ---------- */
.card .muted-note { font-size: .82rem; color: #2b2119aa; margin: 6px 0; }
.card .online-err { font-size: .85rem; color: #a3392b; margin: 6px 0; min-height: 0; }
.card .online-err:empty { display: none; }
.card .online-ok { font-size: .88rem; font-weight: 700; color: #3f6b35; }
.card .me-card { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid #2b211922; }
.card .me-card small { display: block; font-size: .72rem; color: #2b2119aa; }
.card .me-card b { font-size: 1.05rem; }
.card .code { letter-spacing: .18em; font-family: ui-monospace, monospace; }
.card button.sm, .card .sm { min-height: 36px; min-width: 44px; padding: 4px 10px; font: inherit; font-size: .85rem; border-radius: 4px; cursor: pointer; }
.card .ghost.sm { background: none; color: var(--ink); border: 1px solid #2b211955; }
.card .add-friend { display: flex; gap: 6px; margin: 10px 0 0; }
.card .add-friend input { flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 1rem; padding: 6px 10px; border: 1px solid #2b211966; border-radius: 4px; background: #fffaf0; color: var(--ink); text-transform: uppercase; }
.card #nameForm input { text-transform: none; }
.card .add-friend button, .card .wide-btn { min-height: 44px; font: inherit; border: 0; border-radius: 4px; padding: 8px 14px; cursor: pointer; background: var(--ink); color: var(--paper); }
.card .wide-btn { display: block; width: 100%; margin-top: 8px; }
.card .wide-btn.ghost { background: none; color: var(--ink); border: 1px solid #2b211955; }
.card .list-h { font-size: .85rem; margin: 14px 0 4px; letter-spacing: .04em; color: #2b2119cc; }
.card .friend-list, .card .rank-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.card .friend-list li { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid #2b211918; }
.card .friend-list .who { flex: 1; min-width: 0; }
.card .friend-list .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .friend-list small, .card .rank-list small { font-size: .76rem; color: #2b2119aa; }
.card li.empty { justify-content: center; color: #2b2119aa; font-size: .88rem; padding: 14px 0; border: 0; }
.card .tabs { display: flex; gap: 4px; margin: 4px 0 8px; border-bottom: 1px solid #2b211933; }
.card .tabs button { flex: 1; min-height: 40px; font: inherit; background: none; border: 0; border-bottom: 3px solid transparent; color: #2b2119aa; cursor: pointer; }
.card .tabs button[aria-selected="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.card .rank-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid #2b211918; }
.card .rank-list li.me { background: #f0c06033; border-radius: 4px; }
.card .rank-list .rk { width: 2.2em; text-align: center; font-weight: 700; }
.card .rank-list li:nth-child(-n+3):not(.empty) .rk { color: #b8862e; }
.card .rank-list.mine { margin-top: 6px; border-top: 2px dotted #2b211944; }
.card .rank-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .rank-list .pt { text-align: right; font-weight: 700; }
.card .rank-list .pt small { display: block; font-weight: 400; }
.card .fr-sum { font-size: .9rem; margin: 0 0 4px; }
.card .fr-table { width: 100%; border-collapse: collapse; font-size: .85rem; table-layout: fixed; }
.card .fr-table tr:first-child th:first-child { width: 3.6em; }
.card .fr-table th, .card .fr-table td { padding: 4px 6px; border-bottom: 1px solid #2b211918; text-align: left; }
.card .fr-table tr:first-child th { font-size: .76rem; color: #2b2119aa; font-weight: 400; }
.card .fr-table tr.them td:nth-child(2), .card .fr-table tr.me td:nth-child(3) { font-weight: 700; background: #f0c06026; }
.card .fr-table .none { color: #2b211966; }
#frBody { max-height: 56vh; overflow-y: auto; }
.card .keep { margin-top: 10px; padding-top: 4px; border-top: 1px dashed #2b211933; }
.card .keep .row { justify-content: flex-start; }
.card .code-in { display: block; width: 100%; box-sizing: border-box; min-height: 44px; margin: 6px 0; font: inherit; font-size: 1rem; padding: 6px 10px; border: 1px solid #2b211966; border-radius: 4px; background: #fffaf0; color: var(--ink); text-transform: uppercase; letter-spacing: .08em; }
.card .rank-list .flag { min-width: 36px; min-height: 36px; background: none; border: 0; color: #2b211966; cursor: pointer; font-size: 1rem; }
.card .rank-list .flag:hover, .card .rank-list .flag:focus-visible { color: #a3392b; }

/* ---------- 상점 ---------- */
.card .shop-list { list-style: none; margin: 6px 0 0; padding: 0; }
.card .shop-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #2b211918; }
.card .shop-list li.featured { background: #f0c06022; border-radius: 6px; padding: 10px 8px; border: 1px solid #b8862e55; }
.card .shop-list .who { flex: 1; min-width: 0; }
.card .shop-list .who b { display: block; }
.card .shop-list small { display: block; font-size: .78rem; color: #2b2119aa; line-height: 1.4; }
.card .shop-list button { flex: none; min-width: 84px; min-height: 44px; font: inherit; font-weight: 700; border: 0; border-radius: 4px; padding: 8px 12px; cursor: pointer; background: var(--ink); color: var(--paper); }
.card .shop-list button:disabled { opacity: .55; cursor: default; }
.card .shop-note { font-size: .74rem; line-height: 1.5; }
.card .linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; }
/* 초대 보상 */
.card .invite-rewards { margin: 12px 0; }
.card .invited-list { list-style: none; margin: 6px 0 0; padding: 0; }
.card .invited-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #2b211922; font-size: .88rem; }
.card .invited-list small { color: #2b2119aa; white-space: nowrap; }
