: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(16px, calc(env(safe-area-inset-top) + 8px));
  right: max(18px, calc(env(safe-area-inset-right) + 10px));
  left: max(18px, calc(env(safe-area-inset-left) + 10px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 24px;
  color: rgb(245, 246, 243);
  font-size: clamp(11px, 0.82vw, 13px);
  font-weight: 620;
  line-height: 1.35;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 600ms ease;
}

.hud.is-hidden {
  opacity: 0;
}

.hud.is-loading-hidden {
  visibility: hidden;
  opacity: 0;
  transition: none;
}

.hud.is-loading-reveal {
  transition: none;
}

.hud p {
  margin: 0;
}

.hud-room-line {
  min-width: 0;
  white-space: nowrap;
}

.hud-instruction {
  white-space: nowrap;
  text-align: right;
}

.boot-notice {
  position: fixed;
  z-index: 7;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: min(520px, calc(100vw - 40px));
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: rgba(0, 0, 0, 0.85);
  box-shadow: none;
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  text-transform: uppercase;
  backdrop-filter: none;
  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;
}

.door-prompt {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 20px));
  transform: translate(-50%, 8px);
  max-width: min(360px, calc(100vw - 32px));
  padding: 4px 8px;
  border: 0;
  border-radius: 0;
  background: none;
  color: rgba(245, 246, 243, 0.85);
  box-shadow: none;
  font-size: clamp(12px, 0.82vw, 14px);
  font-weight: 620;
  letter-spacing: 0.02em;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}

.door-prompt.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.door-prompt[hidden] {
  display: none;
}

.door-transition-fade {
  position: fixed;
  z-index: 14;
  inset: 0;
  background: #050706;
  opacity: 0;
  pointer-events: none;
  transition-property: opacity;
  transition-timing-function: ease;
}

.note-popup {
  position: fixed;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(18, 24, 22, 0.16);
  opacity: 0;
  pointer-events: auto;
  transition: opacity 160ms ease;
}

.note-popup.is-open {
  opacity: 1;
}

.note-popup[hidden] {
  display: none;
}

.note-popup-panel {
  position: relative;
  width: min(520px, calc(100vw - 36px));
  max-height: min(72dvh, 620px);
  overflow: auto;
  padding: 25px 27px 26px;
  border: 1px solid rgba(55, 72, 66, 0.16);
  border-radius: 17px;
  background: rgba(250, 249, 244, 0.96);
  color: var(--ink);
  box-shadow: 0 20px 70px rgba(18, 24, 22, 0.24);
  backdrop-filter: blur(18px) saturate(0.86);
}

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

.note-popup h2 {
  margin: 0 42px 12px 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.note-popup p {
  white-space: pre-line;
}

#notePopupBody {
  margin: 0;
  color: #34403c;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
}

.note-popup-close {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(55, 72, 66, 0.14);
  border-radius: 50%;
  background: rgba(239, 241, 235, 0.92);
  color: var(--ink);
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.generic-popup {
  position: fixed;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(18, 24, 22, 0.16);
  opacity: 0;
  pointer-events: auto;
  transition: opacity 160ms ease;
}

.generic-popup.is-open {
  opacity: 1;
}

.generic-popup[hidden] {
  display: none;
}

.generic-popup-panel {
  position: relative;
  width: min(640px, calc(100vw - 36px));
  max-height: min(76dvh, 680px);
  overflow: auto;
  padding: 25px 27px 26px;
  border: 1px solid rgba(55, 72, 66, 0.16);
  border-radius: 17px;
  background: rgba(250, 249, 244, 0.96);
  color: var(--ink);
  box-shadow: 0 20px 70px rgba(18, 24, 22, 0.24);
  backdrop-filter: blur(18px) saturate(0.86);
}

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

.generic-popup h2 {
  margin: 0 42px 12px 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

#genericPopupImage {
  display: block;
  width: 100%;
  max-height: min(58dvh, 520px);
  object-fit: contain;
  border-radius: 10px;
}

#genericPopupBody {
  margin: 0;
  color: #34403c;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
  white-space: pre-line;
}

