:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  --ink: #f8f3e7;
  --muted: #c8c8b9;
  --glass: rgba(12, 25, 20, 0.86);
  --line: rgba(231, 224, 192, 0.2);
  --amber: #f5b947;
  --cyan: #56d6d2;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body,
#world,
#scene,
#scene canvas {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #122a21;
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

#world {
  position: relative;
  min-width: 280px;
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

#scene canvas {
  display: block;
  outline: 0;
}

.hud {
  position: absolute;
  z-index: 5;
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hud-top {
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  min-height: 62px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 6px;
  pointer-events: none;
}

.identity,
.location {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.identity strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2.2vh, 23px);
  line-height: 1.05;
  white-space: nowrap;
}

.kicker,
.panel-label,
.connection {
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.location {
  align-items: flex-end;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.connection {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  color: var(--cyan);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(86, 214, 210, 0.8);
}

.field-notes {
  top: 92px;
  left: max(14px, env(safe-area-inset-left));
  width: min(236px, calc(100vw - 28px));
  padding: 13px 14px;
  border-radius: 6px;
  display: grid;
  gap: 6px;
  pointer-events: none;
}

.field-notes strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.2;
}

.field-notes > span:last-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--amber);
  transition: width 250ms ease;
}

.controls {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  height: 58px;
  padding: 7px;
  display: flex;
  align-items: stretch;
  gap: 5px;
  border-radius: 6px;
}

button {
  border: 1px solid transparent;
  border-radius: 4px;
  font: inherit;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.mode-button {
  min-width: 74px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mode-button.active {
  border-color: rgba(245, 185, 71, 0.45);
  color: #19180f;
  background: var(--amber);
}

.mode-icon {
  width: 23px;
  height: 23px;
  border: 1px solid currentColor;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 21px;
}

.icon-button:hover,
.icon-button.active {
  border-color: var(--line);
  color: var(--amber);
  background: rgba(255, 255, 255, 0.07);
}

.toast {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 91px;
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  padding: 9px 13px;
  transform: translate(-50%, 10px);
  border-left: 3px solid var(--amber);
  border-radius: 2px;
  color: var(--ink);
  background: rgba(12, 25, 20, 0.92);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.compass {
  position: absolute;
  z-index: 4;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 38px;
  height: 50px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.65));
}

.compass i {
  display: block;
  width: 0;
  height: 0;
  margin: 3px auto 0;
  border-right: 8px solid transparent;
  border-bottom: 27px solid var(--amber);
  border-left: 8px solid transparent;
}

.cursor-label {
  position: absolute;
  z-index: 8;
  padding: 5px 8px;
  transform: translate(13px, 13px);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  background: rgba(10, 19, 16, 0.9);
  font-size: 11px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
}

.cursor-label.show {
  opacity: 1;
}

.loading {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  color: var(--ink);
  background: #122a21;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  text-align: center;
  transition: opacity 350ms ease, visibility 350ms ease;
}

.loading span {
  width: 36px;
  height: 36px;
  margin: auto;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.loading.done {
  opacity: 0;
  visibility: hidden;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 620px) {
  .hud-top {
    min-height: 56px;
    padding: 8px 10px;
  }

  .identity strong {
    font-size: 15px;
  }

  .kicker {
    display: none;
  }

  .location {
    font-size: 11px;
  }

  .field-notes {
    top: 80px;
    width: min(210px, calc(100vw - 28px));
    padding: 10px 11px;
  }

  .field-notes strong {
    font-size: 15px;
  }

  .controls {
    height: 54px;
  }

  .mode-button {
    min-width: 61px;
    padding: 4px 7px;
  }

  .mode-icon {
    display: none;
  }

  .icon-button {
    width: 38px;
    min-width: 38px;
  }

  .compass {
    display: none;
  }

  .toast {
    bottom: 84px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
