*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100dvh;
  background: #010208; overflow: hidden; cursor: none;
}

/* ===== Page transition ===== */
@keyframes slideFromRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideFromLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes slideOutLeft {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(-100%); opacity: 0; }
}
@keyframes slideOutRight {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(100%);  opacity: 0; }
}
body.slide-from-right { animation: slideFromRight .4s ease-out both; }
body.slide-from-left  { animation: slideFromLeft  .4s ease-out both; }
body.slide-out-left   { animation: slideOutLeft   .3s ease-in both; }
body.slide-out-right  { animation: slideOutRight  .3s ease-in both; }

/* ===== Scene layers ===== */
.scene { position: fixed; inset: 0; overflow: hidden; }
.bg-placeholder {
  position: absolute; inset: 0;
}
.bg-grade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg,
    rgba(0,4,20,.25) 0%, rgba(5,12,35,.08) 42%, rgba(0,2,10,.45) 100%);
}
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 88% 80% at 50% 50%,
    transparent 30%, rgba(0,0,6,.6) 100%);
}
.scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg,
    transparent, transparent 3px, rgba(0,0,0,.055) 3px, rgba(0,0,0,.055) 4px);
  animation: scanShift 8s linear infinite;
}
@keyframes scanShift { 0%{background-position:0 0} 100%{background-position:0 80px} }
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .038;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 185px; mix-blend-mode: overlay;
}
.chroma {
  position: absolute; inset: 0; pointer-events: none; z-index: 18;
  mix-blend-mode: screen; opacity: 0; transition: opacity .08s;
}
.glitching .chroma { opacity: 1; }
#rain {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; opacity: .65;
}
#glitch-overlay {
  position: fixed; inset: 0; z-index: 17;
  pointer-events: none; mix-blend-mode: screen;
}
.glitching #glitch-overlay {
  animation: sceneGlitch .12s steps(1) 2;
}
@keyframes sceneGlitch {
  0%  { transform:translate(0,0);      filter:none; }
  30% { transform:translate(-3px,1px); filter:hue-rotate(12deg) saturate(1.4); }
  60% { transform:translate(3px,-1px); filter:hue-rotate(-8deg) saturate(1.3); }
  100%{ transform:translate(0,0);      filter:none; }
}

/* ===== Location label ===== */
.loc-label {
  font-family: 'Space Mono', monospace;
  font-size: clamp(11px, 1.4vw, 14px);
  letter-spacing: .22em;
  color: rgba(255,255,255,.8);
  text-align: center;
  line-height: 1.8;
  text-shadow: 0 0 16px rgba(0,0,0,1), 0 2px 6px rgba(0,0,0,.9);
  opacity: 0;
  animation: textReveal .6s ease-out .1s both;
}

/* ===== Main content ===== */
.loc-content {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 20; pointer-events: none;
  gap: clamp(20px, 4vh, 48px);
}

.loc-title-block {
  text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center;
}
@keyframes textReveal {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.loc-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(42px, 7vw, 80px);
  max-width: 80vw;
  letter-spacing: .15em; line-height: 1;
  color: #fff;
  filter: drop-shadow(0 0 28px rgba(56,232,255,.12));
  text-shadow: 0 2px 12px rgba(0,0,0,.25);
  opacity: 0;
  animation: textReveal .8s ease-out .3s both;
}
.loc-atmosphere {
  font-family: 'Space Mono', monospace;
  font-size: clamp(12px, 1.4vw, 16px);
  letter-spacing: .18em; line-height: 1.9;
  color: rgba(255,255,255,.85);
  text-shadow: 0 0 12px rgba(0,0,0,.8), 0 2px 4px rgba(0,0,0,.6);
}
.loc-atmosphere span {
  opacity: 0;
  animation: textReveal .4s ease-out both;
}

/* ===== Footer (hidden on location pages) ===== */
.site-footer { display: none; }

