/* ==========================================================================
   1. BASE & CYBERPUNK CONFIG
   ========================================================================== */
@import url('https://googleapis.com');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Share Tech Mono', monospace;
  user-select: none;
}

body {
  background-color: #030307;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

/* --- 全体ゲームコンテナ --- */
#game-container {
  width: 900px;
  height: 650px;
  background: #06070d;
  border: 2px solid #00f0ff;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.2);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- サイバーエフェクト（グリッド＆スキャンライン） --- */
.cyber-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 25px 25px;
  pointer-events: none;
  z-index: 90;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.3) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 99;
}

/* ==========================================================================
   2. SCENE ROUTER (FLOW SYSTEM)
   ========================================================================== */
.game-scene {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 10;
}

.game-scene.active-scene {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   3. TITLE VIEW (START SCREEN)
   ========================================================================== */
#scene-title {
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #0f111a 0%, #05060b 100%);
}

.title-logo-large {
  text-align: center;
  margin-bottom: 50px;
  position: relative;
}

.glitch-main {
  font-size: 56px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 15px #ff0055, 0 0 30px rgba(255, 0, 85, 0.5);
  letter-spacing: 6px;
  animation: pulse 2s infinite alternate;
}

.subtitle-large {
  font-size: 16px;
  color: #00f0ff;
  letter-spacing: 4px;
  margin-top: 10px;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

.btn-cyber {
  background: transparent;
  border: 1px solid #00f0ff;
  color: #00f0ff;
  padding: 15px 40px;
  font-size: 18px;
  cursor: pointer;
  letter-spacing: 2px;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.1);
}

.btn-cyber:hover {
  background: #00f0ff;
  color: #000;
  box-shadow: 0 0 20px #00f0ff;
}

/* ==========================================================================
   4. STAGE SELECT VIEW
   ========================================================================== */
#scene-select {
  padding: 40px;
  background: #07080e;
  align-items: center;
}

.select-header {
  font-size: 24px;
  color: #00f0ff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  margin-bottom: 40px;
  letter-spacing: 2px;
  border-bottom: 1px dashed #00f0ff;
  width: 100%;
  text-align: center;
  padding-bottom: 15px;
}

.stage-grid {
  display: flex;
  gap: 30px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 800px;
}

.stage-card {
  width: 220px;
  height: 280px;
  background: rgba(16, 20, 35, 0.6);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.3s ease;
}

.stage-card:hover {
  border-color: #00f0ff;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
  transform: translateY(-5px);
}

.stage-num {
  font-size: 14px;
  color: rgba(0, 240, 255, 0.6);
}

