/* 탭탭! 스카이라인 v1.2 — '노선도' 디자인: 종이색 바탕, 먹색 굵은 선, 동그란 역, 도시마다 강조색 하나.
   상자·그림자·그러데이션·이모지를 쓰지 않는다. 구분은 선·여백·글자 크기로. 밤(body.night)에는 종이와 먹을 뒤집는다. */
:root {
  --paper: #F1EEE4; --ink: #1F2329; --mut: #8A877D; --line: #D9D4C5; --ac: #D8432F;
  --c-heart: #D8432F; --c-focus: #2F6DB5; --c-magnet: #E3A51A; --c-net: #2F8F74; --c-crane: #1F2329; --c-brace: #8A877D;
  --f: Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --fn: Outfit, Pretendard, -apple-system, "Apple SD Gothic Neo", system-ui, sans-serif;
  --sl: max(18px, env(safe-area-inset-left)); --sr: max(18px, env(safe-area-inset-right));
  --st: env(safe-area-inset-top); --sb: env(safe-area-inset-bottom);
  color-scheme: light dark;
}
body.night { --ink: #F1EEE4; --mut: #94918A; --line: #3A3F47; --c-crane: #3A3F47; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--f); font-weight: 600;
  word-break: keep-all; overflow-wrap: anywhere; -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
[hidden] { display: none !important; }
.num { font-family: var(--fn); font-feature-settings: "tnum"; }
.ic { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: square; vertical-align: -0.12em; flex: none; }
.sp { flex: 1; }
#scene, #fx { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; }
#fx { pointer-events: none; z-index: 2; }

/* 맨 위 줄: 어디·몇 시·날씨, 소리·처음 화면 */
.top { position: fixed; z-index: 9; left: var(--sl); right: var(--sr); top: calc(var(--st) + 10px); height: 28px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.where { font: 700 10.5px/1 var(--fn); letter-spacing: 0.14em; white-space: nowrap; }
.tools { display: flex; gap: 2px; margin-right: -6px; pointer-events: auto; }
.ib { width: 34px; height: 34px; display: grid; place-items: center; font-size: 19px; }

/* 노선: 선 한가운데에 역 */
.metro { position: relative; display: flex; justify-content: space-between; align-items: center; height: 18px; }
.metro::before { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 5px; margin-top: -2.5px; background: var(--ink); }
.metro i { position: relative; flex: none; width: 17px; height: 17px; border-radius: 50%; background: var(--paper); border: 4px solid var(--ink); transition: background 0.2s, border-color 0.2s, transform 0.2s; }
.metro i.done { background: var(--ink); }
.metro i.on { border-color: var(--ac); transform: scale(1.18); }

/* 플레이 화면 */
#hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.hudtop { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--st) + 46px) var(--sr) 10px var(--sl); background: var(--paper); }
.r1 { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; margin-top: 8px; gap: 10px; }
.r1 #stName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r1 .num { white-space: nowrap; font-weight: 600; }
.r1 .num span { color: var(--mut); }
#hNow { display: inline-block; font-weight: 800; }
#hNow.pop { transform: scale(1.25); }
.r2 { display: flex; align-items: center; gap: 12px; margin-top: 10px; height: 16px; }
.hp { display: flex; gap: 4px; align-items: center; }
/* 안전 = 하트 그림(조건 판의 아이템 그림과 같게). 가진 것은 강조색 채움, 잃은 것은 회색 테두리 */
.hp svg { width: 16px; height: 16px; fill: var(--ac); stroke: var(--ac); stroke-width: 1.8; }
.hp svg.e { fill: none; stroke: var(--mut); }
/* 안전망: 누르는 버튼이 아니라 하트 옆 작은 회색 표시(그물 + 개수) */
.netg { display: flex; align-items: center; gap: 2px; margin-left: -4px; color: var(--mut); font-size: 11px; font-weight: 700; }
.netg .ic { font-size: 15px; }
.hp.hit { animation: hb 0.5s; }
@keyframes hb { 20% { transform: translateX(-5px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
.feverg { display: flex; gap: 3px; align-items: center; }
.feverg i { width: 7px; height: 7px; border: 1.5px solid var(--ink); }
.feverg i.on { background: var(--ink); }
.feverg b { font-size: 11px; font-weight: 700; background: var(--ac); color: #fff; padding: 2px 7px; animation: blink 0.5s infinite alternate; }
@keyframes blink { to { opacity: 0.7; } }
.coin { margin-left: auto; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.coin::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #E3A51A; }
.wob { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 10.5px; color: var(--mut); }
.wob u { flex: 1; height: 3px; background: var(--line); text-decoration: none; position: relative; }
.wob u i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ink); transition: width 0.25s; }
.wob.warn u i, .wob.warn b { background: var(--ac); }
.wob.warn b { background: none; color: var(--ac); }
.wob b { font-weight: 600; }
.combo { position: absolute; left: var(--sl); top: calc(var(--st) + 158px); font-size: 11.5px; font-weight: 700; border: 2px solid var(--ink); padding: 2px 8px; background: var(--paper); }
.combo.fever { background: var(--ink); color: var(--paper); }
.hint { position: absolute; left: 50%; bottom: calc(var(--sb) + 132px); transform: translateX(-50%); background: var(--ink); color: var(--paper); font-size: 13px; padding: 7px 12px; white-space: nowrap; animation: nudge 1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translate(-50%, -5px); } }

/* 아래 물건 토큰: 집중은 왼쪽 끝, 자석은 오른쪽 끝(화면 가장자리에서 같은 여백), 가운데 내려놓기 */
.dock { position: absolute; left: var(--sl); right: var(--sr); bottom: calc(var(--sb) + 16px); height: 84px; }
#focusBtn { position: absolute; left: 0; bottom: 0; }
#magnetBtn { position: absolute; right: 0; bottom: 0; }
.tk { pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; }
.tk i { position: relative; width: 60px; height: 60px; border-radius: 50%; border: 4px solid var(--ink); background: var(--paper); display: grid; place-items: center; font-size: 26px; font-style: normal; transition: transform 0.1s; }
.tk:active i { transform: scale(0.92); }
.tk b { position: absolute; right: -8px; top: -8px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--ink); color: var(--paper); font: 700 12px/22px var(--fn); text-align: center; }
.tk.act i { background: var(--ink); color: var(--paper); }
.tk.act b { background: var(--ac); color: #fff; }
/* 내려놓기 버튼(11-26): 화면 탭 대신. 가운데 큰 먹색 원, 흔들리는 중이 아니면 테두리만 */
.drop { pointer-events: auto; touch-action: none; position: absolute; left: 50%; bottom: 0; width: 84px; height: 84px; margin-left: -42px; border-radius: 50%; border: 4px solid var(--ink); background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 38px; transition: transform 0.08s; }
.drop .ic { stroke-width: 2.2; }
.drop:active { transform: scale(0.92); background: var(--ac); border-color: var(--ac); color: #fff; }
.drop.wait { background: var(--paper); color: var(--ink); }

/* 처음 한 번 화면 안내(기획 12 v3 ③): 먹색 안개(모달 뒤 안개 — 원칙 2의 유일한 예외) 위에 종이 판.
   위 HUD 띠와 아래 버튼은 안개 위로 올려, 번호가 가리키는 곳이 밝게 보이게 한다. .guide 는 쌓임 맥락을 만들지 않는다. */
.guide { position: absolute; inset: 0; }
.guide .fog { position: absolute; inset: 0; z-index: 5; background: rgba(31, 35, 41, 0.62); pointer-events: auto; }
body.guiding .hudtop, body.guiding .dock { z-index: 6; }
body.guiding .tk span { color: #F1EEE4; }
.gpanel { position: absolute; z-index: 7; left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); top: 184px; background: var(--paper); border-top: 3px solid var(--ink); padding: 14px 16px 16px; overflow-y: auto; overscroll-behavior: contain; pointer-events: auto; }
.gpanel .k { display: block; font: 700 10.5px/1 var(--fn); letter-spacing: 0.14em; color: var(--ac); }
.gpanel h3 { margin: 6px 0 8px; font-size: 21px; font-weight: 800; letter-spacing: -0.03em; }
.gl { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--mut); line-height: 1.4; }
.gl b { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
.gl b svg { width: 13px; height: 13px; fill: var(--ac); stroke: var(--ac); stroke-width: 1.8; vertical-align: -1px; margin-left: 4px; }
.gl .no { width: 22px; height: 22px; border-radius: 50%; background: var(--ac); color: #fff; font: 800 12px/22px var(--fn); text-align: center; }
.gpanel .go { margin-top: 8px; }
.pin { position: absolute; z-index: 8; width: 18px; height: 18px; border-radius: 50%; background: var(--ac); color: #fff; font: 800 11px/18px var(--fn); text-align: center; outline: 2px solid var(--paper); pointer-events: none; }

/* 판정 글자 + 눈금자 */
.judge { position: fixed; z-index: 4; left: var(--sl); top: calc(var(--st) + 198px); pointer-events: none; white-space: nowrap; transform-origin: 0 100%; animation: judge 0.75s ease-out forwards; }
.judge b { display: block; font-size: 40px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; text-shadow: 3px 0 var(--paper), -3px 0 var(--paper), 0 3px var(--paper), 0 -3px var(--paper), 2px 2px var(--paper), -2px 2px var(--paper), 2px -2px var(--paper), -2px -2px var(--paper); }
.judge.p b { font-size: 60px; }
.judge.s b { color: var(--mut); }
.judge.m b { color: var(--ac); }
.judge small { display: table; font-size: 12.5px; font-weight: 600; margin: 6px 0 0 -5px; padding: 2px 5px; color: var(--ac); background: var(--paper); }
.judge.s small, .judge.g small { color: var(--ink); }
.ruler { position: relative; width: 128px; height: 14px; margin-top: 8px; background: var(--paper); outline: 5px solid var(--paper); border-left: 1.5px solid var(--mut); border-right: 1.5px solid var(--mut); }
.ruler::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 1.5px; background: var(--mut); }
.ruler .g { position: absolute; top: 3px; height: 8px; border: 1.5px solid var(--ink); background: var(--paper); }
.ruler .p { position: absolute; top: 3px; height: 8px; background: var(--ink); }
.ruler .m { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1.5px; background: var(--ac); }
/* 0%부터 보이게 한다 — 기기가 느려 애니메이션 시작이 늦어도 글자는 바로 보인다 */
@keyframes judge { 0% { transform: scale(0.7); opacity: 1; } 14% { transform: scale(1.12); } 26% { transform: scale(1); } 75% { opacity: 1; } 100% { transform: translateY(-10px); opacity: 0; } }

/* 번쩍임: 평평한 색으로 아주 잠깐 */
.flash { position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: 0; }
.flash.p { background: var(--ink); animation: fl1 0.22s ease-out; }
.flash.m { background: var(--ac); animation: fl2 0.4s ease-out; }
.flash.focus { background: var(--c-focus); animation: fl2 0.45s ease-out; }
.flash.fever { background: var(--ac); animation: fl2 0.7s ease-out; }
@keyframes fl1 { from { opacity: 0.1; } to { opacity: 0; } }
@keyframes fl2 { from { opacity: 0.22; } to { opacity: 0; } }
body.fever::after { content: ""; position: fixed; inset: 0; z-index: 2; pointer-events: none; box-shadow: inset 0 0 0 5px var(--ac); }

/* 알림 한 줄 */
.toast { position: fixed; z-index: 6; left: var(--sl); right: var(--sr); bottom: calc(var(--sb) + 118px); width: fit-content; max-width: calc(100vw - 36px); background: var(--ink); color: var(--paper); padding: 9px 12px; font-size: 14px; font-weight: 700; line-height: 1.35; pointer-events: none; animation: drop 0.25s ease-out; }
.toast small { display: block; font-size: 11.5px; font-weight: 500; opacity: 0.75; margin-top: 2px; }
@keyframes drop { from { transform: translateY(8px); opacity: 0; } }

/* 시작 화면 */
.home { position: fixed; inset: 0; z-index: 8; display: flex; flex-direction: column; justify-content: flex-end; pointer-events: none; }
.hhead { position: absolute; left: var(--sl); right: var(--sr); top: calc(var(--st) + 56px); }
.hhead h1 { margin: 0; font-size: 60px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.hhead p { margin: 9px 0 0; font-size: 12.5px; font-weight: 500; color: var(--mut); }
.hpanel { pointer-events: auto; background: var(--paper); padding: 14px var(--sr) calc(var(--sb) + 16px) var(--sl); max-height: 72dvh; overflow-y: auto; border-top: 3px solid var(--ink); }
.lab { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; display: flex; justify-content: space-between; align-items: center; }
.lab small { font-weight: 500; color: var(--mut); font-size: 11px; margin-left: 6px; }
.cline { margin: 12px calc(-1 * var(--sr)) 14px calc(-1 * var(--sl)); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.cline::-webkit-scrollbar { display: none; }
.ctrack { position: relative; display: flex; width: max-content; padding: 0 var(--sr) 0 var(--sl); }
.ctrack::before { content: ""; position: absolute; left: calc(var(--sl) + 33px); right: calc(var(--sr) + 33px); top: 7px; height: 5px; background: var(--ink); }
.cty { position: relative; display: flex; flex-direction: column; align-items: center; font-size: 13px; font-weight: 700; line-height: 1.25; width: 66px; flex: none; white-space: nowrap; }
.cty i { width: 19px; height: 19px; border-radius: 50%; background: var(--paper); border: 4px solid var(--ink); margin-bottom: 6px; }
.cty.cur i { border-color: var(--ac); border-width: 5px; transform: scale(1.18); }
.cty.lock { color: var(--mut); }
.cty small { font: 600 11px var(--fn); color: var(--mut); display: flex; align-items: center; gap: 3px; margin-top: 1px; }
.lst { border-top: 2px solid var(--ink); margin-top: 8px; }
.li { display: flex; align-items: center; gap: 10px; width: 100%; height: 43px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.li > .ic { font-size: 19px; }
.li .nm { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.li .nm small { font-size: 10.5px; font-weight: 500; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 3px; margin-left: auto; flex: none; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.8px solid var(--ink); }
.dots i.f { background: var(--ink); }
.li .pr { flex: none; width: 58px; height: 26px; display: grid; place-items: center; font: 700 12px var(--fn); border: 2px solid var(--ink); }
.li.no .pr { border-color: var(--line); color: var(--mut); }
.li.max .pr { border-color: transparent; color: var(--mut); font-family: var(--f); font-size: 11px; }
.li.ready:active .pr { background: var(--ink); color: var(--paper); }
.go { pointer-events: auto; width: 100%; height: 52px; margin-top: 14px; background: var(--ink); color: var(--paper); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: 16px; font-weight: 700; }
.go .ic { font-size: 20px; stroke-width: 2.2; }
.go:active { background: var(--ac); color: #fff; }
.go.alt { background: none; color: var(--ink); border: 2px solid var(--ink); justify-content: center; }

/* 아래에서 올라오는 판(결과) · 화면을 덮는 판(카드) */
.banner { position: fixed; z-index: 7; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 3px solid var(--ink); padding: 16px var(--sr) calc(var(--sb) + 16px) var(--sl); animation: up 0.28s ease-out; max-height: 82dvh; overflow-y: auto; }
.banner.full { top: 0; border-top: 0; max-height: none; padding-top: calc(var(--st) + 52px); animation: fade 0.2s ease-out; display: flex; flex-direction: column; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.banner .k { font: 700 10.5px/1 var(--fn); letter-spacing: 0.14em; }
.banner h2 { margin: 8px 0 0; font-size: 30px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.15; }
.banner p { margin: 6px 0 0; font-size: 12.5px; font-weight: 500; color: var(--mut); line-height: 1.5; }
.banner p b { color: var(--ink); font-weight: 700; }
.cards { margin-top: 20px; border-bottom: 2px solid var(--ink); }
.card { display: flex; width: 100%; height: 104px; border-top: 2px solid var(--ink); align-items: stretch; }
.card .pic { flex: none; width: 104px; display: grid; place-items: center; color: #fff; font-size: 56px; transition: transform 0.1s; }
.card .pic .ic { stroke-width: 1.5; }
.card:active .pic { transform: scale(0.94); }
.card .t { padding: 13px 0 0 14px; min-width: 0; }
.card .t b { display: flex; align-items: baseline; gap: 8px; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.card .t b em { font: 800 22px var(--fn); font-style: normal; }
.card .t small { display: block; font-size: 12px; font-weight: 500; color: var(--mut); margin-top: 3px; line-height: 1.45; }
.card .t small.ch { color: var(--ink); font-weight: 700; font-family: var(--fn); }
.foot { margin-top: auto; padding-top: 14px; font-size: 11.5px; font-weight: 500; color: var(--mut); }
.endhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.grade { font: 800 76px/0.9 var(--fn); letter-spacing: -0.04em; color: var(--ac); }
.grade.gB, .grade.gC { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; border-top: 2px solid var(--ink); }
.stats span { padding: 8px 0 7px; border-bottom: 1px solid var(--line); font-size: 10.5px; font-weight: 500; color: var(--mut); }
.stats b { display: block; font: 700 17px var(--fn); color: var(--ink); }
.earn { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; font-size: 12px; font-weight: 500; color: var(--mut); }
.earn .coin { font-size: 20px; color: var(--ink); margin: 0; }
.best { font-size: 12px; font-weight: 700; margin-top: 4px; min-height: 16px; }
.btns { display: grid; grid-template-columns: 1.5fr 1fr; gap: 8px; }

/* 로딩: 역이 차례로 채워진다 */
.load { position: fixed; inset: 0; z-index: 20; background: var(--paper); display: grid; place-content: center; justify-items: center; gap: 16px; transition: opacity 0.2s; }
.load.off { opacity: 0; pointer-events: none; }
.load .metro { width: 132px; }
.load .metro i { animation: fill 1.2s infinite; }
.load .metro i:nth-child(2) { animation-delay: 0.2s; } .load .metro i:nth-child(3) { animation-delay: 0.4s; }
@keyframes fill { 0%, 70%, 100% { background: var(--paper); } 25%, 50% { background: var(--ink); } }
.nogl { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--paper); z-index: 10; }
@media (max-height: 700px) {
  .hhead h1 { font-size: 46px; } .hhead { top: calc(var(--st) + 46px); }
  .li { height: 38px; } .card { height: 92px; } .card .pic { width: 92px; font-size: 48px; }
  .gpanel { padding: 10px 14px 12px; } .gpanel h3 { font-size: 18px; margin: 4px 0 4px; }
  .gl { padding: 3px 0; font-size: 11.5px; line-height: 1.32; } .gl b { font-size: 12.5px; } .gpanel .go { height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .hint, .feverg b, .load .metro i { animation: none; } }

/* 건설 영상(docs/plans/11-REPLAY.md): 화면 전체 종이 판, 가운데 9:16 미리보기, 아래 먹 막대 진행 */
.reel { position: fixed; inset: 0; z-index: 9; background: var(--paper); display: flex; flex-direction: column; padding: calc(var(--st) + 18px) var(--sr) calc(var(--sb) + 16px) var(--sl); animation: fade 0.2s ease-out; }
.reel h2 { margin: 8px 0 12px; font-size: 30px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.15; }
.reel .stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: center; }
.reel .stage canvas, .reel .stage video { height: 100%; max-width: 100%; aspect-ratio: 9 / 16; object-fit: contain; border: 2px solid var(--ink); background: var(--paper); }
.reel .bar { height: 5px; margin-top: 16px; background: var(--line); }
.reel .bar i { display: block; height: 100%; width: 0; background: var(--ink); }
.reel .btns { grid-template-columns: 1fr 1fr; }
.reel a.go { text-decoration: none; }
.reelgo { justify-content: center; gap: 8px; }
.reelgo .ic { font-size: 20px; }
