:root {
  color-scheme: dark;
  --glass: rgba(10, 27, 39, 0.62);
  --glass-strong: rgba(7, 20, 30, 0.84);
  --line: rgba(219, 242, 255, 0.28);
  --text: #f7fbff;
  --muted: rgba(238, 248, 255, 0.7);
  --accent: #ffd19b;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #100c18;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

button, input { font: inherit; }

#experience {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  overflow: hidden;
  background: radial-gradient(circle at 35% 42%, #8f4e42 0%, #292036 44%, #080711 100%);
  isolation: isolate;
}

#panorama {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}

#panorama.ready { opacity: 1; }
#panorama.dragging { cursor: grabbing; }

.loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  gap: 14px;
  color: rgba(255,255,255,.82);
  font-size: .82rem;
  letter-spacing: .18em;
  background: #0c0912;
  transition: opacity .6s ease, visibility .6s;
}

.loading.hidden { opacity: 0; visibility: hidden; }

.loading-mark {
  width: 34px;
  height: 34px;
  justify-self: center;
  border: 1px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.9);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.identity {
  position: absolute;
  z-index: 4;
  top: max(24px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  color: var(--text);
  text-shadow: 0 2px 16px rgba(0,0,0,.55);
  pointer-events: none;
}

.identity p {
  margin: 0 0 6px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .28em;
  opacity: .78;
}

.identity h1 {
  margin: 0;
  font-family: "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: clamp(1.65rem, 3.4vw, 2.6rem);
  font-weight: 300;
  letter-spacing: .12em;
  line-height: 1;
}

.identity span {
  display: block;
  margin-top: 8px;
  font-size: .76rem;
  letter-spacing: .14em;
  opacity: .82;
}

.start-panel {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 28px;
  color: var(--text);
  text-align: center;
  background: linear-gradient(180deg, rgba(3,12,18,.08), rgba(3,12,18,.48));
  transition: opacity .9s ease, visibility .9s;
}

.start-panel.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.end-panel {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 28px;
  color: var(--text);
  text-align: center;
  background: rgba(3, 12, 18, .72);
  backdrop-filter: blur(10px);
  transition: opacity .65s ease, visibility .65s;
}

.end-panel.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.end-copy p {
  margin: 0 0 13px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .3em;
  opacity: .72;
}

.end-copy h2 {
  margin: 0;
  font-family: "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: clamp(2rem, 6vw, 3.6rem);
  font-weight: 300;
  letter-spacing: .15em;
}

.end-copy span {
  display: block;
  margin-top: 14px;
  font-size: .85rem;
  letter-spacing: .14em;
  opacity: .78;
}

.end-actions { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.end-actions a { text-decoration: none; }
.enter-button.secondary {
  color: var(--text);
  border: 1px solid rgba(255,255,255,.34);
  background: rgba(255,255,255,.08);
}
.enter-button.secondary:hover { background: rgba(255,255,255,.16); }

.start-copy p {
  margin: 0 0 16px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .32em;
  opacity: .78;
}

.start-copy h2 {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 3.2rem);
  font-weight: 400;
  line-height: 1.48;
  letter-spacing: .08em;
  text-shadow: 0 4px 28px rgba(0,0,0,.58);
}

.start-copy span {
  display: block;
  margin-top: 18px;
  font-size: .78rem;
  letter-spacing: .16em;
  opacity: .7;
}

.enter-button {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 15px 22px 15px 26px;
  color: #06121a;
  border: 0;
  border-radius: 2px;
  background: rgba(242,251,255,.92);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .18em;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  transition: background .2s ease, transform .2s ease;
}

.enter-button:hover { background: white; transform: translateY(-2px); }
.enter-button:focus-visible { outline: 3px solid #72cdf5; outline-offset: 4px; }
.enter-button i { width: 28px; height: 1px; background: currentColor; position: relative; }
.enter-button i::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  width: 7px;
  height: 7px;
  border-top: 1px solid;
  border-right: 1px solid;
  transform: rotate(45deg);
}

.controls {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 10px));
  width: min(920px, calc(100% - 32px));
  min-height: 64px;
  transform: translateX(-50%) translateY(110px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--glass);
  color: var(--text);
  box-shadow: 0 14px 46px rgba(0,0,0,.28);
  backdrop-filter: blur(18px) saturate(120%);
  transition: transform .75s cubic-bezier(.2,.8,.2,1);
}

