/* =============================================================
   VRコアルーム「ロベリア拷問ゲーム」モック（0616版）
   816x624 固定ステージ + MZ風ウィンドウ + 左選択肢 + 感応率ゲージ
   ============================================================= */

:root {
  --cyan: #19f2dc;
  --cyan-dim: rgba(25, 242, 220, 0.55);
  --font-game: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-dot: "DotGothic16", "Meiryo", monospace;
  --font-term: "Share Tech Mono", "DotGothic16", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  background: #04050d radial-gradient(1200px 800px at 50% 40%, #0b0d22 0%, #04050d 70%);
  overflow: hidden;
  font-family: var(--font-game);
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------- ステージ（整数スケール） ---------------- */
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 816px;
  height: 624px;
  margin: -312px 0 0 -408px;
  transform-origin: 50% 50%;
  background: #000;
  box-shadow: 0 0 90px rgba(20, 40, 120, 0.35);
}
#view {
  position: absolute;
  inset: 0;
  image-rendering: pixelated;
}
#ui {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* ---------------- MZ風メッセージウィンドウ ---------------- */
.msg-window {
  position: absolute;
  left: 16px;
  right: 90px; /* 右サイド感応率ゲージを避ける */
  bottom: 14px;
  height: 148px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(24, 40, 82, 0.93), rgba(9, 15, 40, 0.95));
  border: 2px solid rgba(232, 238, 255, 0.88);
  box-shadow: 0 0 0 2px rgba(10, 18, 46, 0.85), inset 0 0 26px rgba(80, 120, 255, 0.14);
  padding: 14px 24px 12px;
  color: #fff;
  font-size: 22px;
  line-height: 1.55;
  z-index: 40;
}
.msg-name {
  position: absolute;
  top: -36px;
  left: 6px;
  min-width: 130px;
  text-align: center;
  padding: 4px 18px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(24, 40, 82, 0.95), rgba(9, 15, 40, 0.96));
  border: 2px solid rgba(232, 238, 255, 0.88);
  box-shadow: 0 0 0 2px rgba(10, 18, 46, 0.85);
  font-size: 17px;
  color: #ffce73;
}
.msg-text {
  white-space: pre-wrap;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}
.msg-pause {
  position: absolute;
  bottom: 4px;
  left: 50%;
  margin-left: -7px;
  color: #fff;
  font-size: 14px;
  animation: pause-bounce 0.7s ease-in-out infinite;
}
@keyframes pause-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ---------------- ト書きナレーション帯 ---------------- */
.narration {
  position: absolute;
  left: 0;
  right: 0;
  top: 37%;
  background: rgba(2, 4, 14, 0.78);
  border-top: 1px solid rgba(190, 210, 255, 0.4);
  border-bottom: 1px solid rgba(190, 210, 255, 0.4);
  padding: 24px 30px 14px;
  text-align: center;
  color: #dbe4ff;
  font-family: var(--font-dot);
  font-size: 20px;
  z-index: 45;
}
.narration-cue {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  animation: pause-bounce 0.7s ease-in-out infinite;
}
.tutorial-caption {
  position: absolute;
  left: 50%;
  bottom: 44px;
  z-index: 42;
  transform: translateX(-50%);
  min-width: 360px;
  text-align: center;
  font-family: var(--font-dot);
  font-size: 22px;
  line-height: 1.55;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 255, 230, 0.42), 1px 1px 0 rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
.tutorial-caption span {
  color: #eafffb;
}
.tutorial-caption b {
  font-weight: normal;
  color: #ffdeee;
  text-shadow: 0 0 12px rgba(255, 80, 150, 0.72), 1px 1px 0 rgba(0, 0, 0, 0.9);
}