/* ===== Nav ===== */
.loc-nav {
  position: fixed; bottom: clamp(24px,4vh,44px); left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  transition: opacity .35s ease;
}
/* 漫画リーディング中はEXPLOREを退避（コマの上に被らないように） */
body.comic-reading .loc-nav { opacity: 0; pointer-events: none; }
.loc-nav__btn {
  font-family: 'Space Mono', monospace;
  font-size: 10px; font-weight: 700; letter-spacing: .36em;
  color: rgba(56,232,255,.9); text-decoration: none;
  pointer-events: auto; transition: all .3s ease;
  border: 1px solid rgba(56,232,255,.5);
  background: rgba(0,4,20,.5);
  backdrop-filter: blur(10px);
  padding: 14px 24px;
  display: block;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(56,232,255,.15), inset 0 0 12px rgba(56,232,255,.05);
  text-shadow: 0 0 8px rgba(56,232,255,.6);
}
.loc-nav__btn:hover {
  color: #fff;
  border-color: rgba(56,232,255,1);
  background: rgba(0,12,40,.7);
  box-shadow: 0 0 24px rgba(56,232,255,.4), inset 0 0 20px rgba(56,232,255,.1);
  text-shadow: 0 0 12px rgba(56,232,255,1);
  letter-spacing: .42em;
}
/* ===== Cursor ===== */
.cur-dot, .cur-ring {
  position: fixed; border-radius: 50%;
  pointer-events: none; transform: translate(-50%,-50%);
}
.cur-dot {
  z-index: 9100; width: 8px; height: 8px; background: #ff4d2e;
  box-shadow: 0 0 12px 3px rgba(255,77,46,.70);
  transition: width .18s, height .18s, background .18s, box-shadow .18s;
}
.cur-ring {
  z-index: 9099; width: 36px; height: 36px;
  border: 1.5px solid rgba(255,77,46,.40);
  transition: width .18s, height .18s, border-color .18s;
}
body:has(a:hover) .cur-dot {
  width: 14px; height: 14px; background: #c8ff3e;
  box-shadow: 0 0 18px 5px rgba(200,255,62,.65);
}
body:has(a:hover) .cur-ring {
  width: 56px; height: 56px; border-color: rgba(200,255,62,.32);
}

/* ===== Night horror overlay (station/RUM) ===== */
.horror-glitch {
  position: fixed; inset: 0; z-index: 19;
  pointer-events: none; opacity: 0;
  background: repeating-linear-gradient(0deg,
    rgba(255,0,40,.03) 0px, rgba(255,0,40,.03) 2px,
    transparent 2px, transparent 4px);
  animation: horrorPulse 3s ease-in-out infinite;
}
.is-night .horror-glitch { opacity: 1; }
@keyframes horrorPulse {
  0%,100% { opacity: 0; }
  50% { opacity: 1; }
}

/* ===== Location prev/next ===== */
.loc-pn {
  position: fixed; top: 50%; z-index: 9999;
  transform: translateY(-50%);
  pointer-events: auto;
  padding: 16px;
  text-decoration: none;
  display: block;
}
.loc-pn svg {
  width: 36px; height: auto;
  display: block;
  filter: drop-shadow(0 0 6px rgba(56,232,255,.2));
}
.loc-pn svg polygon {
  fill: none;
  stroke: rgba(255,255,255,.45);
  stroke-miterlimit: 10;
  stroke-width: 5px;
  transition: stroke .3s, filter .3s;
}
.loc-pn:hover svg polygon {
  stroke: rgba(56,232,255,1);
  filter: drop-shadow(0 0 12px rgba(56,232,255,.8));
}
.loc-pn--prev { left: 10px; }
.loc-pn--next { right: 10px; }

/* ===== TOWER locked style ===== */
.night-signal { display: none; }
body[data-location="tower"] .night-signal { display: block; }
body[data-location="tower"] .loc-name { color: rgba(255,46,80,.5); }
body[data-location="tower"] .loc-atmosphere { color: rgba(255,255,255,.85); }

.sealed-badge {
  display: none !important;
  font-family: 'Space Mono', monospace;
  font-size: 9px; font-weight: 700; letter-spacing: .45em;
  color: #fff;
  background: rgba(255,46,80,.75);
  padding: 6px 18px;
}
body[data-location="tower"] .sealed-badge { display: inline-block !important; }

/* ===== EIGHT (ロケ×時間帯で出現) ===== */
.eight-appear {
  position: absolute;
  left: 74%;
  bottom: 6%;
  height: 21vh;
  transform: translateX(-50%);
  z-index: 2;
  cursor: pointer;
}
.eight-appear canvas {
  display: block;
  height: 100%;
  width: auto;
}
@media (max-width: 640px) {
  .eight-appear { height: 15vh; bottom: 12%; }
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .loc-pn { padding: 10px; }
  .loc-pn--prev { left: 2px; }
  .loc-pn--next { right: 2px; }
  .loc-pn svg { width: 22px; }
  .loc-content { gap: 16px; padding: 0 20px; }
  body { cursor: auto; }
  .cur-dot, .cur-ring { display: none; }
}

