/* 삼천리 배관 대모험 — 07 QUEST 팔레트 */
:root {
  --ink: #16133d;
  --sky: #3bb4ff;
  --sky2: #a9e8ff;
  --sun: #ffd21f;
  --sun2: #fff3a6;
  --hot: #ff3d6a;
  --leaf: #22c96b;
  --aqua: #19dcf0;
  --grape: #5b3cf0;
  --navy: #2c55c9;
  --px: 'Galmuri11', 'Galmuri14', 'Pretendard Variable', sans-serif;
  --body: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --barh: 52px;
  --u: 2px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sky); color: var(--ink); font-family: var(--body);
  overflow: hidden; overscroll-behavior: none; word-break: keep-all;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  background-image:
    linear-gradient(180deg, rgba(255,255,255,.0) 0 60%, rgba(22,19,61,.18) 100%),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(255,255,255,.08) 46px 48px);
}
button, a { font: inherit; color: inherit; }
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
:focus-visible { outline: 3px solid var(--hot); outline-offset: 3px; }
[hidden] { display: none !important; }

.ico-phone { width: 1em; height: 1em; display: inline-block; flex: none; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M1 0h2v1h1v2H3v1h1v1h1V4h2v1h1v2H7v1H5V7H4V6H3V5H2V4H1V3H0V1h1z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M1 0h2v1h1v2H3v1h1v1h1V4h2v1h1v2H7v1H5V7H4V6H3V5H2V4H1V3H0V1h1z'/%3E%3C/svg%3E") center/contain no-repeat; }

/* ---------- 상단 바 ---------- */
.bar { height: var(--barh); background: var(--ink); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 12px 0 16px; font-family: var(--px); position: relative; z-index: 30; border-bottom: 4px solid #2a2570; }
.bar__brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 17px; white-space: nowrap; }
.bar__brand img { width: 30px; height: auto; }
.bar__game { color: var(--sun); font-size: 14px; white-space: nowrap; padding-left: 14px; border-left: 2px solid #3d3a7a; }
.bar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bar__back { color: #cfd6ff; text-decoration: none; font-size: 14px; padding: 6px 8px; white-space: nowrap; }
.bar__back:hover { color: var(--ink); background: var(--sun); }
.bar__mute { background: none; border: 2px solid #5d5a99; color: #cfd6ff; font-family: var(--px); font-size: 13px; padding: 4px 8px; cursor: pointer; white-space: nowrap; }
.bar__mute[aria-pressed="true"] { color: #8f8cc4; text-decoration: line-through; }
.bar__call { display: flex; align-items: center; gap: 8px; background: var(--sun); color: var(--ink); text-decoration: none; font-weight: 700; padding: 8px 14px; font-size: 16px; box-shadow: inset 0 -4px 0 #c79a00; white-space: nowrap; }
.bar__call:hover { background: #fff; }
.bar__short { display: none; }

/* ---------- 플레이 영역 ---------- */
.play { height: calc(100% - var(--barh)); height: calc(100dvh - var(--barh)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px 24px; position: relative; }
.frame { position: relative; background: var(--ink); box-shadow: 0 0 0 4px var(--ink), 8px 8px 0 4px rgba(22,19,61,.45); flex: none; touch-action: none; }
.frame canvas { display: block; width: 100%; height: 100%; }
.ui { position: absolute; inset: 0; pointer-events: none; font-family: var(--px); color: #fff; overflow: hidden; }
.ui > * { pointer-events: auto; }
.keys { margin: 0; font-family: var(--px); font-size: 13px; color: var(--ink); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; text-align: center; }
.keys kbd { font-family: var(--px); background: #fff; border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 #c3cedc; padding: 1px 7px; font-size: 12px; }
.keys span { color: #1b3384; margin-right: 6px; }

/* ---------- HUD ---------- */
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: calc(var(--u) * 7); padding: calc(var(--u) * 3) calc(var(--u) * 5);
  background: linear-gradient(180deg, rgba(22,19,61,.88), rgba(22,19,61,.55) 80%, transparent); font-size: clamp(11px, calc(var(--u) * 7), 19px); pointer-events: none; text-shadow: 2px 2px 0 var(--ink); }
.hud__hp { display: flex; gap: max(1px, calc(var(--u) * 0.6)); }
.hud__hp img { height: max(11px, calc(var(--u) * 7)); width: auto; }
.hud__coin { display: flex; align-items: center; gap: 4px; color: var(--sun); }
.hud__coin img { height: max(11px, calc(var(--u) * 8)); width: auto; }
.hud__area { margin-left: auto; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud__stars { color: var(--sun2); white-space: nowrap; }
.hud__stars span { color: var(--sun); letter-spacing: 1px; }

.bossbar { position: absolute; left: 50%; bottom: calc(var(--u) * 5); transform: translateX(-50%); width: min(72%, 560px); display: flex; align-items: center; gap: 10px; font-size: clamp(11px, calc(var(--u) * 6.5), 18px); pointer-events: none; text-shadow: 2px 2px 0 var(--ink); }
.bossbar b { white-space: nowrap; color: #fff; }
.bossbar i { flex: 1; height: max(8px, calc(var(--u) * 5)); background: #2a2570; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--ink); position: relative; }
.bossbar span { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--hot) 0 8px, #ff6b8c 8px 10px); transition: width .15s steps(3); }

.toast { position: absolute; left: 50%; top: calc(var(--u) * 20); transform: translate(-50%, -12px); opacity: 0; text-align: center; pointer-events: none; transition: opacity .2s, transform .2s steps(3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { display: inline-block; background: var(--sun); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 4px 14px; font-size: clamp(14px, calc(var(--u) * 9), 30px); white-space: nowrap; }
.toast span { display: table; margin: 6px auto 0; padding: 2px 10px; background: var(--ink); color: #fff; font-size: clamp(11px, calc(var(--u) * 6), 17px); white-space: nowrap; }

.prompt { position: absolute; left: 50%; bottom: calc(var(--u) * 8); transform: translateX(-50%); background: #fff; color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 3px 10px 3px 4px; font-size: clamp(12px, calc(var(--u) * 6.5), 18px); display: flex; align-items: center; gap: 8px; white-space: nowrap; pointer-events: none; animation: pbob .8s steps(2) infinite; }
.prompt kbd { font-family: var(--px); background: var(--hot); color: #fff; padding: 1px 6px; font-size: .85em; }
@keyframes pbob { 50% { transform: translate(-50%, -3px); } }

/* ---------- 대화창 ---------- */
.dlg { position: absolute; left: calc(var(--u) * 6); right: calc(var(--u) * 6); bottom: calc(var(--u) * 5); display: flex; gap: calc(var(--u) * 5); align-items: flex-start;
  background: #fff; color: var(--ink); border: 4px solid var(--ink); box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px var(--ink), 5px 5px 0 rgba(22,19,61,.6); padding: calc(var(--u) * 5) calc(var(--u) * 6); cursor: pointer; }
.dlg__face { width: clamp(44px, calc(var(--u) * 30), 120px); height: auto; flex: none; background: var(--sky2); border: 3px solid var(--ink); padding: 4px; }
.dlg__body { flex: 1; min-width: 0; }
.dlg__body b { display: inline-block; background: var(--ink); color: var(--sun); font-size: clamp(11px, calc(var(--u) * 6), 17px); padding: 1px 8px; margin-bottom: 6px; }
.dlg p { margin: 0; font-family: var(--px); font-size: clamp(13px, calc(var(--u) * 7.4), 23px); line-height: 1.55; min-height: 3.1em; }
.dlg--sys { background: var(--sun2); }
.dlg__next { position: absolute; right: 12px; bottom: 6px; color: var(--hot); font-size: clamp(11px, calc(var(--u) * 6), 16px); opacity: 0; }
.dlg--done .dlg__next { opacity: 1; animation: pbob2 .6s steps(2) infinite; }
@keyframes pbob2 { 50% { transform: translateY(3px); } }

/* ---------- 오버레이 화면 ---------- */
.screen { position: absolute; inset: 0; z-index: 5; color: #fff; text-align: center; display: flex; }
.screen__scroll { margin: auto; width: 100%; max-height: 100%; overflow-y: auto; padding: calc(var(--u) * 8) calc(var(--u) * 10); display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 5); -webkit-overflow-scrolling: touch; }
.screen--title { background: linear-gradient(180deg, rgba(22,19,61,.15), rgba(22,19,61,.0) 30%, rgba(22,19,61,.55) 100%); }
.screen--clear, .screen--over { background: rgba(22,19,61,.86); }
.screen--ending { background: linear-gradient(180deg, rgba(22,19,61,.35), rgba(22,19,61,.82) 45%); }

.logo { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.logo__sup { background: var(--hot); color: #fff; border: 3px solid var(--ink); padding: 2px 12px; font-size: clamp(12px, calc(var(--u) * 7), 20px); box-shadow: 3px 3px 0 var(--ink); transform: rotate(-2deg); }
.logo__main { margin: 0; font-family: var(--px); font-weight: 700; line-height: 1.02; font-size: clamp(34px, calc(var(--u) * 30), 104px); color: var(--sun);
  text-shadow: 0 4px 0 #e3a800, 4px 4px 0 var(--ink), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 0 9px 0 var(--ink); letter-spacing: 1px; }
.title__party { display: flex; align-items: flex-end; gap: calc(var(--u) * 4); filter: drop-shadow(3px 3px 0 rgba(22,19,61,.5)); }
.title__party img { height: clamp(40px, calc(var(--u) * 26), 108px); width: auto; }
.title__party .bob { height: clamp(24px, calc(var(--u) * 15), 64px); animation: bob 1s steps(2) infinite; }
.title__vs { font-size: clamp(14px, calc(var(--u) * 9), 28px); color: var(--hot); text-shadow: 2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink); margin: 0 6px 8px; }
.title__bosses { display: flex; align-items: flex-end; gap: calc(var(--u) * 2); }
.title__bosses img { height: clamp(26px, calc(var(--u) * 17), 72px); animation: bob 1.2s steps(2) infinite; }
.title__bosses img:nth-child(2n) { animation-delay: -.6s; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.title__btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.title__hint { margin: 0; font-size: clamp(11px, calc(var(--u) * 6), 16px); text-shadow: 2px 2px 0 var(--ink); }
.only-touch { display: none; }
body.touch .only-touch { display: block; }
body.touch .only-key { display: none; }

.pbtn { font-family: var(--px); font-weight: 700; font-size: clamp(15px, calc(var(--u) * 9), 26px); background: var(--sun); color: var(--ink); border: 4px solid var(--ink); padding: 6px 22px 10px; cursor: pointer; text-decoration: none;
  box-shadow: 5px 5px 0 var(--ink), inset 0 -5px 0 #e3a800, inset 0 3px 0 var(--sun2); display: inline-flex; flex-direction: column; align-items: center; gap: 0; transition: transform .08s steps(2); }
.pbtn small { font-size: .55em; font-weight: 400; }
.pbtn:hover, .pbtn:focus-visible { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink), inset 0 -5px 0 #e3a800, inset 0 3px 0 var(--sun2); outline: none; background: #fff36b; }
.pbtn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink), inset 0 -2px 0 #e3a800; }
.pbtn--alt { background: #fff; box-shadow: 5px 5px 0 var(--ink), inset 0 -5px 0 #c3cedc; font-size: clamp(13px, calc(var(--u) * 7), 20px); }
.pbtn--alt:hover, .pbtn--alt:focus-visible { background: var(--sky2); box-shadow: 7px 7px 0 var(--ink), inset 0 -5px 0 #7ad3ff; }

.clear__big { margin: 0; font-family: var(--px); font-weight: 700; font-size: clamp(30px, calc(var(--u) * 24), 84px); color: var(--sun); line-height: 1;
  text-shadow: 4px 4px 0 var(--hot), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 7px 7px 0 var(--ink); animation: pop .5s steps(4); }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } }
.clear__ko { margin: -4px 0 0; font-size: clamp(14px, calc(var(--u) * 9), 28px); }
.clear__row { display: flex; align-items: center; gap: calc(var(--u) * 6); text-align: left; }
.clear__row img { height: clamp(48px, calc(var(--u) * 28), 110px); width: auto; transform: rotate(180deg) scaleX(-1); opacity: .9; }
.clear__row h2 { margin: 0; font-size: clamp(17px, calc(var(--u) * 11), 34px); color: #fff; text-shadow: 3px 3px 0 var(--hot); }
.clear__stars { margin: 4px 0 0; color: var(--sun); font-size: clamp(16px, calc(var(--u) * 10), 30px); letter-spacing: 3px; }
.clear__real { background: #fff; color: var(--ink); border: 4px solid var(--ink); box-shadow: 5px 5px 0 var(--hot); padding: calc(var(--u) * 4) calc(var(--u) * 6); text-align: left; max-width: 640px; font-family: var(--body); font-size: clamp(12px, calc(var(--u) * 6.2), 17px); line-height: 1.55; }
.clear__real b { font-family: var(--px); display: block; margin-bottom: 4px; color: var(--navy); }
.clear__real p { margin: 2px 0; }
.clear__real em { font-style: normal; font-family: var(--px); background: var(--sun); padding: 0 6px; margin-right: 4px; }

.over__hero { height: clamp(40px, calc(var(--u) * 24), 100px); width: auto; transform: rotate(90deg); filter: grayscale(.5); margin: 10px 0; }
.over__big { margin: 0; font-size: clamp(20px, calc(var(--u) * 14), 44px); color: var(--hot); text-shadow: 3px 3px 0 var(--ink); }
.over__sub { margin: 0; font-size: clamp(12px, calc(var(--u) * 6.5), 18px); }

.end__title { margin: 0; font-size: clamp(17px, calc(var(--u) * 11), 36px); text-shadow: 3px 3px 0 var(--ink); }
.end__bosses { list-style: none; margin: 0; padding: 0; display: flex; gap: calc(var(--u) * 4); flex-wrap: wrap; justify-content: center; }
.end__bosses li { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: clamp(10px, calc(var(--u) * 5), 14px); }
.end__bosses img { height: clamp(28px, calc(var(--u) * 16), 64px); width: auto; }
.end__bosses li::after { content: '★ 처치'; color: var(--sun); }
.end__stat { margin: 0; font-size: clamp(12px, calc(var(--u) * 6.5), 18px); }
.end__stat b { color: var(--sun); }
.end__msg { margin: 0; max-width: 620px; font-family: var(--body); font-size: clamp(12px, calc(var(--u) * 6.4), 18px); line-height: 1.6; }
.callbtn { display: inline-flex; flex-direction: column; align-items: center; text-decoration: none; background: var(--sun); color: var(--ink); border: 4px solid var(--ink);
  box-shadow: 6px 6px 0 var(--hot), 6px 6px 0 4px var(--ink), inset 0 -6px 0 #e3a800, inset 0 4px 0 var(--sun2); padding: 8px 26px 12px; font-family: var(--px); }
.callbtn__top { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: clamp(22px, calc(var(--u) * 15), 48px); line-height: 1.1; }
.callbtn__sub { font-size: clamp(12px, calc(var(--u) * 6.5), 18px); }
.callbtn:hover { background: #fff; }

/* ---------- 가상 패드 ---------- */
.pad { display: none; }
body.touch .pad { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 0 18px; touch-action: none; }
body.touch .keys { display: none; }
.dpad { position: relative; width: 150px; height: 150px; border-radius: 50%; background: rgba(22,19,61,.18); border: 4px solid var(--ink); touch-action: none; flex: none; box-shadow: inset 0 -6px 0 rgba(22,19,61,.15); }
.dpad__cross { position: absolute; inset: 0; margin: auto; width: 62%; height: 62%;
  background: linear-gradient(var(--ink), var(--ink)) center/34% 100% no-repeat, linear-gradient(var(--ink), var(--ink)) center/100% 34% no-repeat; opacity: .9;
  clip-path: polygon(33% 0, 67% 0, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 100%, 33% 100%, 33% 67%, 0 67%, 0 33%, 33% 33%); }
.dpad__knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: var(--sun); border: 4px solid var(--ink); box-shadow: inset 0 -5px 0 #e3a800; pointer-events: none; }
.abtn { width: 104px; height: 104px; border-radius: 50%; border: 5px solid var(--ink); background: var(--hot); color: #fff; font-family: var(--px); font-weight: 700; font-size: 40px; box-shadow: inset 0 -8px 0 #c41f4a, 0 6px 0 var(--ink); touch-action: none; flex: none; text-shadow: 2px 2px 0 var(--ink); cursor: pointer; }
.abtn.on { transform: translateY(4px); box-shadow: inset 0 -3px 0 #c41f4a, 0 2px 0 var(--ink); background: #ff6b8c; }

/* 세로 모바일: 화면 위, 컨트롤 아래 */
body.portrait .play { justify-content: flex-start; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 0; }
body.portrait { background: #1d1850; }
body.portrait .pad { flex: 1; flex-wrap: wrap; align-content: center; gap: 18px 0; background: linear-gradient(180deg, #1d1850, #2a2570); margin: 10px -8px 0; padding: 12px 22px calc(18px + env(safe-area-inset-bottom)); border-top: 4px solid var(--ink); }
.pad__tip { display: none; }
body.portrait .pad__tip { display: block; width: 100%; margin: 0; text-align: center; font-family: var(--px); font-size: 12px; color: #cfd6ff; }
body.portrait .dpad { background: rgba(255,255,255,.08); border-color: #0d0b26; }
body.portrait .dpad__cross { background: linear-gradient(#5d5a99, #5d5a99) center/34% 100% no-repeat, linear-gradient(#5d5a99, #5d5a99) center/100% 34% no-repeat; }
body.portrait .ui.compact .screen--title { top: var(--fb); background: #1d1850; }
/* 가로 모바일: 컨트롤을 화면 양옆에 겹치기 */
body.landscape .play { padding: 6px; }
body.landscape .pad { position: absolute; left: 0; right: 0; bottom: 10px; padding: 0 calc(14px + env(safe-area-inset-left)); pointer-events: none; z-index: 20; }
body.landscape .pad > * { pointer-events: auto; opacity: .82; }
body.landscape .dpad { width: 128px; height: 128px; }
body.landscape .abtn { width: 88px; height: 88px; font-size: 32px; }

/* 작은 화면: 오버레이 화면은 플레이 영역 전체로 */
.ui.compact .screen { position: fixed; top: var(--barh); left: 0; right: 0; bottom: 0; background-color: rgba(22,19,61,.95); --u: 1.8px; }
.ui.compact .screen--title { background: rgba(22,19,61,.72); }

@media (max-width: 760px) {
  .bar { gap: 8px; padding: 0 8px 0 10px; }
  .bar__game, .bar__back { display: none; }
  .bar__brand { font-size: 15px; }
  .bar__num { display: none; }
  .bar__short { display: inline; }
  .bar__call { padding: 8px 12px; }
}
@media (max-width: 380px) { .bar__brand span { font-size: 14px; } .bar__mute { padding: 3px 5px; font-size: 12px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