/* ---------------- 左サイド感覚ゲージ ---------------- */
.command-panel {
  position: absolute;
  top: 108px;
  left: 18px;
  width: 286px;
  color: #79f7e8;
  font-family: var(--font-term);
  z-index: 36;
  transition: opacity 0.35s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.command-panel.busy { opacity: 0.48; pointer-events: none; }
.command-panel.closing { opacity: 0; transition: opacity 1.8s; pointer-events: none; }

.command-head {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #34e8d2;
}
.c-title { text-shadow: 0 0 8px rgba(0, 255, 230, 0.6); white-space: nowrap; }
.c-stat { margin-top: 4px; }
.c-stat b { color: #b8fff6; }
.c-prompt {
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: #9bfdf0;
  min-height: 20px;
}
.c-prompt b { color: #eafffb; }
.c-prompt .dim { opacity: 0.55; }
.command-columns {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.c-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 128px;
  flex: 0 0 128px;
}
.c-btns.sense-gauges {
  width: 252px;
  flex: 0 0 252px;
  gap: 10px;
  padding-top: 4px;
  touch-action: none;
}
.sense-row {
  --sense: 0;
  --sense-jitter: 0px;
  --sense-phase: 0;
  position: relative;
  width: 252px;
  height: 34px;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 0 7px rgba(0, 255, 230, 0.18));
}
.sense-row.dragging {
  cursor: grabbing;
}
.sense-row.locked {
  cursor: not-allowed;
  filter: drop-shadow(0 0 10px rgba(255, 80, 130, 0.45));
}
.sense-name {
  position: absolute;
  left: 0;
  top: 0;
  width: 72px;
  font-family: var(--font-dot);
  font-size: 12px;
  line-height: 1;
  color: rgba(198, 255, 248, 0.92);
  text-shadow: 0 0 8px rgba(0, 255, 230, 0.55);
  white-space: nowrap;
}
.sense-track {
  position: absolute;
  left: 76px;
  top: 15px;
  width: 152px;
  height: 16px;
  border: 1px solid rgba(25, 242, 220, 0.58);
  border-radius: 2px;
  background:
    linear-gradient(90deg, rgba(25, 242, 220, 0.14), transparent 18%, transparent 82%, rgba(255, 150, 210, 0.13)),
    rgba(0, 18, 20, 0.72);
  box-shadow: inset 0 0 9px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}
.sense-track::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(190, 255, 248, 0.12);
  pointer-events: none;
}
.sense-fill {
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: calc(var(--sense) * 1%);
  background: linear-gradient(90deg, #96fff6 0%, #34e8d2 54%, #ffe9f2 100%);
  box-shadow: 0 0 10px rgba(25, 242, 220, 0.48), inset 0 0 7px rgba(255, 255, 255, 0.42);
  transform: translateX(calc(var(--sense-jitter) * var(--sense-phase)));
}
.sense-grip {
  position: absolute;
  left: calc(var(--sense) * 1%);
  top: -5px;
  width: 9px;
  height: 26px;
  border: 1px solid rgba(232, 255, 252, 0.92);
  border-radius: 2px;
  background: rgba(4, 14, 18, 0.92);
  box-shadow: 0 0 8px rgba(25, 242, 220, 0.55), inset 0 0 5px rgba(255, 255, 255, 0.18);
  transform: translateX(-50%) translateX(calc(var(--sense-jitter) * var(--sense-phase)));
}
.sense-status {
  position: absolute;
  right: 0;
  top: 14px;
  width: 22px;
  font-family: var(--font-term);
  font-size: 9px;
  line-height: 1;
  color: rgba(255, 206, 226, 0.95);
  text-align: left;
  text-shadow: 0 0 7px rgba(255, 60, 130, 0.8);
}
.sense-row.heavy .sense-track {
  border-color: rgba(255, 238, 178, 0.68);
  box-shadow: inset 0 0 11px rgba(0, 0, 0, 0.82), 0 0 10px rgba(255, 220, 120, 0.15);
}
.sense-row.heavy .sense-fill {
  background: linear-gradient(90deg, #96fff6 0%, #ffe487 64%, #ff98c2 100%);
}
.sense-row.locked .sense-track {
  border-color: rgba(255, 125, 166, 0.82);
  animation: sense-lock 0.12s steps(2) infinite;
}
.sense-row.locked .sense-fill {
  background: linear-gradient(90deg, #fff4fb 0%, #ff7fae 45%, #ff2f7d 100%);
}
.sense-row.locked .sense-grip {
  border-color: rgba(255, 235, 244, 0.96);
  box-shadow: 0 0 11px rgba(255, 70, 138, 0.74);
}
.sense-row.tutorial-expanded .sense-track {
  box-shadow: inset 0 0 11px rgba(0, 0, 0, 0.82), 0 0 16px rgba(255, 80, 150, 0.42);
}
.sense-row.tutorial-spawn {
  animation: tutorial-gauge-spawn 0.34s cubic-bezier(0.2, 0.9, 0.2, 1.2) both;
}
@keyframes sense-lock {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-2px); }
}
@keyframes tutorial-gauge-spawn {
  0% {
    opacity: 0;
    transform: translateX(-18px) scaleX(0.72);
    filter: blur(2px) drop-shadow(0 0 0 rgba(0, 255, 230, 0));
  }
  60% {
    opacity: 1;
    transform: translateX(3px) scaleX(1.04);
    filter: blur(0) drop-shadow(0 0 12px rgba(0, 255, 230, 0.48));
  }
  100% {
    opacity: 1;
    transform: translateX(0) scaleX(1);
    filter: drop-shadow(0 0 7px rgba(0, 255, 230, 0.18));
  }
}
.c-sub-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 108px;
  flex: 0 0 108px;
}
.c-btn {
  font-family: var(--font-dot);
  width: 100%;
  min-height: 54px;
  font-size: 20px;
  color: #aefcf1;
  background: rgba(0, 40, 38, 0.45);
  border: 1px solid rgba(25, 242, 220, 0.5);
  border-radius: 3px;
  padding: 11px 4px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.c-btn.selected {
  color: #fff;
  background: rgba(0, 255, 230, 0.2);
  box-shadow: 0 0 12px rgba(0, 255, 230, 0.35), inset 0 0 10px rgba(0, 255, 230, 0.18);
}
.c-sub-btns .c-btn {
  min-height: 36px;
  font-size: 15px;
  padding: 6px 4px;
  justify-content: flex-start;
}
.c-sub-btns .c-btn .key {
  font-size: 10px;
  padding: 1px 4px;
}
.c-btn:hover {
  background: rgba(0, 255, 230, 0.18);
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 255, 230, 0.35), inset 0 0 8px rgba(0, 255, 230, 0.2);
}
.c-btn:active { transform: translateY(1px); }
.c-btn .key {
  font-family: var(--font-term);
  font-size: 12px;
  color: var(--cyan);
  border: 1px solid rgba(25, 242, 220, 0.6);
  border-radius: 2px;
  padding: 1px 6px;
}
.c-btn.back {
  min-height: 34px;
  padding: 5px;
  font-size: 13px;
  background: transparent;
  border-style: dashed;
  opacity: 0.8;
}

/* ---------------- 右上説明テキスト ---------------- */
.flavor-text {
  position: absolute;
  top: 30px;
  right: 18px;
  width: 420px;
  max-height: 184px;
  z-index: 35;
  font-family: var(--font-dot);
  font-size: 15px;
  line-height: 1.65;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  text-align: right;
  color: rgba(214, 255, 249, 0.92);
  text-shadow: 0 0 8px rgba(0, 255, 230, 0.45), 1px 1px 0 rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.c-line { white-space: normal; word-break: keep-all; overflow-wrap: normal; opacity: 0.54; margin-bottom: 6px; }
.c-line:last-child {
  opacity: 1;
  color: #f1fffb;
  text-shadow: 0 0 10px rgba(0, 255, 230, 0.58), 1px 1px 0 rgba(0, 0, 0, 0.9);
}

/* ---------------- 感応率ゲージ ---------------- */
.affection-gauge {
  --affection: 0;
  position: absolute;
  top: auto;
  right: 18px;
  bottom: 24px;
  height: 348px;
  width: 70px;
  z-index: 37;
  display: grid;
  grid-template-columns: 22px 30px;
  grid-template-rows: 1fr auto;
  column-gap: 7px;
  align-items: center;
  justify-content: end;
  color: #fff;
  font-family: var(--font-dot);
  pointer-events: none;
}
.affection-label {
  grid-row: 1 / 2;
  writing-mode: vertical-rl;
  justify-self: center;
  font-size: 18px;
  letter-spacing: 0.1em;
  color: #ffe1ee;
  text-shadow: 0 0 12px rgba(255, 80, 150, 0.72), 1px 1px 0 rgba(0, 0, 0, 0.8);
}
.affection-frame {
  position: relative;
  grid-row: 1 / 2;
  width: 28px;
  height: 304px;
  justify-self: center;
  border: 1px solid rgba(255, 210, 228, 0.82);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(42, 4, 24, 0.82);
  background: rgba(6, 3, 12, 0.72);
  overflow: hidden;
}
.affection-fill {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: calc(var(--affection) * 1%);
  max-height: none;
  border-radius: 2px;
  background: linear-gradient(180deg, #fff4fb 0%, #ff8dbc 22%, #ff3f8e 58%, #b90055 100%);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.38);
  transition: height 0.42s cubic-bezier(0.22, 0.9, 0.2, 1.18), box-shadow 0.28s;
}
.affection-value {
  grid-column: 1 / 3;
  grid-row: 2 / 3;
  justify-self: center;
  margin-top: 10px;
  min-width: 60px;
  text-align: center;
  font-family: var(--font-term);
  font-size: 14px;
  color: #ffe8f1;
  text-shadow: 0 0 10px rgba(255, 80, 150, 0.7);
}
.affection-gauge.limit-break .affection-frame {
  overflow: visible;
  border-color: rgba(255, 210, 228, 0.82);
  box-shadow: 0 0 0 1px rgba(42, 4, 24, 0.82);
  animation: gauge-shatter 0.16s steps(2) 8;
}
.affection-gauge.limit-break .affection-fill {
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.48), 0 0 14px rgba(255, 42, 120, 0.45);
}
.affection-heart {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 68;
  width: var(--heart-size);
  height: var(--heart-size);
  line-height: 1;
  font-family: "Meiryo", "Yu Gothic UI", sans-serif;
  font-size: var(--heart-size);
  font-weight: 900;
  color: #ff4f9a;
  text-align: center;
  -webkit-text-stroke: 1px rgba(255, 245, 250, 0.95);
  text-shadow: 0 0 4px #fff, 0 0 12px rgba(255, 48, 126, 0.98), 0 0 28px rgba(255, 150, 200, 0.86);
  filter: drop-shadow(0 0 10px rgba(255, 40, 120, 0.9));
  pointer-events: none;
  animation: affection-heart-flight 1.35s cubic-bezier(0.18, 0.85, 0.24, 1) forwards;
  animation-delay: var(--delay);
}
@keyframes affection-heart-flight {
  0% {
    opacity: 0;
    transform: translate(var(--sx), var(--sy)) scale(0.25) rotate(var(--r0));
  }
  12% {
    opacity: 1;
  }
  40% {
    opacity: 1;
    transform: translate(var(--sx), var(--sy)) scale(1) rotate(var(--r0));
  }
  72% {
    opacity: 1;
    transform: translate(var(--mx), var(--my)) scale(1.15) rotate(var(--r1));
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.38) rotate(var(--r2));
  }
}
@keyframes gauge-shatter {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-2px, 1px) rotate(-1deg); }
  50% { transform: translate(2px, -1px) rotate(1deg); }
  75% { transform: translate(1px, 2px) rotate(-0.6deg); }
}

