/* 한양분식 3D 둘러보기 — 차콜 + 금
   다국어: <html lang dir> 는 i18n.js 가 바꾼다. 좌우는 논리 속성(inline-start/end)으로 → RTL 이면 자동으로 뒤집힘.
   한국어만 낱말 단위 줄바꿈(keep-all) · 문자권별 글꼴은 아래 :lang() */
:root {
  --ink: #f3ede1;
  --dim: rgba(243, 237, 225, .68);
  --line: rgba(243, 237, 225, .16);
  --char: #15120f;
  --panel: rgba(21, 18, 15, .74);
  --gold: #c9a45c;
  --gold-hi: #e2c584;
  --red: #a8432f;
  --r: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --sans: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--char); color: var(--ink); font-family: var(--sans);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}
html:lang(ko) body { word-break: keep-all; }
html:lang(ja) { --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif; --serif: "Hiragino Mincho ProN", "Noto Serif JP", "Yu Mincho", serif; }
html:lang(zh-TW) { --sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif; --serif: "Noto Serif TC", "Songti TC", serif; }
html:lang(zh-CN) { --sans: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; --serif: "Noto Serif SC", "Songti SC", serif; }
html:lang(th) { --sans: "Noto Sans Thai", "Leelawadee UI", Thonburi, Tahoma, system-ui, sans-serif; --serif: var(--sans); }
html:lang(hi) { --sans: "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", Mangal, system-ui, sans-serif; --serif: var(--sans); }
html:lang(ar) { --sans: "Noto Sans Arabic", "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", Tahoma, system-ui, sans-serif; --serif: var(--sans); }
html:not(:lang(ko)):not(:lang(ja)):not(:lang(zh)):not(:lang(th)):not(:lang(hi)):not(:lang(ar)) { --serif: Georgia, "Noto Serif", "Times New Roman", serif; }
html:lang(ar) .eyebrow, html:lang(ar) .brand b, html:lang(hi) .eyebrow, html:lang(th) .eyebrow { letter-spacing: 0; }
[dir="rtl"] .home .arr { display: inline-block; transform: scaleX(-1); }
canvas#c { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; height: 100dvh; touch-action: none; outline: none; }
a { color: var(--gold-hi); }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* 기기별 안내 */
.only-touch { display: none; }
body.touch .only-touch { display: revert; }
body.touch .only-desk { display: none; }

/* ── 윗줄 ─────────────────────────────────────── */
#top {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) 22px calc(16px + var(--safe-l));   /* 기기 안전 여백 = 물리 좌우 */
  background: linear-gradient(rgba(12, 10, 8, .72), rgba(12, 10, 8, 0));
  pointer-events: none;
}
#top > * { pointer-events: auto; }
.home {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); text-decoration: none; font-size: 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color .2s, color .2s;
}
.home:hover { border-color: var(--gold); color: var(--gold-hi); }
.brand { flex: 1; min-width: 0; font-size: 14px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.brand b { font-family: var(--serif); font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: .04em; }
.brand .sep { display: inline-block; width: 1px; height: 12px; margin: 0 10px; background: var(--gold); opacity: .7; vertical-align: -1px; }
.ghost {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  font-size: 13px; cursor: pointer; white-space: nowrap;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color .2s, color .2s;
}
.ghost:hover { border-color: var(--gold); color: var(--gold-hi); }

/* ── 장소 단추 ─────────────────────────────────── */
#spots {
  position: fixed; z-index: 15; inset-inline-end: calc(16px + var(--safe-r)); top: calc(64px + var(--safe-t));
  display: flex; flex-direction: column; gap: 6px; max-height: calc(100% - 160px); overflow-y: auto;
  scrollbar-width: none;
}
#spots::-webkit-scrollbar { display: none; }
#spots button {
  display: flex; align-items: center; gap: 9px; text-align: start; cursor: pointer;
  padding-block: 8px; padding-inline: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); font-size: 13.5px; white-space: nowrap;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color .2s, background-color .2s, transform .2s;
}
#spots button .n {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid rgba(201, 164, 92, .55); color: var(--gold-hi); font-size: 11px; font-variant-numeric: tabular-nums;
}
#spots button:hover { border-color: var(--gold); transform: translateX(-2px); }
[dir="rtl"] #spots button:hover { transform: translateX(2px); }
#spots button.on { border-color: var(--gold); background: rgba(201, 164, 92, .28); }
#spots button.on .n { background: var(--gold); color: var(--char); border-color: var(--gold); }

