:root {
  color-scheme: light;
  --ink: #26302d;
  --muted: #68736f;
  --panel: rgba(250, 250, 247, 0.88);
  --panel-line: rgba(55, 72, 66, 0.14);
  --accent: #587a6f;
  --error: #a14d48;
  --shadow: 0 16px 52px rgba(48, 55, 51, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #e7e4dc;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}

#appShell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#sceneHost {
  position: fixed;
  inset: 0;
}

#sceneHost canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.sr-only {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hud {
  position: fixed;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  width: 320px;
  max-width: calc(100vw - 28px - env(safe-area-inset-left));
  pointer-events: none;
}

.hud-title {
  padding: 14px 17px 15px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(0.8);
}

.hud-title h1 {
  margin: 3px 0 6px;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 720;
}

.hud-title p {
  margin: 0;
}

.hud-kicker {
  color: var(--accent);
  font-size: 10px;
  line-height: 1.1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 760;
}

#hudSubtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 560;
}

.hud-instruction {
  margin-top: 8px !important;
  padding-top: 8px;
  border-top: 1px solid var(--panel-line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  font-weight: 600;
}

.touch-hint {
  display: none;
}

.boot-notice {
  position: fixed;
  z-index: 7;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: min(520px, calc(100vw - 40px));
  padding: 13px 18px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: rgba(250, 250, 247, 0.94);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.boot-notice.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.movement-pad {
  display: none;
  position: fixed;
  z-index: 6;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 124px;
  height: 124px;
  border-radius: 50%;
  opacity: 0.56;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 180ms ease;
}

.movement-pad.is-active {
  opacity: 0.94;
}

.movement-pad-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(239, 243, 238, 0.45);
  border-radius: 50%;
  background: rgba(25, 32, 29, 0.26);
  box-shadow:
    inset 0 0 0 1px rgba(18, 24, 22, 0.2),
    0 8px 24px rgba(18, 24, 22, 0.14);
  backdrop-filter: blur(7px);
}

.movement-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(244, 247, 243, 0.62);
  border-radius: 50%;
  background: rgba(226, 232, 226, 0.5);
  box-shadow: 0 5px 15px rgba(18, 24, 22, 0.22);
  transform: translate(-50%, -50%);
  will-change: transform;
}

.boot-notice.is-error {
  border-color: rgba(161, 77, 72, 0.35);
  color: var(--error);
  text-transform: none;
}

body.touch-capable .desktop-hint {
  display: none;
}

body.touch-capable .touch-hint {
  display: inline;
}

body.touch-capable .movement-pad {
  display: block;
}

@media (hover: none),
  (pointer: coarse),
  (any-hover: none),
  (any-pointer: coarse) {
  .desktop-hint {
    display: none;
  }

  .touch-hint {
    display: inline;
  }

  .movement-pad {
    display: block;
  }
}

@media (max-width: 740px), (max-height: 520px) {
  .hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: min(270px, calc(100vw - 16px - env(safe-area-inset-left)));
  }

  .hud-title {
    padding: 9px 12px 10px;
    border-radius: 12px;
  }

  .hud-title h1 {
    margin: 2px 0 4px;
    font-size: 17px;
  }

  #hudSubtitle {
    font-size: 11px;
  }

  .hud-instruction {
    margin-top: 6px !important;
    padding-top: 6px;
    font-size: 10px;
  }

  .movement-pad {
    width: 108px;
    height: 108px;
  }

  .movement-thumb {
    width: 42px;
    height: 42px;
  }
}

@media (max-height: 430px) {
  .hud {
    width: 235px;
  }

  .hud-title {
    padding: 7px 10px 8px;
  }

  .hud-kicker {
    font-size: 8px;
  }

  .hud-title h1 {
    font-size: 15px;
  }

  .hud-instruction {
    display: none;
  }

  .movement-pad {
    width: 92px;
    height: 92px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .movement-thumb {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .movement-pad,
  .boot-notice {
    transition: none;
  }
}