.stage-name {
  font-size: 20px;
  color: #fff;
  margin-top: 10px;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.stage-status {
  font-size: 12px;
  padding: 6px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #ff0055;
  color: #ff0055;
}

/* クリア済みのカード補正 */
.stage-card.cleared-card {
  border-color: #00ff66;
}
.stage-card.cleared-card .stage-status {
  border-color: #00ff66;
  color: #00ff66;
  text-shadow: 0 0 5px rgba(0, 255, 102, 0.5);
}

.btn-back {
  margin-top: auto;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.6);
  padding: 10px 25px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-back:hover {
  border-color: #fff;
  color: #fff;
}
/* ==========================================================================
   5. GAMEPLAY VIEW HEADER
   ========================================================================== */
.cyber-header {
  height: 75px;
  border-bottom: 2px dashed #ff0055;
  background: rgba(11, 13, 23, 0.9);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 80;
}
.header-logo-group {
  display: flex;
  flex-direction: column;
}
.glitch-text {
  font-size: 22px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 8px #ff0055;
  letter-spacing: 1px;
}
.subtitle {
  font-size: 11px;
  color: #00f0ff;
}
.status-panel {
  font-size: 13px;
  border: 1px solid #00f0ff;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  gap: 15px;
}
.text-neon-blue { color: #00f0ff; text-shadow: 0 0 5px #00f0ff; }
.text-neon-red { color: #ff0055; text-shadow: 0 0 5px #ff0055; }

/* ==========================================================================
   6. MAIN LAB VIEWPORT & ROOMS
   ========================================================================== */
#stage-viewport {
  flex: 1;
  position: relative;
  z-index: 50;
}
.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  /* 近未来ラボのベース背景テクスチャ描写（黒い隙間を無くす） */
  background: linear-gradient(180deg, #0f1220 0%, #07080f 100%);
  padding: 20px;
}
.screen.active { 
  display: block; 
}
.screen-title {
  position: absolute;
  top: 15px;
  left: 20px;
  font-size: 12px;
  color: rgba(0, 240, 255, 0.6);
  letter-spacing: 1px;
}

/* --- 精密な背景フレーム装飾（ラボの壁面ライン） --- */
.screen::before {
  content: '';
  position: absolute;
  inset: 15px;
  border: 1px solid rgba(0, 240, 255, 0.1);
  border-bottom: 3px solid rgba(0, 240, 255, 0.15);
  pointer-events: none;
}

/* ==========================================================================
   7. GIMMICK OBJECTS DESIGNS
   ========================================================================== */
.cyber-object {
  position: absolute;
  background: rgba(14, 18, 36, 0.85);
  border: 1px solid #00f0ff;
  box-shadow: inset 0 0 15px rgba(0, 240, 255, 0.15);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.cyber-object:hover {
  box-shadow: 0 0 15px #00f0ff, inset 0 0 10px rgba(0, 240, 255, 0.3);
  background: rgba(20, 28, 54, 0.9);
}

/* ――― 【中央画面オブジェクト】 ――― */
.door-locked {
  width: 150px;
  height: 250px;
  top: 60px;
  left: 375px;
  border: 2px solid #ff0055;
  box-shadow: 0 0 15px rgba(255, 0, 85, 0.2), inset 0 0 20px rgba(255, 0, 85, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
}
.door-panel { text-align: center; }
.neon-led { width: 14px; height: 14px; border-radius: 50%; margin: 0 auto 12px; }
.red-pulse { background: #ff0055; box-shadow: 0 0 12px #ff0055; animation: pulse 0.8s infinite alternate; }
.green-on { background: #00ff66; box-shadow: 0 0 15px #00ff66; }
.panel-text { font-size: 13px; color: #fff; letter-spacing: 1px; }

.tech-desk {
  width: 360px;
  height: 110px;
  bottom: 30px;
  left: 270px;
  border-top: 3px solid #00f0ff;
  border-radius: 4px 4px 0 0;
}
#hologram {
  width: 200px;
  height: 90px;
  position: absolute;
  top: -105px;
  left: 80px;
  border: 1px dashed rgba(0, 240, 255, 0.6);
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.02) 0%, rgba(0, 240, 255, 0.1) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #00f0ff;
  text-shadow: 0 0 8px #00f0ff;
  text-align: center;
  font-size: 11px;
  padding: 5px;
}
.holo-glitch { animation: holo-shimmer 2.5s infinite linear; }
.desk-drawer {
  width: 100px;
  height: 45px;
  border: 1px solid rgba(0, 240, 255, 0.6);
  position: absolute;
  bottom: 15px;
  left: 25px;
  padding: 8px;
  font-size: 12px;
  color: #00f0ff;
  background: rgba(0,0,0,0.3);
}

/* ――― 【左画面オブジェクト】 ――― */
.power-node {
  width: 190px;
  height: 150px;
  top: 90px;
  left: 110px;
  padding: 20px;
}
.node-title { font-size: 13px; color: #00f0ff; border-bottom: 1px solid rgba(0,240,255,0.3); padding-bottom: 5px; }
.status-indicator { font-size: 20px; font-weight: bold; margin-top: 25px; text-align: center; letter-spacing: 2px; }
.offline { color: #ff0055; text-shadow: 0 0 6px #ff0055; }
.online { color: #00ff66; text-shadow: 0 0 12px #00ff66; }

.bio-tube {
  width: 130px;
  height: 280px;
  bottom: 50px;
  right: 130px;
  border-radius: 40px 40px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#tube-fluid {
  width: 100%;
  flex: 1;
  transition: all 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.fluid-muddy { background: linear-gradient(180deg, rgba(30, 22, 12, 0.2) 0%, rgba(153, 99, 18, 0.7) 100%); }
.fluid-clear { background: linear-gradient(180deg, rgba(0, 240, 255, 0.05) 0%, rgba(0, 240, 255, 0.4) 100%); }
.tube-label { font-size: 11px; text-align: center; padding: 8px; background: #0c0e17; border-top: 1px solid rgba(0,240,255,0.3); color: #fff; }

/* ――― 【右画面オブジェクト】 ――― */
.scrap-robot {
  width: 160px;
  height: 200px;
  bottom: 50px;
  left: 110px;
  padding: 15px;
  text-align: center;
}
.robot-eye-off { width: 40px; height: 6px; background: #222533; margin: 25px auto 15px; border-radius: 3px; }
.robot-eye-on { width: 40px; height: 6px; background: #ff0055; box-shadow: 0 0 12px #ff0055; margin: 25px auto 15px; border-radius: 3px; animation: pulse 0.4s infinite alternate; }
.object-label { font-size: 11px; display: block; margin-top: 15px; color: #00f0ff; background: rgba(0,0,0,0.4); padding: 4px; border: 1px solid rgba(0,240,255,0.2); }

.neon-board {
  width: 250px;
  height: 180px;
  top: 70px;
  right: 90px;
  border: 1px solid #00f0ff;
  box-shadow: inset 0 0 15px rgba(0,240,255,0.1);
  padding: 18px;
  font-size: 12px;
  color: #00f0ff;
  line-height: 1.5;
}
/* ==========================================================================
   8. NAVIGATION ARROWS
   ========================================================================== */
.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(10, 12, 22, 0.95);
  border: 1px solid #00f0ff;
  color: #00f0ff;
  padding: 16px 12px;
  cursor: pointer;
  z-index: 75;
  font-size: 13px;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.arrow:hover {
  background: #00f0ff;
  color: #000;
  box-shadow: 0 0 15px #00f0ff;
}
.arrow-left { left: 20px; }
.arrow-right { right: 20px; }

/* ==========================================================================
   9. GAMEPLAY VIEW FOOTER (INVENTORY)
   ========================================================================== */
.cyber-footer {
  height: 105px;
  border-top: 2px solid #00f0ff;
  background: #090a10;
  display: flex;
  z-index: 80;
}
.inventory-section {
  width: 60%;
  border-right: 1px solid rgba(0, 240, 255, 0.2);
  padding: 12px 20px;
}
.memory-section {
  width: 40%;
  padding: 12px 20px;
  position: relative;
}
.section-label {
  font-size: 11px;
  color: rgba(0, 240, 255, 0.5);
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.slots-container {
  display: flex;
  gap: 12px;
}
.slot {
  width: 90px;
  height: 52px;
  border: 1px dashed rgba(0, 240, 255, 0.4);
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 11px;
  color: #00ff66;
  cursor: pointer;
  text-align: center;
  padding: 4px;
  transition: all 0.2s;
}
.slot.active-item {
  border: 1px solid #00ff66;
  box-shadow: 0 0 10px #00ff66;
  color: #fff;
  background: rgba(0, 255, 102, 0.1);
}
.letters-container {
  font-size: 26px;
  color: #ff0055;
  text-shadow: 0 0 10px #ff0055;
  letter-spacing: 6px;
  font-weight: bold;
  margin-top: 4px;
}
.btn-giveup {
  position: absolute;
  right: 20px;
  bottom: 15px;
  background: transparent;
  border: 1px solid rgba(255, 0, 85, 0.5);
  color: #ff0055;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
}
.btn-giveup:hover {
  background: #ff0055;
  color: #000;
  box-shadow: 0 0 8px #ff0055;
}

/* ==========================================================================
   10. ITEM DETAIL MODAL (DOUBLE CLICK POPUP)
   ========================================================================== */
#item-modal {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 9, 0.9);
  backdrop-filter: blur(5px);
  z-index: 150;
  justify-content: center;
  align-items: center;
}
#modal-content {
  width: 420px;
  background: #0b0d16;
  border: 2px solid #00f0ff;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
  padding: 24px;
  text-align: center;
}
#modal-title {
  font-size: 15px;
  color: #00f0ff;
  border-bottom: 1px dashed rgba(0, 240, 255, 0.4);
  padding-bottom: 10px;
  margin-bottom: 18px;
  letter-spacing: 1px;
}
#modal-description {
  font-size: 13px;
  color: #fff;
  line-height: 1.6;
  margin-bottom: 22px;
  white-space: pre-wrap;
  text-align: left;
}
.modal-close-btn {
  background: transparent;
  border: 1px solid #ff0055;
  color: #ff0055;
  padding: 6px 18px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}
.modal-close-btn:hover {
  background: #ff0055;
  color: #000;
  box-shadow: 0 0 10px #ff0055;
}
#modal-graphic {
  margin: 15px auto;
  display: flex;
  justify-content: center;
  gap: 10px;
}
.card-led {
  width: 32px;
  height: 48px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
}
.bg-red { background: #ff0055; box-shadow: 0 0 12px #ff0055; }
.bg-blue { background: #00f0ff; box-shadow: 0 0 12px #00f0ff; }

/* ==========================================================================
   11. STAGE CLEAR OVERLAY ANIMATION
   ========================================================================== */
#clear-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 255, 102, 0.15);
  z-index: 200;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.5s ease forwards;
}
.clear-window {
  width: 460px;
  background: #060a12;
  border: 2px solid #00ff66;
  box-shadow: 0 0 35px rgba(0, 255, 102, 0.4);
  padding: 35px;
  text-align: center;
}
.clear-banner {
  font-size: 38px;
  font-weight: bold;
  color: #00ff66;
  text-shadow: 0 0 15px #00ff66;
  letter-spacing: 4px;
  margin-bottom: 15px;
}
.clear-msg {
  font-size: 14px;
  color: #fff;
  line-height: 1.6;
  margin-bottom: 30px;
}

/* ==========================================================================
   12. ANIMATIONS ENGINE
   ========================================================================== */
@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes holo-shimmer {
  0%, 100% { opacity: 0.75; transform: skewX(0deg); filter: brightness(1); }
  50% { opacity: 0.95; transform: skewX(1.5deg); filter: brightness(1.2); }
}