/* 시작 전에는 조작 단추를 숨김 */
body:not(.started) #spots, body:not(.started) #ctrl, body:not(.started) #joy { display: none; }

/* ── 아래 조작 ─────────────────────────────────── */
#ctrl {
  position: fixed; z-index: 15; inset-inline-end: calc(16px + var(--safe-r)); bottom: calc(18px + var(--safe-b));
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
#modeBtn {
  padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(201, 164, 92, .6);
  background: var(--panel); color: var(--gold-hi); font-size: 14px; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#modeBtn[aria-pressed="true"] { background: rgba(201, 164, 92, .3); color: var(--ink); }
#flyPad { display: flex; flex-direction: column; gap: 8px; }
#flyPad button {
  width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); font-size: 18px; touch-action: none; user-select: none; -webkit-user-select: none;
}
#joy {
  position: fixed; z-index: 15; inset-inline-start: calc(22px + var(--safe-l)); bottom: calc(28px + var(--safe-b));
  width: 128px; height: 128px; border-radius: 50%; touch-action: none;
  background: radial-gradient(circle, rgba(21, 18, 15, .25), rgba(21, 18, 15, .55));
  border: 1px solid rgba(201, 164, 92, .45); display: none;
}
body.touch.started #joy { display: block; }
#joy i {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: rgba(226, 197, 132, .55); border: 1px solid rgba(255, 255, 255, .35); pointer-events: none;
}

#cross { position: fixed; z-index: 14; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255, 255, 255, .6); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); pointer-events: none; }
#hint {
  position: fixed; z-index: 16; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  padding: 9px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; color: var(--dim); white-space: nowrap; pointer-events: none;
}

/* ── 도움말 ───────────────────────────────────── */
#help {
  position: fixed; z-index: 25; inset-inline-start: calc(16px + var(--safe-l)); bottom: calc(18px + var(--safe-b));
  width: min(360px, calc(100% - 32px)); padding: 18px 20px 16px; border-radius: var(--r);
  background: rgba(21, 18, 15, .92); border: 1px solid rgba(201, 164, 92, .35);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
#help h2 { margin: 0 0 10px; font-family: var(--serif); font-size: 17px; color: var(--gold-hi); }
#help ul { margin: 0 0 14px; padding: 0; list-style: none; font-size: 14px; line-height: 1.9; color: var(--ink); }
kbd {
  display: inline-block; min-width: 22px; padding: 0 5px; margin-inline-end: 3px; border-radius: 5px; text-align: center; direction: ltr;
  border: 1px solid var(--line); border-bottom-width: 2px; font: 12px/20px var(--sans); color: var(--gold-hi);
}

/* ── 시작 화면 ─────────────────────────────────── */
#start {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background:
    radial-gradient(ellipse 60% 45% at 50% 40%, rgba(201, 164, 92, .16), transparent 70%),
    radial-gradient(ellipse at 50% 120%, rgba(168, 67, 47, .18), transparent 60%),
    rgba(15, 12, 9, .9);
  overflow-y: auto;
}
.card {
  width: 100%; max-width: 440px; padding: 34px 28px 24px; text-align: center;
  border-radius: 18px; background: rgba(24, 20, 16, .88);
  border: 1px solid rgba(201, 164, 92, .32); box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  animation: rise .7s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: .32em; color: var(--gold); }
.card h1 { margin: 0 0 12px; font-family: var(--serif); font-size: clamp(25px, 7vw, 31px); font-weight: 700; letter-spacing: .03em; }
.lead { margin: 0 0 22px; color: var(--dim); font-size: 15px; line-height: 1.75; }
.progress { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; }
.track { flex: 1; height: 4px; border-radius: 2px; background: rgba(243, 237, 225, .12); overflow: hidden; }
.track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-hi)); transition: width .25s ease-out; }
#pct { min-width: 3.2em; text-align: end; font-size: 13px; color: var(--gold-hi); font-variant-numeric: tabular-nums; direction: ltr; }
#msg { margin: 0 0 18px; min-height: 1.5em; font-size: 13.5px; color: var(--dim); }
#go {
  min-width: 180px; padding: 13px 30px; border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #1c150b; font-size: 16px; font-weight: 700; letter-spacing: .04em;
  box-shadow: 0 8px 24px rgba(201, 164, 92, .25); transition: transform .2s, box-shadow .2s, opacity .2s;
}
#go:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(201, 164, 92, .35); }
#go:disabled { opacity: .45; cursor: progress; box-shadow: none; }
.keys { margin: 18px 0 0; font-size: 13px; color: var(--ink); opacity: .85; }
.small { margin: 8px 0 0; font-size: 12px; color: var(--dim); line-height: 1.6; }
.foot { margin: 18px 0 0; font-size: 13px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; color: var(--dim); }
#go { max-width: 100%; }
.home, .ghost, #modeBtn { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.foot a { color: var(--dim); text-decoration: none; border-bottom: 1px solid var(--line); }
.foot a:hover { color: var(--gold-hi); border-color: var(--gold); }
#start.failed #msg { color: #f0b7a8; }
#start.failed .track i { background: var(--red); }

