:root {
  --ink: #1f2a24;
  --paper: #ffffff;
  --muted: #5c6660;
  --accent: #2f5d46;
  --accent-ink: #ffffff;
  --glass: rgba(255, 255, 255, 0.88);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c9d6e2; color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }
.hud { position: fixed; z-index: 5; }

#room { top: max(12px, env(safe-area-inset-top)); left: 12px; background: var(--glass); padding: 7px 12px;
  border-radius: 8px; font-weight: 600; box-shadow: var(--shadow); max-width: 52vw; }
#room.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: #fff8d8; } 100% { background: var(--glass); } }

#mapwrap { top: max(12px, env(safe-area-inset-top)); right: 12px; background: var(--glass); border-radius: 10px;
  padding: 6px; box-shadow: var(--shadow); }
#map { display: block; width: 150px; height: 160px; touch-action: none; cursor: pointer; }
.mapbtn { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 12px; font-weight: 600; padding: 4px 8px;
  border-radius: 6px; border: 1px solid #c8cfca; background: #fff; color: var(--ink); cursor: pointer; }

#joy { position: fixed; z-index: 6; left: 18px; bottom: calc(86px + env(safe-area-inset-bottom)); width: 120px; height: 120px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.28); border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow); touch-action: none; display: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3); }
body.touch #joy { display: block; }

#bar { left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--glass); box-shadow: 0 -2px 12px rgba(0,0,0,.12); }
.who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who span { color: var(--muted); font-size: 13px; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn { display: inline-block; font: inherit; font-weight: 600; font-size: 14px; padding: 9px 14px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; border: 0; cursor: pointer; white-space: nowrap; }
.btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn:focus-visible, .mapbtn:focus-visible, #map:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.btn[disabled] { opacity: 0.6; cursor: default; }
.narrow { display: none; }
#note { right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); margin: 0; font-size: 12px; color: #26302a;
  background: rgba(255, 255, 255, 0.7); padding: 3px 8px; border-radius: 6px; }

#intro, #bigmap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 28, 24, 0.45); padding: 16px; }
#bigmap[hidden] { display: none; }
.card, .bigcard { background: var(--paper); border-radius: 14px; padding: 22px 22px 20px; max-width: 420px; width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); }
.bigcard { max-width: 640px; text-align: center; }
#map2 { width: 100%; height: auto; max-height: 70vh; aspect-ratio: 600 / 640; touch-action: none; cursor: pointer; }
.bigcard p { margin: 6px 0 12px; color: var(--muted); }
.card h1 { margin: 0 0 4px; font-size: 22px; line-height: 1.25; }
.card .sub { margin: 0 0 16px; color: var(--muted); }
#progress { height: 8px; background: #e6ebe8; border-radius: 4px; overflow: hidden; }
#pbar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#ptext { margin: 8px 0 12px; font-size: 13px; color: var(--muted); }
.how { margin: 0 0 18px; padding-left: 20px; }
.how li { margin: 3px 0; }
body.touch .how .mouse, body:not(.touch) .how .touch { display: none; }
#start { width: 100%; padding: 12px; font-size: 16px; }

#ctl { right: 12px; bottom: calc(100px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.zoom { display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.zoom button { width: 46px; height: 46px; border: 0; background: var(--glass); color: var(--ink); font: 600 24px/1 -apple-system, Segoe UI, Roboto, sans-serif; cursor: pointer; }
.zoom button + button { border-top: 1px solid #d5dbd7; }
.zoom button:focus-visible { outline: 3px solid #f2b705; outline-offset: -3px; }
#intro.gone { display: none; }
.nojs { position: fixed; inset: auto 16px 50% 16px; background: #fff; padding: 16px; border-radius: 10px; z-index: 30; }

@media (min-width: 760px) {
  #map { width: 220px; height: 235px; }
  #room { font-size: 17px; }
}
@media (max-width: 480px) {
  #bar { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .who strong { font-size: 14px; }
  .who span { font-size: 12px; }
  .btn { padding: 8px 10px; font-size: 13px; }
  .acts .ghost { padding: 8px 12px; }
  .wide { display: none; }
  .narrow { display: inline; }
  #note { bottom: calc(60px + env(safe-area-inset-bottom)); font-size: 11px; }
  #joy { bottom: calc(80px + env(safe-area-inset-bottom)); }
  #ctl { bottom: calc(92px + env(safe-area-inset-bottom)); }
}

#setbtn { width: 46px; height: 46px; border: 0; border-radius: 10px; background: var(--glass); color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer; display: flex; align-items: center; justify-content: center; }
#setbtn[aria-expanded="true"] { background: var(--accent); color: #fff; }
#setbtn:focus-visible, #setclose:focus-visible, #settings input:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
#settings { right: 70px; bottom: calc(100px + env(safe-area-inset-bottom)); width: min(260px, calc(100vw - 94px));
  background: var(--paper); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); z-index: 7; }
#settings[hidden] { display: none; }
.sethead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#setclose { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
#settings label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-top: 8px; }
#settings label span { color: var(--muted); font-weight: 400; }
#settings input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 2px; }
#settings .hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
body.touch #settings .hint { display: none; }
@media (max-width: 480px) { #settings { bottom: calc(92px + env(safe-area-inset-bottom)); } }