/* ---------------- 侵入ログ（遷移演出） ---------------- */
.intrude {
  position: absolute;
  left: 18px;
  top: 44px;
  z-index: 46;
  font-family: var(--font-term);
  font-size: 14px;
  line-height: 1.75;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 255, 230, 0.7);
  pointer-events: none;
}

/* ---------------- 仮テキスト注記 ---------------- */
.temp-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 50;
  font-family: var(--font-dot);
  font-size: 12px;
  color: rgba(255, 235, 235, 0.85);
  background: rgba(10, 6, 16, 0.55);
  border: 1px solid rgba(255, 160, 160, 0.35);
  border-radius: 4px;
  padding: 3px 8px;
  pointer-events: none;
}

/* ---------------- ゲームから開始 ---------------- */
.start-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  font-family: var(--font-dot);
  font-size: 14px;
  color: #aefcf1;
  background: rgba(2, 16, 18, 0.78);
  border: 1px solid rgba(25, 242, 220, 0.55);
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
}
.start-btn:hover {
  background: rgba(0, 255, 230, 0.16);
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 255, 230, 0.3);
}

/* ---------------- デバッグ表示 ---------------- */
.debug {
  position: absolute;
  left: 10px;
  top: 42px;
  z-index: 60;
  font-family: var(--font-term);
  font-size: 12px;
  line-height: 1.6;
  color: #d9fef8;
  background: rgba(2, 8, 10, 0.82);
  border: 1px solid rgba(25, 242, 220, 0.4);
  border-radius: 4px;
  padding: 10px 12px;
  white-space: pre;
  pointer-events: none;
}

