* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1117; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #eef1f5; }
#c { display: block; width: 100%; height: 100%; }
button { font: inherit; cursor: pointer; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #hud canvas { pointer-events: auto; }
#topleft { position: absolute; left: 14px; top: 12px; }
#roomlabel { background: rgba(10, 14, 20, 0.72); backdrop-filter: blur(6px); padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 15px; letter-spacing: 0.2px; border: 1px solid rgba(255,255,255,0.08); }
#fps { margin-top: 6px; font-size: 11px; color: rgba(255,255,255,0.55); padding-left: 4px; }
#levels { position: absolute; right: 14px; top: 12px; display: flex; gap: 6px; }
#levels button { background: rgba(10, 14, 20, 0.72); color: #eef1f5; border: 1px solid rgba(255,255,255,0.14); border-radius: 9px; padding: 8px 12px; font-weight: 600; backdrop-filter: blur(6px); }
#levels button.active { background: #2e7d32; border-color: #4caf50; }
#levels button:hover { border-color: #9be7a3; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255,255,255,0.8); box-shadow: 0 0 0 1px rgba(0,0,0,0.5); }
body:not(.playing) #crosshair { display: none; }
#hint { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); background: rgba(10, 14, 20, 0.72); padding: 8px 14px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity 0.2s; border: 1px solid rgba(255,255,255,0.1); }
#hint.on { opacity: 1; }
#flash { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); background: rgba(46,125,50,0.85); padding: 8px 14px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity 0.3s; }
#flash.on { opacity: 1; }
#minimap { position: absolute; left: 14px; bottom: 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14); width: 200px; height: 276px; }
#bottomright { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; }
#bottomright button { background: rgba(10, 14, 20, 0.72); color: #eef1f5; border: 1px solid rgba(255,255,255,0.14); border-radius: 9px; padding: 8px 12px; font-weight: 600; backdrop-filter: blur(6px); min-width: 42px; }
#joy { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.08); display: none; }
#joy.on { display: block; }
#joyknob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.55); }
body.nohud #hud, body.nohud #intro, body.nohud #resume { display: none !important; }

.card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 92vw); background: rgba(14, 18, 26, 0.92); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 26px 28px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5); z-index: 20; }
.card h1 { margin: 0 0 4px; font-size: 26px; }
.card .addr { margin: 0 0 14px; color: #9be7a3; font-weight: 600; }
.card p { line-height: 1.45; font-size: 15px; margin: 8px 0; }
.card .keys { font-size: 13px; color: rgba(255,255,255,0.75); }
.card .fine, .fine { font-size: 12px; color: rgba(255,255,255,0.55); }
.card button, .panel .floors button, #photosnap { background: #2e7d32; color: #fff; border: 0; border-radius: 10px; padding: 12px 22px; font-weight: 700; font-size: 16px; margin-top: 8px; }
.card button:hover { background: #388e3c; }
.hidden { display: none !important; }
.touchonly { display: none; }
body.touch .touchonly { display: block; }
body.touch #crosshair { display: none; }

#photo { position: fixed; top: 62px; right: 0; bottom: 0; width: min(46vw, 640px); transform: translateX(105%); transition: transform 0.25s ease; z-index: 15; }
#photo.open { transform: none; }
#photo .inner { height: 100%; overflow: auto; background: rgba(10, 13, 18, 0.94); backdrop-filter: blur(10px); border-left: 1px solid rgba(255,255,255,0.12); border-top: 1px solid rgba(255,255,255,0.12); border-top-left-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
#photo img { width: 100%; height: auto; border-radius: 10px; background: #222; min-height: 120px; }
#photo .bar, .panel .bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#photo .bar span:first-child { font-weight: 700; }
#photo .bar button, .panel .bar button { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; padding: 6px 10px; }
#photosnap { padding: 8px 14px; font-size: 14px; margin: 0; }
#photodesc { line-height: 1.45; font-size: 14px; margin: 0; }

.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.98); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 18; width: min(560px, 92vw); }
.panel.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.panel .inner { background: rgba(14, 18, 26, 0.95); border: 1px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 18px 22px; max-height: 84vh; overflow: auto; }
.panel ul { padding-left: 18px; line-height: 1.5; font-size: 14px; }
.panel .floors { display: flex; flex-direction: column; gap: 8px; }
#drawings { display: flex; flex-wrap: wrap; gap: 6px; }
#drawings button { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.18); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
#err { display: none; position: fixed; left: 50%; top: 20px; transform: translateX(-50%); background: #b71c1c; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; }

#roomlabel { max-width: min(60vw, 520px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) {
  #minimap { width: 110px; height: 152px; }
  #levels { top: auto; bottom: 64px; right: 14px; gap: 4px; }
  #levels button { padding: 6px 8px; font-size: 12px; }
  #photo { width: 100vw; top: 52px; }
  #roomlabel { font-size: 13px; max-width: calc(100vw - 28px); }
  #hint { top: 58px; bottom: auto; font-size: 12px; max-width: calc(100vw - 28px); }
  #flash { top: 96px; }
}

/* drag-to-look fallback hint */
body.draglook.playing canvas{cursor:grab}
body.draglook.playing canvas:active{cursor:grabbing}
body.draglook.playing #hud::after{content:'Drag to look · W A S D to walk';position:fixed;left:50%;bottom:18px;transform:translateX(-50%);background:rgba(8,12,20,.75);color:#fff;font:13px system-ui,sans-serif;padding:6px 12px;border-radius:999px;pointer-events:none}
