:root {
  --ink: #25292c;
  --muted: #6d7378;
  --accent-yellow: #f2c230;
  --accent-tosca: #4fb8a8;
  --accent-tosca-dark: #2a7f74;
  --sign-blue: #2a4fa0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #bfe6ee;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#scene {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
  outline: none;
}

.joystick {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.55);
  touch-action: none;
}

.joystick[hidden] { display: none; }

.joystick-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.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.prompt {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-yellow);
  color: var(--ink);
  font: 600 15px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.prompt[hidden],
.dialog[hidden],
.info-panel[hidden],
.info-media[hidden],
.toolbar[hidden],
.minimap[hidden],
.sheet[hidden],
.loading[hidden] { display: none; }

.dialog {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px));
  padding: 14px 18px 12px;
  border-radius: 12px;
  background: #ffffff;
  z-index: 2;
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  border-top: 4px solid var(--accent-tosca);
  cursor: pointer;
  user-select: none;
}

.dialog-head { margin: 0 0 6px; }
.dialog-name { font-weight: 700; font-size: 16px; color: var(--sign-blue); }
.dialog-role { font-size: 13px; color: var(--muted); }
.dialog-text { margin: 0 0 8px; font-size: 16px; line-height: 1.5; }
.dialog-next { display: block; text-align: right; font-size: 14px; font-weight: 600; color: var(--accent-tosca-dark); }

.info-panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 30, 34, 0.45);
}

.info-card {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px 20px 16px;
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border-top: 5px solid var(--accent-yellow);
}

.info-title { margin: 0 36px 12px 0; font-size: 20px; color: var(--sign-blue); }
.info-body p { margin: 0 0 10px; font-size: 15px; line-height: 1.55; }
.info-link {
  display: block;
  margin-top: 4px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--accent-tosca-dark);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.info-link:hover { background: #226b62; }
.info-link:focus-visible { outline: 3px solid var(--accent-yellow); outline-offset: 2px; }
.info-media { margin: 0 0 12px; }
.info-media img,
.info-media video,
.info-media iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; object-fit: cover; }

.info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #eef1f2;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

body.touch .prompt { bottom: 160px; }
body.touch .dialog { bottom: 160px; }

.debug-stats {
  position: fixed;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #9f9;
  font: 12px/1.3 ui-monospace, Consolas, monospace;
  white-space: pre;
  pointer-events: none;
}

.toolbar {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 1;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 44px;
  height: 44px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.tool-btn svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.tool-btn:hover { background: #ffffff; }
.tool-btn:focus-visible,
.minimap:focus-visible,
.sheet button:focus-visible { outline: 3px solid var(--accent-tosca-dark); outline-offset: 2px; }
#btn-locations { background: var(--accent-yellow); }
#btn-audio .icon-off,
#btn-audio[aria-pressed="true"] .icon-on { display: none; }
#btn-audio[aria-pressed="true"] .icon-off { display: block; }

.minimap {
  position: fixed;
  right: 12px;
  bottom: 12px;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  overflow: hidden;
  background: #9fc88a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  cursor: zoom-in;
  z-index: 1;
}

.minimap canvas { display: block; width: 132px; height: auto; }
.minimap.expanded { cursor: zoom-out; }
.minimap.expanded canvas { width: auto; height: min(70dvh, 560px); max-width: calc(100vw - 24px); }

.sheet {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 30, 34, 0.45);
  z-index: 3;
}

.sheet-card {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border-top: 5px solid var(--accent-tosca);
}

.sheet-title { margin: 0 36px 14px 0; font-size: 20px; color: var(--sign-blue); }

.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #eef1f2;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.location-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.location-list button {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #dfe4e5;
  border-radius: 10px;
  background: #f7f9f9;
  color: var(--ink);
  text-align: left;
  font: 600 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}

.location-list button:hover { border-color: var(--accent-tosca); background: #eef8f6; }
.location-list small { display: block; margin-top: 2px; font-weight: 400; font-size: 13px; color: var(--muted); }
.location-floor { margin-top: 6px; font: 700 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.location-floor:first-child { margin-top: 0; }

.help-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; font-size: 15px; line-height: 1.45; }
.help-list span { display: block; color: var(--muted); font-size: 14px; }
.help-list .mark { color: #9a7400; }
.help-touch { display: none; }
body.touch .help-desktop { display: none; }
body.touch .help-touch { display: grid; }

kbd {
  display: inline-block;
  min-width: 24px;
  margin-right: 3px;
  padding: 2px 6px;
  border: 1px solid #cfd5d7;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #f4f6f6;
  font: 600 13px/1.2 ui-monospace, Consolas, monospace;
  text-align: center;
}

.sheet-action {
  display: block;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-yellow);
  color: var(--ink);
  font: 700 16px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}

.fade {
  position: fixed;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
  z-index: 4;
}

.fade.on { opacity: 1; }

.loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(#6fb7e8, #d6eef2);
  z-index: 5;
  transition: opacity 0.4s;
}

.loading.done { opacity: 0; pointer-events: none; }

.loading-card { width: min(360px, 100%); text-align: center; color: var(--ink); }
.loading-school { margin: 0; font-size: 14px; font-weight: 600; color: var(--sign-blue); letter-spacing: 0.02em; }
.loading-title { margin: 4px 0 20px; font-size: 30px; line-height: 1.15; }
.loading-bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.7); overflow: hidden; }
.loading-bar span { display: block; width: 4%; height: 100%; background: var(--accent-tosca-dark); transition: width 0.3s; }
.loading-status { margin: 10px 0 0; font-size: 14px; color: #3c474c; }
.loading-error { color: #a3271f; }

body.touch .tool-label { display: none; }
body.touch .minimap { right: 12px; bottom: auto; top: 64px; }
body.touch .minimap canvas { width: 96px; }
body.touch .minimap.expanded canvas { width: auto; height: min(64dvh, 520px); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; background: var(--accent-tosca-dark); color: #fff; font: 600 17px/1.5 system-ui, sans-serif; text-align: center; }