/* ===== WARNING OVERLAY ===== */
#loc-warning {
  position: fixed; inset: 0; z-index: 200000;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: default;
}
#lw-noise {
  position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  background-size: 180px 180px; opacity: .55;
  animation: lwNoise .12s steps(1) infinite;
}
@keyframes lwNoise {
  0%{background-position:0 0}25%{background-position:40px 20px}50%{background-position:80px 60px}75%{background-position:20px 80px}100%{background-position:60px 40px}
}
#lw-scan {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0px, transparent 3px, rgba(0,0,0,.22) 3px, rgba(0,0,0,.22) 4px);
}
#lw-sweep {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
#lw-sweep::after {
  content: ''; position: absolute; left: 0; right: 0; height: 60px;
  background: linear-gradient(to bottom, transparent, rgba(56,232,255,.04), transparent);
  animation: lwSweep 4s linear infinite;
}
@keyframes lwSweep { 0%{top:-60px} 100%{top:100%} }
#lw-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  gap: 40px; text-align: center;
  animation: lwFlicker 7s infinite;
}
@keyframes lwFlicker {
  0%,100%{opacity:1}88%{opacity:1}89%{opacity:.45}90%{opacity:1}94%{opacity:1}95%{opacity:.75}95.5%{opacity:1}
}
.lw-icon {
  font-size: 32px; color: rgba(255,60,60,.8);
  text-shadow: 0 0 12px rgba(255,60,60,.5);
  animation: lwIconPulse 2s ease-in-out infinite;
}
@keyframes lwIconPulse { 0%,100%{opacity:.7} 50%{opacity:1} }
.lw-title {
  font-family: 'Space Mono', monospace;
  font-size: 13px; font-weight: 700; letter-spacing: .46em;
  color: rgba(240,237,230,.85);
  position: relative;
  animation: lwRgb 3s ease-in-out infinite;
}
@keyframes lwRgb {
  0%,100%{text-shadow:1px 0 0 rgba(255,60,60,.25),-1px 0 0 rgba(56,232,255,.25)}
  50%{text-shadow:2px 0 0 rgba(255,60,60,.45),-2px 0 0 rgba(56,232,255,.45)}
}
.lw-divider {
  width: 180px; height: 1px;
  background: linear-gradient(to right, transparent, rgba(56,232,255,.3), transparent);
}
.lw-text {
  font-family: 'Space Mono', monospace;
  font-size: 11px; letter-spacing: .12em; line-height: 2;
  color: rgba(240,237,230,.55);
}
.lw-btns { display: flex; gap: 20px; }
#lw-accept {
  font-family: 'Space Mono', monospace;
  font-size: 11px; font-weight: 700; letter-spacing: .32em;
  color: rgba(56,232,255,.9); background: none; cursor: pointer;
  width: 140px !important; padding: 16px 0 !important;
  border: 1px solid rgba(56,232,255,.5);
  text-shadow: 0 0 8px rgba(56,232,255,.6);
  animation: lwBtnPulse 2.5s ease-in-out infinite;
  transition: background .18s;
}
#lw-accept:hover { background: rgba(56,232,255,.06); }
@keyframes lwBtnPulse {
  0%,100%{box-shadow:0 0 10px rgba(56,232,255,.15),inset 0 0 10px rgba(56,232,255,.05)}
  50%{box-shadow:0 0 22px rgba(56,232,255,.3),inset 0 0 16px rgba(56,232,255,.1)}
}
#lw-back {
  font-family: 'Space Mono', monospace;
  font-size: 11px; font-weight: 700; letter-spacing: .32em;
  color: rgba(240,237,230,.25); background: none; cursor: pointer;
  width: 140px !important; padding: 16px 0 !important;
  border: 1px solid rgba(240,237,230,.1);
  transition: color .18s, border-color .18s;
}
#lw-back:hover { color: rgba(240,237,230,.45); border-color: rgba(240,237,230,.25); }
.lw-corner {
  position: absolute; width: 16px; height: 16px; pointer-events: none;
}
.lw-corner--tl { top:-28px;left:-28px;border-top:1px solid rgba(56,232,255,.35);border-left:1px solid rgba(56,232,255,.35); }
.lw-corner--tr { top:-28px;right:-28px;border-top:1px solid rgba(56,232,255,.35);border-right:1px solid rgba(56,232,255,.35); }
.lw-corner--bl { bottom:-28px;left:-28px;border-bottom:1px solid rgba(56,232,255,.35);border-left:1px solid rgba(56,232,255,.35); }
.lw-corner--br { bottom:-28px;right:-28px;border-bottom:1px solid rgba(56,232,255,.35);border-right:1px solid rgba(56,232,255,.35); }

/* ===== SOUND TOGGLE ===== */
#sound-toggle {
  position: fixed; bottom: 18px; left: 20px; z-index: 90000;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(240,237,230,.12);
  border-radius: 50%; width: 44px; height: 44px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color .25s, background .25s;
}
#sound-toggle.snd-on {
  border-color: rgba(56,232,255,.5);
}
#sound-toggle:hover {
  background: rgba(56,232,255,.08);
}
@media (pointer: coarse) {
  #sound-toggle { bottom: 14px; left: 15px; width: 44px; height: 44px; }
}

/* 動きを減らす設定のユーザー向け安全網: CSSアニメーション/トランジションを短縮 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