.controls.visible { transform: translateX(-50%) translateY(0); }
.sound-group, .music-group { display: flex; align-items: center; gap: 9px; min-width: 0; }
.spacer { flex: 1; }
.divider { width: 1px; height: 30px; background: var(--line); margin: 0 2px; }

button { -webkit-tap-highlight-color: transparent; }

.icon-button, .text-button {
  min-height: 42px;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 1rem;
}

.icon-button:hover, .text-button:hover { background: rgba(255,255,255,.1); }
.icon-button:focus-visible, .text-button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-button:disabled { opacity: .35; cursor: default; }
.control-label, .utility-label { font-size: .78rem; letter-spacing: .08em; }
.sound-icon { width: 26px; letter-spacing: -2px; }
.compact { width: 42px; }
.utility { min-width: 42px; border-left: 1px solid rgba(255,255,255,.09); }
.icon-button.exit-mode {
  padding-inline: 14px;
  color: #07151e;
  background: rgba(244, 252, 255, .94);
  font-weight: 700;
}
.icon-button.exit-mode:hover { background: #fff; }
.end-button { color: rgba(255,255,255,.82); }
.end-button:hover { background: rgba(126, 27, 34, .42); }

.text-button {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: .78rem;
  letter-spacing: .05em;
  white-space: nowrap;
}

#musicName { overflow: hidden; text-overflow: ellipsis; }
.plus { font-size: 1.1rem; font-weight: 300; }
.range-wrap { display: flex; width: 90px; padding: 10px 2px; }
.music-volume { width: 70px; }

input[type="range"] {
  width: 100%;
  height: 3px;
  appearance: none;
  border-radius: 4px;
  background: linear-gradient(to right, rgba(231,249,255,.9) 55%, rgba(255,255,255,.22) 55%);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%;
  background: #17384b;
}

.reticle {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 50%;
  opacity: 0;
  transition: opacity .6s;
  pointer-events: none;
}

.entered .reticle { opacity: .48; }

.look-hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  margin: 0;
  color: rgba(255,255,255,.88);
  font-size: .75rem;
  letter-spacing: .13em;
  text-shadow: 0 2px 12px rgba(0,0,0,.65);
  opacity: 0;
  transition: opacity .8s;
  pointer-events: none;
}

.entered .look-hint { opacity: 1; }
.entered.interacted .look-hint { opacity: 0; }

.privacy-note {
  position: absolute;
  z-index: 4;
  bottom: 98px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 11px;
  border-radius: 3px;
  color: rgba(255,255,255,.78);
  background: rgba(4,15,23,.58);
  font-size: .7rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s;
}

.privacy-note.show { opacity: 1; visibility: visible; }

.vignette {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(1,8,12,.18) 100%);
}

@media (max-width: 720px) {
  .identity { top: max(18px, env(safe-area-inset-top)); left: 18px; }
  .identity p { font-size: .58rem; }
  .identity span { font-size: .7rem; }
  .controls {
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100% - 20px);
    min-height: 58px;
    gap: 5px;
    padding: 8px;
  }
  .control-label, .utility-label, .range-wrap, .divider { display: none; }
  .fullscreen-label { display: none; font-size: .72rem; white-space: nowrap; }
  .icon-button.exit-mode .fullscreen-label { display: inline; }
  .icon-button.exit-mode { min-width: 108px; padding-inline: 10px; }
  .controls.fullscreen-active #resetButton { display: none; }
  .controls.fullscreen-active .text-button { max-width: 90px; }
  .sound-group, .music-group { gap: 2px; }
  .text-button { max-width: 145px; padding-inline: 7px; }
  .utility { min-width: 38px; padding-inline: 6px; }
  .look-hint { bottom: 88px; }
  .privacy-note { bottom: 82px; width: max-content; max-width: calc(100% - 24px); text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