.noscript {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 24px; text-align: center; background: var(--char); font-size: 15px; line-height: 1.7;
}

/* ── 좁은 화면(휴대폰) ─────────────────────────── */
@media (max-width: 720px), (pointer: coarse) {
  #top { gap: 10px; padding-bottom: 14px; }
  .brand { font-size: 13px; }
  .brand b { font-size: 15px; }
  #spots {
    left: 0; right: 0; top: calc(52px + var(--safe-t)); max-height: none;
    flex-direction: row; gap: 6px; overflow-x: auto; overflow-y: hidden;
    padding: 2px calc(12px + var(--safe-r)) 6px calc(12px + var(--safe-l));
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  }
  #spots button { flex: none; padding: 7px 12px 7px 8px; font-size: 13px; }
  #spots button:hover { transform: none; }
  #help { inset-inline: 0; margin-inline: auto; bottom: auto; top: calc(100px + var(--safe-t)); }
  .card { padding: 28px 20px 20px; }
}
@media (max-width: 360px) {
  .brand .sep, .brand b + .sep { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 우측 아래 둘러보기 안내 — 날기(F) 단추 위 (사용자 12-05) */
#dragTip { margin: 0; max-width: min(78vw, 420px); padding: 10px 18px; border-radius: 999px; border: 1px solid #f4cd82; background: #f4cd82; color: #1e1a17; font-size: 14px; font-weight: 700; text-align: center; pointer-events: none; }
@media (pointer: coarse) { #dragTip { display: none; } }

/* 선택된 단추는 밝은 하늘 위에서도 읽히게 불투명 금색 */
#spots button.on, #modeBtn[aria-pressed="true"] { background: #f4cd82; border-color: #f4cd82; color: #1e1a17; }
#spots button.on .n { background: #1e1a17; border-color: #1e1a17; color: #f4cd82; }
/* 휴대폰 조작 안내 — 장소 단추 아래에 계속 표시 (사용자 12-05) */
#touchTip { display: none; }
@media (pointer: coarse) {
  body.started #touchTip { display: block; position: fixed; z-index: 14; top: calc(104px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); box-sizing: border-box; margin: 0; padding: 8px 16px; border-radius: 999px; background: rgba(16, 13, 11, .82); color: #fff4dc; font-size: 13px; font-weight: 600; text-align: center; pointer-events: none; }
}

/* PC 방향키 안내 — 도움말을 열지 않아도 보인다 (사용자 12-05) */
#keyPad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-areas: ". w ." "a s d"; gap: 6px; pointer-events: none; }
#keyPad .kc { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; background: rgba(16, 13, 11, .82); border: 1px solid rgba(201, 164, 92, .6); color: #fff4dc; }
#keyPad .w { grid-area: w; } #keyPad .a { grid-area: a; } #keyPad .s { grid-area: s; } #keyPad .d { grid-area: d; }
#keyPad kbd { font: 800 16px/1.2 inherit; font-family: inherit; color: #f4cd82; }
#keyPad small { font-size: 11px; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
#keyPad .down { background: #f4cd82; border-color: #f4cd82; color: #1e1a17; }
#keyPad .down kbd { color: #1e1a17; }
@media (max-height: 700px) { #keyPad { position: fixed; inset-inline-start: 16px; bottom: 18px; } }
@media (pointer: coarse) { #keyPad { display: none; } }

#keyPad { grid-template-areas: ". w ." "a s d" "sp sp sp"; }
#keyPad .sp { grid-area: sp; }
body.flying #keyPad .sp { visibility: hidden; }

/* 달리기 단추 = 날기 단추와 같은 모양 (사용자 12-05) */
#runBtn { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(201, 164, 92, .6); background: var(--panel); color: var(--gold-hi); font-size: 14px; font-weight: 600; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#runBtn[aria-pressed="true"] { background: #f4cd82; border-color: #f4cd82; color: #1e1a17; }
