/* ===== リセット・ベース ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #fff;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  user-select: none;
}

/* ===== イントロ画面 ===== */
#intro-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 1s ease-out;
}

#intro-screen.fade-out {
  opacity: 0;
}

#intro-text {
  font-size: 64px;
  font-weight: bold;
  color: #fff;
  letter-spacing: 8px;
}

#intro-time {
  font-size: 28px;
  color: #888;
  letter-spacing: 4px;
  opacity: 0;
  animation: intro-time-fadein 0.5s ease-in 1.5s forwards;
}

@keyframes intro-time-fadein {
  to { opacity: 1; }
}

#intro-start {
  font-size: 20px;
  color: #aaa;
  letter-spacing: 3px;
  margin-top: 32px;
  opacity: 0;
  animation: intro-start-fadein 0.5s ease-in 2.5s forwards, intro-start-blink 1.5s ease-in-out 3s infinite;
  cursor: pointer;
}

@keyframes intro-start-fadein {
  to { opacity: 1; }
}

@keyframes intro-start-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== ゲームコンテナ ===== */
#game-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

#night-label {
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

#time-display {
  font-size: 28px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

#power-display {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  z-index: 30;
  pointer-events: none;
}

#power-bar-container {
  width: 120px;
  height: 16px;
  border: 1px solid #0f0;
  background: #111;
}

#power-bar {
  height: 100%;
  width: 100%;
  background: #0f0;
  transition: width 0.3s, background-color 0.3s;
}

#power-bar.warning {
  background: #ff0;
}

#power-bar.danger {
  background: #f00;
}

#power-percent {
  min-width: 40px;
}

/* ===== 通信端末室ビュー ===== */
#office-view {
  width: 100%;
  height: 100%;
  position: relative;
  background: #050505;
  overflow: hidden;
}

/* 背景画像（open/closed共通） */
.office-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

#office-bg-open {
  z-index: 0;
}

#office-bg-closed {
  z-index: 1;
}

/* 閉鎖画像のclip-path（片方だけ表示用） */
#office-bg-closed.show-left {
  clip-path: inset(0 50% 0 0);
}

#office-bg-closed.show-right {
  clip-path: inset(0 0 0 50%);
}

#office-bg-closed.show-both {
  clip-path: none;
}

/* 扉前キャラ画像（共通スタイル - 全キャラ対応） */
.door-char {
  position: absolute;
  top: 15%;
  height: 65%;
  z-index: 2;
  animation: door-char-sway 3s ease-in-out infinite;
}

.door-char.left {
  left: -6.3%;
  transform: scaleX(-1);
  animation: door-char-sway-left 3s ease-in-out infinite;
}

.door-char.right {
  right: -5%;
}

@keyframes door-char-sway {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes door-char-sway-left {
  0%, 100% { transform: scaleX(-1) translateY(0); }
  50% { transform: scaleX(-1) translateY(-4px); }
}

/* シャッターボタン */
.shutter-btn {
  position: absolute;
  bottom: 15%;
  width: 120px;
  height: 70px;
  background: rgba(20, 20, 20, 0.8);
  border: 2px solid #444;
  color: #ccc;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s;
  z-index: 5;
}

#left-shutter-btn {
  left: 14%;
}

#right-shutter-btn {
  right: 14%;
}

.shutter-btn:hover {
  background: rgba(40, 40, 40, 0.9);
  border-color: #666;
}

.shutter-btn.closed {
  background: rgba(40, 20, 20, 0.9);
  border-color: #f44;
}

.shutter-btn.closed .shutter-state {
  color: #f44;
}

.shutter-state {
  font-size: 18px;
  font-weight: bold;
  color: #0f0;
}

/* カメラ起動ボタン */
#camera-toggle-btn {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 32px;
  background: #1a1a2a;
  border: 2px solid #446;
  color: #8af;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: background 0.15s, border-color 0.15s;
  z-index: 5;
}

#camera-toggle-btn:hover {
  background: #252540;
  border-color: #88f;
}

/* ===== カメラビュー ===== */
#camera-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 20;
}

/* カメラ映像エリア */
#camera-feed {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #0a0a0a;
}

/* 監視カメラの首振り（ゆっくり左右パン） */
@keyframes camera-pan {
  0%, 100% { transform: scale(1.1) translateX(-2%); }
  50% { transform: scale(1.1) translateX(2%); }
}

#camera-label {
  position: absolute;
  top: 44px;
  left: 24px;
  font-size: 18px;
  color: #0f0;
  text-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
  z-index: 5;
}

/* パンレイヤー（背景＋キャラが一緒に動く） */
#camera-pan-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  animation: camera-pan 18s ease-in-out infinite;
}

#camera-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.7) contrast(1.1) saturate(0.6);
}

#camera-char {
  position: absolute;
  z-index: 3;
}

/* スキャンライン */
#scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 200%;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.2) 2px,
    rgba(0, 0, 0, 0.2) 4px
  );
  pointer-events: none;
  z-index: 4;
  animation: scanline-scroll 8s linear infinite;
}

@keyframes scanline-scroll {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* ノイズトランジション */
#camera-noise {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%25" height="100%25" filter="url(%23n)"/></svg>');
  background-size: 200px 200px;
  opacity: 0;
  transition: opacity 0.05s;
}