/* ---------------- FIN ---------------- */
.fin {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: radial-gradient(circle at 50% 42%, rgba(8, 10, 30, 0.25), rgba(4, 5, 16, 0.78));
  opacity: 0;
  transition: opacity 1.2s;
}
.fin.visible { opacity: 1; }
.fin-title {
  font-family: var(--font-dot);
  font-size: 74px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: #fff;
  text-shadow: 0 0 26px rgba(160, 200, 255, 0.8);
}
.fin-sub {
  font-family: var(--font-dot);
  font-size: 16px;
  color: #cfd9f5;
  margin-bottom: 18px;
}
.fin-btns { display: flex; gap: 18px; }
.fin-btn {
  font-family: var(--font-game);
  font-size: 18px;
  color: #fff;
  background: linear-gradient(180deg, rgba(24, 40, 82, 0.93), rgba(9, 15, 40, 0.95));
  border: 2px solid rgba(232, 238, 255, 0.88);
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(10, 18, 46, 0.85);
  padding: 10px 30px;
  cursor: pointer;
}
.fin-btn:hover {
  color: #bfe0ff;
  box-shadow: 0 0 0 2px rgba(120, 180, 255, 0.7), 0 0 18px rgba(120, 180, 255, 0.5);
}

/* ---------------- フラッシュ / ローディング ---------------- */
.flash {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: #eafcff;
  opacity: 0;
  pointer-events: none;
}
.flash.on { animation: flash-fade 0.5s ease-out; }
@keyframes flash-fade {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #04050d;
  color: #9fb4e8;
  font-family: var(--font-term);
  font-size: 16px;
  letter-spacing: 0.2em;
  animation: load-pulse 1.2s ease-in-out infinite;
}
@keyframes load-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
