@font-face {
  font-family: "NotoThai";
  src: url("assets/fonts/NotoSansThai.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "NotoThai", Tahoma, sans-serif;
  --paper: #f0e5cd;
  --ink: #17120e;
  --gold: #d2a55f;
  --glass: rgba(17, 13, 10, .78);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #0c0907; }
button { font: inherit; }
#gallery { width: 100%; height: 100%; display: block; outline: 0; touch-action: none; }

.hud { position: fixed; z-index: 8; pointer-events: none; }
.top-hud { top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 26px; background: linear-gradient(rgba(7,5,4,.82), transparent); }
.eyebrow { color: var(--gold); font-size: 11px; letter-spacing: .18em; font-weight: 700; }
.top-hud h2 { margin: 3px 0 0; color: #fff7e8; font-size: clamp(18px, 2.2vw, 28px); font-weight: 500; text-shadow: 0 2px 10px #000; }
.icon-button { pointer-events: auto; width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(240,229,205,.5); color: var(--paper); background: rgba(19,14,10,.72); cursor: pointer; font-size: 22px; }

.crosshair { position: fixed; z-index: 7; inset: 50% auto auto 50%; transform: translate(-50%,-50%); width: 20px; height: 20px; pointer-events: none; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: rgba(255,235,192,.86); box-shadow: 0 0 5px #000; }
.crosshair::before { width: 14px; height: 1px; left: 3px; top: 9px; }
.crosshair::after { width: 1px; height: 14px; left: 9px; top: 3px; }
.crosshair span { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #e3b76b; left: 8px; top: 8px; }

.prompt { position: fixed; z-index: 8; bottom: 24px; left: 50%; transform: translateX(-50%); min-width: min(680px, calc(100vw - 36px)); padding: 12px 20px; text-align: center; border: 1px solid rgba(226,185,112,.38); border-radius: 8px; color: #fff7e8; background: var(--glass); backdrop-filter: blur(12px); pointer-events: none; }
.room-index { position: fixed; z-index: 6; top: 95px; right: 22px; width: min(270px, 28vw); padding: 14px 16px; border-left: 2px solid var(--gold); color: rgba(255,247,232,.82); background: linear-gradient(90deg, rgba(15,10,7,.72), transparent); pointer-events: none; font-size: 13px; }
.room-index b { display: block; color: white; font-size: 16px; margin-bottom: 2px; }

.loading { position: fixed; z-index: 50; inset: 0; display: grid; place-content: center; justify-items: center; background: radial-gradient(circle at center, #37281b, #0d0907 68%); transition: opacity .8s ease, visibility .8s; }
.loading.done { opacity: 0; visibility: hidden; }
.loading-mark { display: grid; place-items: center; width: 76px; height: 76px; border: 1px solid #c99951; border-radius: 50%; color: #e4bd78; font-family: serif; font-size: 36px; }
.loading h1 { margin: 22px 0 2px; font-size: clamp(26px, 4vw, 44px); font-weight: 400; }
.loading p { color: #c6b79e; }
.loading-line { width: 240px; height: 2px; overflow: hidden; background: rgba(255,255,255,.1); }
.loading-line span { display: block; width: 45%; height: 100%; background: #d2a55f; animation: load 1.4s infinite ease-in-out; }
@keyframes load { from { transform: translateX(-110%); } to { transform: translateX(250%); } }

.modal { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(5,4,3,.84); backdrop-filter: blur(13px); transition: opacity .25s ease, visibility .25s; }
.modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.modal-card { position: relative; width: min(760px, 100%); max-height: calc(100vh - 48px); overflow: auto; padding: clamp(28px, 5vw, 58px); border: 1px solid rgba(211,166,94,.42); background: linear-gradient(145deg, rgba(55,39,27,.98), rgba(15,11,8,.98)); box-shadow: 0 28px 90px #000; }
.intro-card { text-align: center; }
.intro-card h1 { font-size: clamp(35px, 6vw, 64px); font-weight: 400; margin: 12px 0 4px; color: #fff3da; }
.intro-subtitle { margin: 0 auto 26px; color: #cfbea0; font-size: clamp(17px, 2.2vw, 23px); line-height: 1.7; }
.route-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 24px 0; }
.route-grid div { padding: 13px 6px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.22); }
.route-grid b, .route-grid span { display: block; }
.route-grid b { color: #f3d89f; font-size: 19px; }
.route-grid span { color: #a99c87; font-size: 12px; }
.intro-control { color: #aaa092; font-size: 13px; line-height: 1.8; }
.primary-button { margin-top: 10px; padding: 12px 40px; border: 1px solid #d6aa62; color: #1a120b; background: #d6aa62; cursor: pointer; font-weight: 700; transition: .2s; }
.primary-button:hover { background: #f0cb88; transform: translateY(-2px); }
.close-button { position: absolute; top: 12px; right: 15px; z-index: 2; width: 42px; height: 42px; border: 0; color: #eee2ce; background: transparent; font-size: 34px; cursor: pointer; }
.help-card h2 { font-size: 34px; font-weight: 400; margin: 5px 0 20px; }
.help-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; }
.help-columns h3 { color: #e4bd78; }
.help-columns p { line-height: 1.9; color: #d0c3ae; }
kbd { display: inline-block; padding: 1px 7px; min-width: 26px; border: 1px solid #776650; border-radius: 3px; background: #211a14; color: #fff; text-align: center; }

.photo-modal { grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: clamp(24px, 4vw, 60px); padding: clamp(28px, 5vw, 70px); }
.photo-stage { display: grid; place-items: center; height: calc(100vh - 100px); min-width: 0; }
.photo-stage img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 25px 80px #000; }
.photo-copy { align-self: center; }
.photo-copy h2 { margin: 10px 0; font-size: clamp(28px, 3.5vw, 48px); line-height: 1.35; font-weight: 400; color: #fff1d5; }
.photo-copy p { color: #bdb09c; line-height: 1.8; overflow-wrap: anywhere; }
.photo-close { position: fixed; top: 18px; right: 22px; }
.error { position: fixed; z-index: 100; inset: auto 20px 20px; padding: 18px; color: white; background: #8d2a23; }
.hidden { display: none; }

.touch-ui { display: none; }
.joystick { position: fixed; z-index: 12; left: 24px; bottom: 28px; width: 116px; height: 116px; border: 1px solid rgba(255,239,209,.35); border-radius: 50%; background: rgba(20,14,10,.4); touch-action: none; }
.joystick span { position: absolute; left: 34px; top: 34px; width: 48px; height: 48px; border-radius: 50%; background: rgba(226,184,110,.72); transform: translate(0,0); }
.touch-actions { position: fixed; z-index: 12; right: 18px; bottom: 24px; display: grid; gap: 8px; }
.touch-actions button { min-width: 104px; padding: 11px; border: 1px solid rgba(255,239,209,.4); color: #fff3dd; background: rgba(20,14,10,.68); border-radius: 7px; }

@media (pointer: coarse), (max-width: 760px) {
  .touch-ui { display: block; }
  .prompt { bottom: 154px; min-width: 0; width: calc(100vw - 36px); font-size: 13px; }
  .room-index { display: none; }
  .top-hud { padding: 14px 16px; }
  .top-hud h2 { max-width: calc(100vw - 76px); }
  .photo-modal { display: flex; flex-direction: column; overflow: auto; gap: 20px; padding: 58px 20px 28px; }
  .photo-stage { flex: 0 0 auto; height: 58vh; }
  .photo-copy { width: 100%; }
  .photo-copy h2 { font-size: 27px; }
  .help-columns { grid-template-columns: 1fr; gap: 8px; }
}

@media (max-width: 520px) {
  .route-grid { grid-template-columns: 1fr 1fr; }
  .intro-card { padding: 28px 20px; }
  .intro-card h1 { font-size: 36px; }
}
