/* 도깨비 장터길 — 한지·먹·오방색. 색은 토큰만 덮는다(kit gb-ui.css 위에) */
:root {
  --gb-bg: #241812;
  --gb-panel: rgba(255, 246, 228, 0.08);
  --gb-panel-2: rgba(255, 246, 228, 0.14);
  --gb-line: rgba(255, 238, 205, 0.16);
  --gb-text: #fff6e4;
  --gb-dim: rgba(255, 246, 228, 0.68);
  --gb-accent: #f2c14e;
  --gb-accent-ink: #2b1d16;
  --gb-gold: #ffd166;
  --gb-danger: #ff6b5d;
  --red: #c8372d;
  --jade: #3f9a7a;
  --blue: #2f6fb5;
  --hanji: #f6ecd6;
  --ink: #2b1d16;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--gb-bg); color: var(--gb-text); font-family: var(--gb-font);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: var(--gb-font); }

/* 불러오기 */
.overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 35%, #4a2f22, #1a110c); z-index: 30; }
.overlay.on { display: flex; }
.load-box { width: min(86vw, 360px); text-align: center; display: flex; flex-direction: column; gap: 14px; }
.brand-big { font-size: 34px; font-weight: 900; letter-spacing: 2px; color: var(--hanji); text-shadow: 0 3px 0 var(--red); }
.bar { height: 10px; border-radius: 10px; background: rgba(255,255,255,0.12); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--red), var(--gb-accent)); transition: width .2s; }
#loadMsg { margin: 0; color: var(--gb-dim); font-size: 14px; }