#camera-noise.active {
  opacity: 0.7;
  animation: noise-flicker 0.15s steps(3) forwards;
}

@keyframes noise-flicker {
  0% { opacity: 0.8; background-position: 0 0; }
  33% { opacity: 0.6; background-position: -50px -30px; }
  66% { opacity: 0.7; background-position: 30px -60px; }
  100% { opacity: 0; background-position: -20px 40px; }
}

/* REC表示 */
#rec-indicator {
  position: absolute;
  top: 16px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
  z-index: 5;
  letter-spacing: 2px;
}

#rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f00;
  box-shadow: 0 0 6px #f00, 0 0 12px #f00;
  animation: rec-blink 1.5s ease-in-out infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* 時計ゲージ */
#clock-gauge-container {
  position: absolute;
  top: 100px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  z-index: 5;
}

#clock-gauge-label {
  font-size: 14px;
  color: #fd0;
  text-shadow: 0 0 8px rgba(255, 220, 0, 0.5);
}

#clock-gauge-bar-container {
  width: 160px;
  height: 16px;
  border: 1px solid #fd0;
  background: #111;
}

#clock-gauge-bar {
  height: 100%;
  width: 100%;
  background: #fd0;
  transition: width 0.2s, background-color 0.3s;
}

#clock-gauge-bar.warning {
  background: #f80;
}

#clock-gauge-bar.danger {
  background: #f00;
  animation: gauge-flash 0.5s infinite;
}

@keyframes gauge-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#clock-gauge-percent {
  font-size: 14px;
  color: #fd0;
}

/* カメラ選択パネル */
#camera-panel {
  position: absolute;
  bottom: 60px;
  right: 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  z-index: 5;
}

.cam-btn {
  width: 72px;
  height: 40px;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #888;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.cam-btn:hover {
  background: #252525;
  border-color: #666;
  color: #ccc;
}

.cam-btn.active {
  background: #1a2a1a;
  border-color: #0f0;
  color: #0f0;
}

/* カメラ閉じるボタン */
#camera-close-btn {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 32px;
  background: #2a1a1a;
  border: 2px solid #644;
  color: #f88;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  cursor: pointer;
  letter-spacing: 2px;
  z-index: 25;
}

#camera-close-btn:hover {
  background: #3a2020;
  border-color: #a66;
}

/* ===== ジャンプスケア ===== */
#jumpscare-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#jumpscare-img {
  max-width: 100%;
  max-height: 100%;
  animation: jumpscare-shake 0.1s infinite;
}

@keyframes jumpscare-shake {
  0% { transform: translate(2px, -2px); }
  25% { transform: translate(-2px, 2px); }
  50% { transform: translate(2px, 2px); }
  75% { transform: translate(-2px, -2px); }
  100% { transform: translate(0, 0); }
}

/* ===== ゲームオーバー ===== */
#gameover-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

#gameover-text {
  font-size: 48px;
  color: #f00;
  text-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
  letter-spacing: 8px;
}

#retry-btn {
  padding: 12px 40px;
  background: #1a1a1a;
  border: 2px solid #f44;
  color: #f88;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  cursor: pointer;
  letter-spacing: 2px;
}

#retry-btn:hover {
  background: #2a1a1a;
}

/* ===== クリア画面 ===== */
#clear-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  animation: clear-fadein 1s ease-in;
}

@keyframes clear-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

#clear-time {
  font-size: 72px;
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
  letter-spacing: 8px;
}

#clear-text {
  font-size: 28px;
  color: #aaa;
  letter-spacing: 4px;
}

#continue-btn {
  margin-top: 20px;
  padding: 12px 40px;
  background: #1a1a1a;
  border: 2px solid #4a4;
  color: #8f8;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  cursor: pointer;
  letter-spacing: 2px;
}

#continue-btn:hover {
  background: #1a2a1a;
}

/* ===== 電力切れオーバーレイ ===== */
#blackout-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 50;
  animation: blackout-flicker 0.3s ease-in;
}

@keyframes blackout-flicker {
  0% { opacity: 0; }
  30% { opacity: 0.8; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* ===== Night5 エンディング演出 ===== */
#ending-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ending-text {
  font-size: 28px;
  color: #ccc;
  letter-spacing: 3px;
  text-align: center;
  line-height: 1.8;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}

#ending-text.visible {
  opacity: 1;
}

/* ===== メタ的ページ ===== */
#meta-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

#meta-title {
  font-size: 36px;
  color: #fff;
  letter-spacing: 6px;
  opacity: 0;
  animation: meta-fadein 2s ease-in 0.5s forwards;
}

#meta-message {
  font-size: 20px;
  color: #999;
  letter-spacing: 2px;
  text-align: center;
  line-height: 2;
  opacity: 0;
  animation: meta-fadein 2s ease-in 2s forwards;
}

#night6-btn {
  margin-top: 40px;
  padding: 10px 30px;
  background: transparent;
  border: 1px solid #333;
  color: #444;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 2px;
  opacity: 0;
  animation: meta-fadein 3s ease-in 8s forwards;
}

#night6-btn:hover {
  border-color: #666;
  color: #888;
}

@keyframes meta-fadein {
  to { opacity: 1; }
}

/* ===== ユーティリティ ===== */
.hidden {
  display: none !important;
}