.generic-popup-close {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(55, 72, 66, 0.14);
  border-radius: 50%;
  background: rgba(239, 241, 235, 0.92);
  color: var(--ink);
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.email-popup {
  position: fixed;
  z-index: 13;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(10, 15, 13, 0.56);
  opacity: 0;
  pointer-events: auto;
  transition: opacity 160ms ease;
}

.email-popup.is-open {
  opacity: 1;
}

.email-popup[hidden] {
  display: none;
}

.email-popup-panel {
  position: relative;
  width: min(920px, calc(100vw - 36px));
  max-height: min(82dvh, 680px);
  overflow: hidden;
  border: 1px solid rgba(55, 72, 66, 0.18);
  border-radius: 17px;
  background: rgba(248, 247, 241, 0.98);
  color: #202a27;
  box-shadow: 0 24px 80px rgba(7, 11, 9, 0.4);
  backdrop-filter: blur(18px) saturate(0.86);
}

.email-popup-close {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(55, 72, 66, 0.14);
  border-radius: 50%;
  background: rgba(239, 241, 235, 0.92);
  color: var(--ink);
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.email-popup-header {
  padding: 18px 72px 16px 22px;
  border-bottom: 1px solid rgba(55, 72, 66, 0.14);
}

.email-popup-header p {
  margin: 0 0 4px;
  color: #587a6f;
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.email-popup-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.email-popup-layout {
  display: grid;
  grid-template-columns: minmax(220px, 32%) minmax(0, 1fr);
  height: calc(min(82dvh, 680px) - 77px);
  min-height: 430px;
  max-height: calc(min(82dvh, 680px) - 77px);
}

.email-popup-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border-right: 1px solid rgba(55, 72, 66, 0.14);
  background: rgba(235, 237, 230, 0.66);
}

.email-popup-list-item {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid rgba(55, 72, 66, 0.11);
  background: transparent;
  color: #26302d;
  text-align: left;
  cursor: pointer;
}

.email-popup-list-item.is-selected {
  background: rgba(88, 122, 111, 0.17);
  box-shadow: inset 3px 0 #587a6f;
}

.email-popup-sender {
  font-size: 12px;
  font-weight: 740;
  line-height: 1.2;
}

.email-popup-subject {
  color: #5d6864;
  font-size: 11px;
  font-weight: 560;
  line-height: 1.3;
}

.email-popup-message {
  min-height: 0;
  overflow: auto;
  padding: 24px 28px 30px;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.email-popup-meta {
  position: sticky;
  z-index: 1;
  top: -24px;
  display: grid;
  gap: 6px;
  margin: 0 0 22px;
  padding-top: 24px;
  padding-right: 8px;
  padding-bottom: 16px;
  padding-left: 8px;
  border-bottom: 1px solid rgba(55, 72, 66, 0.14);
  background: rgba(248, 247, 241, 0.98);
}

.email-popup-meta div {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 9px;
}

.email-popup-meta dt {
  color: #77817d;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.email-popup-meta dd {
  margin: 0;
  color: #36413d;
  font-size: 12px;
  font-weight: 580;
}

.email-popup-message h3 {
  margin: 0 0 14px;
  font-size: 21px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.email-popup-message p {
  margin: 0;
  color: #34403c;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.58;
  white-space: pre-line;
}

.siri-popup {
  position: fixed;
  z-index: 14;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(8, 13, 12, 0.58);
  opacity: 0;
  pointer-events: auto;
  transition: opacity 160ms ease;
}

.siri-popup.is-open {
  opacity: 1;
}

.siri-popup[hidden] {
  display: none;
}

.siri-popup-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(760px, calc(100vw - 36px));
  height: min(82dvh, 680px);
  max-height: min(82dvh, 680px);
  min-height: min(420px, calc(100dvh - 72px));
  overflow: hidden;
  border: 1px solid rgba(70, 94, 88, 0.2);
  border-radius: 17px;
  background: rgba(248, 247, 241, 0.98);
  color: #202a27;
  box-shadow: 0 24px 80px rgba(7, 11, 9, 0.42);
  backdrop-filter: blur(18px) saturate(0.86);
}

.siri-popup-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 19px 19px 17px 24px;
  border-bottom: 1px solid rgba(55, 72, 66, 0.14);
}

.siri-popup-header h2 {
  min-width: 0;
  margin: 0;
  color: #202a27;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: 0;
}

.siri-popup-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.siri-popup-next,
.siri-popup-close {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(55, 72, 66, 0.16);
  border-radius: 50%;
  background: rgba(239, 241, 235, 0.94);
  color: var(--ink);
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.siri-popup-next {
  font-size: 25px;
  font-weight: 760;
}

.siri-password-view {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 30px 32px;
}

.siri-password-view[hidden] {
  display: none;
}

.siri-password-view label {
  display: grid;
  gap: 10px;
  color: #34403c;
  font-size: 14px;
  font-weight: 720;
}

.siri-password-input {
  width: min(360px, 100%);
  border: 1px solid rgba(55, 72, 66, 0.22);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255, 255, 251, 0.96);
  color: #202a27;
  font: inherit;
}

.siri-password-submit {
  width: fit-content;
  border: 1px solid rgba(55, 72, 66, 0.16);
  border-radius: 999px;
  padding: 10px 18px;
  background: rgba(239, 241, 235, 0.94);
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
}

.siri-password-error {
  margin: 0;
  color: #8b3832;
  font-size: 13px;
  font-weight: 680;
}

.siri-popup-text {
  min-height: 0;
  overflow: auto;
  padding: 26px 32px 34px;
  color: #34403c;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.68;
  letter-spacing: 0;
  white-space: pre-line;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

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

@media (hover: none),
  (pointer: coarse),
  (any-hover: none),
  (any-pointer: coarse) {
  .movement-pad {
    display: block;
  }
}

@media (max-width: 740px), (max-height: 520px) {
  .hud {
    top: max(12px, calc(env(safe-area-inset-top) + 6px));
    right: max(12px, calc(env(safe-area-inset-right) + 8px));
    left: max(12px, calc(env(safe-area-inset-left) + 8px));
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
    font-size: clamp(10px, 2.8vw, 12px);
  }

  .hud-instruction {
    justify-self: end;
  }

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

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

  .note-popup-panel {
    width: min(430px, calc(100vw - 24px));
    padding: 20px 21px 22px;
    border-radius: 14px;
  }

  .note-popup h2 {
    font-size: 20px;
  }

  #notePopupBody {
    font-size: 14px;
  }

  .email-popup-panel {
    width: min(760px, calc(100vw - 24px));
    max-height: min(88dvh, 620px);
    border-radius: 14px;
  }

  .email-popup-layout {
    grid-template-columns: minmax(190px, 38%) minmax(0, 1fr);
    height: calc(min(88dvh, 620px) - 71px);
    min-height: 360px;
    max-height: calc(min(88dvh, 620px) - 71px);
  }

  .email-popup-header {
    padding: 15px 64px 14px 18px;
  }

  .email-popup-header h2 {
    font-size: 19px;
  }

  .email-popup-list-item {
    padding: 11px 13px;
  }

  .email-popup-message {
    padding: 20px 21px 24px;
  }
}

@media (max-width: 560px) and (orientation: portrait) {
  .email-popup {
    padding: max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .email-popup-panel {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .email-popup-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(148px, 38dvh) minmax(0, 1fr);
    height: calc(100dvh - 88px);
    min-height: 0;
    max-height: calc(100dvh - 88px);
  }

  .email-popup-list {
    border-right: 0;
    border-bottom: 1px solid rgba(55, 72, 66, 0.14);
  }

  .email-popup-list-item {
    padding: 10px 13px;
  }

  .email-popup-message {
    padding: 17px 18px 22px;
  }

  .email-popup-message h3 {
    font-size: 18px;
  }
}

@media (max-height: 430px) {
  .hud {
    top: max(8px, calc(env(safe-area-inset-top) + 4px));
    gap: 1px;
    font-size: 10px;
  }

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

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

  .email-popup {
    padding: max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .email-popup-panel {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .email-popup-header {
    padding: 10px 15px 9px;
  }

  .email-popup-layout {
    grid-template-columns: minmax(180px, 34%) minmax(0, 1fr);
    height: calc(100dvh - 65px);
    min-height: 0;
    max-height: calc(100dvh - 65px);
  }

  .email-popup-list-item {
    padding: 8px 11px;
  }

  .email-popup-message {
    padding: 13px 18px 16px;
  }

  .email-popup-meta {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .email-popup-message h3 {
    margin-bottom: 9px;
    font-size: 17px;
  }

  .email-popup-message p {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud,
  .movement-pad,
  .boot-notice,
  .note-popup,
  .generic-popup,
  .email-popup,
  .door-prompt,
  .door-transition-fade {
    transition: none;
  }
}