/* 첫 화면 */
.screen { position: absolute; inset: 0; display: none; overflow-y: auto; padding: calc(12px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: linear-gradient(180deg, rgba(36,24,18,0.86), rgba(36,24,18,0.94)); z-index: 10; }
.screen.on { display: block; }
.gb-brand { font-size: 20px; font-weight: 900; display: flex; align-items: center; gap: 8px; color: var(--hanji); }
.brand-ic { width: 30px; height: 30px; }
.home-hint { margin: -4px 0 0; font-size: 13px; color: var(--gb-dim); text-align: center; min-height: 18px; }
.home-foot { text-align: center; margin: 4px 0 0; }
.link { background: none; border: 0; color: var(--gb-dim); text-decoration: underline; font-size: 13px; min-height: 44px; cursor: pointer; }
.gb-sub button { display: inline-flex; align-items: center; gap: 6px; }
.ic { width: 18px; height: 18px; flex: none; }

/* HUD — 글자·단추는 DOM, 월드만 캔버스 */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; font-weight: 800; }
.hud-top { position: absolute; left: 0; right: 0; top: calc(8px + var(--safe-t)); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 0 116px 0 12px; }
.hud-dist { font-size: 24px; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.55); white-space: nowrap; }
.hud-dist small { font-size: 13px; margin-left: 2px; opacity: 0.85; }
.hud-kk { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.kk-track { position: relative; width: min(220px, 100%); height: 12px; border-radius: 12px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.35); }
.kk-track span { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; border-radius: 12px; background: linear-gradient(90deg, var(--blue), #7fb8ff); transition: width .25s; }
.kk-face { position: absolute; top: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%); border-radius: 50%; background: #3651a8 url('../assets/img/dudu-face.svg') center/100% no-repeat; border: 2px solid #fff; left: 100%; transition: left .25s; }
.hud-kk small { font-size: 12px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.7); white-space: nowrap; }
.hud-coin { display: flex; align-items: center; gap: 6px; font-size: 20px; color: #ffe08a; text-shadow: 0 2px 4px rgba(0,0,0,0.6); }
.coin-ic { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, transparent 28%, #f2c14e 30%, #c9922a 100%); box-shadow: inset 0 0 0 2px #8a5e14; position: relative; }
.coin-ic::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; transform: translate(-50%,-50%); background: rgba(36,24,18,0.9); }
.hud-row2 { position: absolute; top: calc(52px + var(--safe-t)); left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; }
.mult { padding: 4px 10px; border-radius: 999px; background: rgba(43,29,22,0.72); border: 1px solid rgba(242,193,78,0.6); color: var(--gb-accent); font-size: 16px; }
.mode-bar { flex: 1; display: flex; justify-content: center; gap: 8px; font-size: 15px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.7); }
.powers { display: flex; gap: 6px; }
.pw { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #fff; background: conic-gradient(var(--gb-accent) var(--p, 100%), rgba(0,0,0,0.4) 0); border: 2px solid rgba(255,255,255,0.6); }
.pw img { width: 24px; height: 24px; }
.p0 { --p: 0%; } .p10 { --p: 10%; } .p20 { --p: 20%; } .p30 { --p: 30%; } .p40 { --p: 40%; } .p50 { --p: 50%; } .p60 { --p: 60%; } .p70 { --p: 70%; } .p80 { --p: 80%; } .p90 { --p: 90%; } .p100 { --p: 100%; }
.hud-pause, .hud-full { position: absolute; top: calc(8px + var(--safe-t)); z-index: 8; }
.hud-pause { right: 10px; } .hud-full { right: 60px; }

/* 문제 띠 — 화면 위 22 %, 보기 칩은 레인 자리(좌·중·우) */
.q-band { position: absolute; left: 50%; transform: translateX(-50%); top: calc(96px + var(--safe-t)); width: min(94vw, 620px); padding: 12px 16px 10px; border-radius: 16px;
  background: rgba(246, 236, 214, 0.95); color: var(--ink); box-shadow: 0 6px 22px rgba(0,0,0,0.35); border: 3px solid var(--red); text-align: center; animation: band-in .25s ease-out; }
.q-tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; margin-bottom: 4px; }
.q-text { font-size: clamp(20px, 5.6vw, 28px); line-height: 1.3; font-weight: 900; word-break: keep-all; }
.big-text .q-text { font-size: clamp(24px, 7vw, 34px); }
.q-hint { font-size: 12px; color: #6b5444; margin-top: 4px; font-weight: 700; }
@keyframes band-in { from { transform: translate(-50%, -14px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.q-chips { position: absolute; left: 0; right: 0; bottom: calc(22px + var(--safe-b)); display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 0 10px; pointer-events: none; }
.q-chips span { min-height: 52px; display: grid; place-items: center; border-radius: 14px; background: rgba(43,29,22,0.82); border: 2px solid rgba(242,193,78,0.7); color: #fff7e0; font-size: clamp(16px, 4.6vw, 22px); text-align: center; padding: 4px; word-break: keep-all; }
.q-chips span.me { background: rgba(200,55,45,0.92); border-color: #fff; }
.answer-card { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); padding: 12px 18px; border-radius: 16px; background: rgba(246,236,214,0.97); color: var(--ink); font-size: 20px; font-weight: 900; border: 3px solid var(--jade); box-shadow: 0 6px 20px rgba(0,0,0,0.35); text-align: center; max-width: 92vw; }
.answer-card small { display: block; font-size: 13px; font-weight: 700; color: #5d4a3c; margin-top: 4px; }
.status { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 var(--red), 0 0 16px rgba(0,0,0,0.6); white-space: nowrap; opacity: 0; transition: opacity .2s; }
.status.on { opacity: 1; }
.tutor { position: absolute; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); padding: 10px 16px; border-radius: 14px; background: rgba(0,0,0,0.6); color: #fff; font-size: 18px; text-align: center; white-space: nowrap; }
.pad { position: absolute; left: 0; right: 0; bottom: calc(86px + var(--safe-b)); display: flex; justify-content: center; gap: 10px; pointer-events: auto; }
.pad button { width: 64px; height: 64px; border-radius: 16px; border: 2px solid rgba(255,255,255,0.5); background: rgba(43,29,22,0.55); color: #fff; display: grid; place-items: center; }
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }

/* 창 */
.modal { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(20, 12, 8, 0.66); padding: 16px; }
.sheet { width: min(94vw, 460px); max-height: 88vh; overflow-y: auto; border-radius: 20px; background: #3a271d; border: 1px solid var(--gb-line); padding: 18px; box-shadow: 0 16px 40px rgba(0,0,0,0.5); }
.sheet h2 { margin: 0 0 10px; font-size: 22px; color: var(--hanji); }
.sheet p { margin: 6px 0; color: var(--gb-dim); line-height: 1.5; }
.sheet .row { display: flex; gap: 8px; margin-top: 12px; }
.sheet .row > * { flex: 1; }
.btn2 { min-height: 50px; border-radius: 14px; border: 1px solid var(--gb-line); background: var(--gb-panel-2); color: var(--gb-text); font-size: 16px; font-weight: 800; cursor: pointer; }
.btn2:active { transform: scale(0.97); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stat { padding: 10px; border-radius: 12px; background: var(--gb-panel); text-align: center; }
.stat b { display: block; font-size: 24px; color: #fff; }
.stat small { color: var(--gb-dim); font-size: 12px; }
.next-line { padding: 10px 12px; border-radius: 12px; background: rgba(47,111,181,0.25); border: 1px solid rgba(127,184,255,0.5); color: #e6f0ff; font-weight: 800; text-align: center; }
.choice-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.choice-list button { min-height: 56px; border-radius: 14px; border: 2px solid var(--gb-line); background: var(--gb-panel-2); color: #fff; font-size: 18px; font-weight: 800; padding: 6px; word-break: keep-all; }
.choice-list button.ok { background: var(--jade); border-color: #fff; }
.choice-list button.no { background: #7a2b25; }
.revive-q { font-size: 22px; font-weight: 900; color: #fff; margin: 8px 0; line-height: 1.35; word-break: keep-all; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1 1 auto; min-height: 44px; min-width: 64px; border-radius: 12px; border: 1px solid var(--gb-line); background: var(--gb-panel); color: var(--gb-text); font-weight: 800; font-size: 15px; }
.seg button.on { background: var(--gb-accent); color: var(--gb-accent-ink); }
.set-row { margin: 12px 0; }
.set-row > label { display: block; font-size: 13px; color: var(--gb-dim); margin-bottom: 6px; }
.dex { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dex .card { aspect-ratio: 3/4; border-radius: 10px; background: var(--gb-panel); border: 1px solid var(--gb-line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; text-align: center; padding: 4px; color: var(--gb-dim); }
.dex .card.got { background: linear-gradient(160deg, #6b4a2b, #3a271d); color: #fff; border-color: rgba(242,193,78,0.6); }
.dex .card.gold { background: linear-gradient(160deg, #c9922a, #6b4a2b); color: #fff; border-color: #ffe08a; }
.dex .card b { font-size: 14px; }
.dots { letter-spacing: 1px; color: var(--gb-accent); font-size: 11px; }
.wardrobe { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.wardrobe button { min-height: 120px; border-radius: 14px; border: 2px solid var(--gb-line); background: var(--gb-panel); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 800; padding: 8px; }
.wardrobe button.on { border-color: var(--gb-accent); }
.wardrobe button img { width: 64px; height: 64px; object-fit: contain; }
.wardrobe small { color: var(--gb-dim); font-weight: 700; }
.task { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--gb-panel); margin: 6px 0; }
.task .tbar { flex: 1; height: 8px; border-radius: 8px; background: rgba(255,255,255,0.12); overflow: hidden; }
.task .tbar span { display: block; height: 100%; background: var(--gb-accent); }
.task.done { outline: 2px solid var(--jade); }
.credits { font-size: 12px; color: var(--gb-dim); line-height: 1.6; white-space: pre-wrap; }
.toast { position: absolute; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; background: rgba(0,0,0,0.78); color: #fff; font-size: 15px; z-index: 40; max-width: 90vw; text-align: center; }
.cause { font-size: 18px; color: #ffd7cf; text-align: center; font-weight: 900; }
.w-0 { width: 0%; } .w-10 { width: 10%; } .w-20 { width: 20%; } .w-30 { width: 30%; } .w-40 { width: 40%; } .w-50 { width: 50%; } .w-60 { width: 60%; } .w-70 { width: 70%; } .w-80 { width: 80%; } .w-90 { width: 90%; } .w-100 { width: 100%; }
@media (orientation: landscape) and (max-height: 520px) {
  .q-band { top: calc(70px + var(--safe-t)); padding: 8px 14px; }
  .q-text { font-size: 22px; }
  .q-chips { bottom: 12px; padding: 0 18vw; }
}
@media (prefers-reduced-motion: reduce) { .q-band { animation: none; } }
.reduce-motion .q-band { animation: none; }
/* 판 중 단추는 하늘 위에 뜬다 — 밝은 배경에서도 보이게 어두운 반투명 바탕 */
.hud-pause, .hud-full { background: rgba(28, 22, 18, 0.55); border-color: rgba(255, 255, 255, 0.25); color: #fff; }

.tutor.under-q { visibility: hidden; }
