:root{
  --bg:#0f1115;
  --panel:#161a22;
  --panel2:#1c2230;
  --text:#e8ecf1;
  --muted:#aab2c0;
  --accent:#ffb266;
  --accent2:#7fd0ff;
  --danger:#ff6b6b;
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; background:var(--bg); color:var(--text); font-family:system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif; font-size:19px; }

#app{
  height:100%;
  display:flex;
  gap:12px;
  padding:12px;
}

#stage{
  flex: 4;
  min-width: 700px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

#visual{
  flex: 1.7;
  position:relative;
  border-radius:16px;
  overflow:hidden;
  background:linear-gradient(135deg,#1a1f2b,#0f1320);
  box-shadow:0 12px 30px rgba(0,0,0,0.35);
}

#bg{
  position:absolute;
  inset:0;
  background-size:cover;
  background-position:center;
  filter:saturate(1.0) contrast(1.05);
}

#characters{
  position:absolute;
  inset:0;
  pointer-events:none;
}

.ch{
  position:absolute;
  bottom:0;
  width:36%;
  height:calc(100% - 50px);
  background-size:contain;
  background-repeat:no-repeat;
  background-position:bottom center;
  filter:drop-shadow(0 12px 22px rgba(0,0,0,0.45));
  opacity:1;
  transition: opacity 1.5s ease;
}

.ch.left{ left:8%; }
.ch.right{ right:8%; }
.ch.center{ left:32%; width:36%; }

/* 商店街シーンの女の子を大きく下にずらして、背景と重ねて表示 */
#characters[data-bg="shopping_street"] .ch.girl{
  transform-origin:center bottom;
  /* 下方向へ500pxずらして、約3倍に拡大 */
  transform: translateY(700px) scale(3);
  z-index:4;
}

/* 五反野（商店街）シーンの女の子は200%拡大して200px下げる */
#characters[data-scene="S_D2_GOTANNO_SHOP"] .ch.girl{
  transform-origin:center bottom;
  transform: translateY(350px) scale(2);
  z-index:4;
}

/* 雑貨店の店員は200px下げ、150%拡大 */
#characters[data-scene="S_ZAKKAYA"] .ch-zakkaya_clerk{
  transform-origin:center bottom;
  transform: translateY(200px) scale(1.5);
  z-index:4;
}

/* 河川敷シーンの女の子を150%に拡大し、300px下げる */
#characters[data-bg="river_day"] .ch.girl{
  transform-origin:center bottom;
  transform: translateY(300px) scale(1.5);
  z-index:4;
}

/* 堤防ベンチの女の子を150px下げる */
#characters[data-bg="river_bench"] .ch.girl{
  transform-origin:center bottom;
  transform: translateY(150px) scale(1.5);
  z-index:4;
}

/* オフィス街の先輩を200%に拡大し、下に配置 */
#characters[data-bg="north_office"] .ch{
  transform-origin:center bottom;
  transform: translateY(260px) scale(2);
  z-index:4;
}

/* 徘徊イベントの高齢女性は少し下げる */
#characters[data-scene="S_D4_DAY_ELDER"] .ch-elder,
#characters[data-scene="S_D4_DAY_ELDER_GIRL"] .ch-elder{
  transform-origin:center bottom;
  transform: translateY(100px);
  z-index:4;
}

/* 徘徊老人シーンの女の子を150%拡大し、150px下げる */
#characters[data-scene="S_D4_DAY_ELDER_GIRL"] .ch.girl{
  transform-origin:center bottom;
  transform: translateY(275px) scale(1.5);
  z-index:4;
}

/* 通行止めシーンの女の子を100px下げる */
#characters[data-scene="S_D4_DAY_001"] .ch.girl,
#characters[data-scene="S_D4_DAY_001_OPEN"] .ch.girl{
  transform-origin:center bottom;
  transform: translateY(100px) scale(1.5);
  z-index:4;
}

/* 舎人公園の女の子を150px下げる */
#characters[data-scene="S_TONERI_PARK_GIRL"] .ch.girl{
  transform-origin:center bottom;
  transform: translateY(150px) scale(1.5);
  z-index:4;
}

/* 舎人公園の犬と飼い主を少し下げる */
#characters[data-scene="S_TONERI_PARK_DOG"] .ch-dogandlady,
#characters[data-scene="S_TONERI_PARK_DOG_GIRL"] .ch-dogandlady{
  transform-origin:center bottom;
  transform: translateY(80px);
  z-index:4;
}

/* 叔父さんの表示位置を少し下げる */
#characters[data-scene="S_UNCLE_HOME"] .ch-uncle{
  transform-origin:center bottom;
  transform: translateY(50px);
  z-index:4;
}

/* 自転車泥棒シーンで姉（女性）は等倍で100px下げる */
#characters[data-scene="S_D5_DAY_SHOP_BIKE_GIRL"] .ch.girl{
  transform-origin:center bottom;
  transform: translateY(100px) scale(1);
  z-index:4;
}

/* 自転車泥棒シーンの弟を150%拡大し、100px下げる */
#characters[data-scene="S_D5_DAY_SHOP_BIKE"] .ch-brother{
  transform-origin:center bottom;
  transform: translateY(100px) scale(1.5);
  z-index:4;
}

/* 女の子のフェードイン */
.ch.girl{
  opacity:0;
  transform-origin:center bottom;
  transform: translateY(150px) scale(1.5);
  transition:opacity 1.5s ease;
}
.ch.girl.show{
  opacity:1;
}

#message{
  flex: 1.3;
  border-radius:16px;
  background:rgba(28,34,48,0.72);
  backdrop-filter: blur(6px);
  box-shadow:0 12px 30px rgba(0,0,0,0.35);
  padding:10px 12px 8px;
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height:220px;
}

#nameRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

#speaker{
  font-weight:700;
  letter-spacing:0.04em;
  color:var(--accent);
}

#hint{
  display:flex;
  gap:10px;
  color:var(--muted);
  font-size:14px;
  white-space:nowrap;
  opacity:0.9;
}
#hint span{
  padding:4px 8px;
  border-radius:999px;
  background:rgba(0,0,0,0.22);
}

#text{
  flex:1;
  font-size:19px;
  line-height:1.95;
  white-space:pre-wrap;
  overflow:auto;
  padding:6px 2px;
  position:relative;
  z-index:1;
  user-select:none;
}
#text.narration{
  font-size:21px;
  user-select: none;
}

#controls{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:12px;
  flex-wrap:wrap;
  padding:8px 0 0 0;
  position:relative;
  z-index:5;
  pointer-events:auto;
}
.hidden{ display:none !important; }

button, select{
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(0,0,0,0.18);
  color:var(--text);
  border-radius:10px;
  padding:10px 12px;
  cursor:pointer;
  transition:transform 0.03s ease, background 0.2s ease;
  font-size:16px;
}
button:hover, select:hover{ background:rgba(255,255,255,0.06); }
button:active{ transform:translateY(1px); }
button.primary{ border-color:rgba(255,178,102,0.55); }

.ctlLabel{
  color:var(--muted);
  font-size:15px;
  margin-left:4px;
}

#choices{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding-top:2px;
  position:relative;
  z-index:6; /* テキストより前面に配置して読みやすくする */
}
.choiceWrap{
  display:flex;
  flex-direction:column;
  gap:6px;
  animation: choiceSlide 0.35s ease;
}
@keyframes choiceSlide{
  from{ transform: translateY(20px); opacity:0; }
  to{ transform: translateY(0); opacity:1; }
}

.choiceBtn{
  text-align:left;
  width:100%;
  padding:8px 10px;
  border-radius:12px;
  background:rgba(255,178,102,0.18);
  border:1px solid rgba(255,178,102,0.35);
  font-size:17px;
}
.choiceBtn:hover{ background:rgba(255,255,255,0.06); }
.choiceBtn:disabled{
  opacity:0.38;
  cursor:not-allowed;
}

#btnNext{
  font-size:21px;
  padding:16px 30px;
  border-radius:18px;
  background:linear-gradient(90deg, #ff9d2f, #ff7a00);
  border-color:#ffb266;
  color:#0b0f18;
  font-weight:800;
}
#btnNext.btn-ready{
  animation: nextBlink 1.2s ease-in-out infinite alternate;
}
#btnNext:disabled{
  background:#555;
  border-color:#777;
  color:#b5b5b5;
  box-shadow:none;
  cursor:not-allowed;
  animation:none;
  opacity:0.8;
}

#btnBack{
  display:none;
  font-size:16px;
  padding:10px 14px;
  border-radius:12px;
  border-color:rgba(255,255,255,0.28);
  color:var(--muted);
}
#btnBack:disabled{
  opacity:0.5;
  cursor:not-allowed;
}

@keyframes nextBlink{
  from{ box-shadow:0 0 0 rgba(255,178,102,0.0), 0 0 0 rgba(255,122,0,0.0); transform:translateY(0); }
  to{ box-shadow:0 0 18px rgba(255,178,102,0.9), 0 0 24px rgba(255,122,0,0.65); transform:translateY(-1px); }
}

#status{
  flex: 1;
  min-width:260px;
  border-radius:16px;
  background:var(--panel);
  box-shadow:0 12px 30px rgba(0,0,0,0.35);
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.stTitle{
  font-weight:800;
  letter-spacing:0.06em;
  font-size:14px;
  color:var(--accent2);
}

#sleepOverlay{
  position:fixed;
  inset:0;
  background:#000;
  opacity:0;
  pointer-events:none;
  z-index:10000;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:24px;
  padding:40px 24px;
  text-align:center;
}
#sleepOverlay.active{
  opacity:1;
}
#sleepDayLabel{
  color:#f5f7ff;
  font-size:36px;
  letter-spacing:0.18em;
  opacity:0;
  transition:opacity 1.2s ease;
}
#sleepComment{
  color:#e8ecff;
  font-size:20px;
  letter-spacing:0.02em;
  line-height:1.7;
  max-width:820px;
  opacity:0;
  transition:opacity 0.8s ease;
  white-space:pre-wrap;
}
#sleepOverlay.show-comment #sleepComment{
  opacity:1;
}
#sleepOverlay.show-label #sleepDayLabel{
  opacity:1;
}

.stRow{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border-radius:12px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
}
.stRow span:first-child{ color:var(--muted); }
.stLabelBtn{
  appearance:none;
  border:none;
  background:none;
  color:var(--muted);
  padding:0;
  font:inherit;
  cursor:pointer;
}
.stLabelBtn:hover{
  color:var(--text);
}

#stBond.st-bond-up{
  animation: bondCountUpGlow 0.85s ease-out;
}

@keyframes bondCountUpGlow{
  0%{
    color:#fff4cf;
    text-shadow:0 0 0 rgba(255,214,117,0);
    transform:scale(1);
  }
  35%{
    color:#ffe082;
    text-shadow:0 0 14px rgba(255,214,117,0.95), 0 0 26px rgba(255,178,102,0.55);
    transform:scale(1.16);
  }
  100%{
    color:var(--text);
    text-shadow:0 0 0 rgba(255,214,117,0);
    transform:scale(1);
  }
}

.stHr{
  height:1px;
  background:rgba(255,255,255,0.10);
  margin:6px 0;
}

.stFlags{
  font-size:14px;
  color:var(--muted);
  white-space:pre-wrap;
  max-height:220px;
  overflow:auto;
  padding:8px 10px;
  border-radius:12px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
}

#sideControls{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:8px;
}
.miniRow{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}
.miniBtn{
  font-size:13px;
  padding:6px 8px;
  border-radius:8px;
  background:rgba(255,255,255,0.05);
}
.miniSelect{
  font-size:13px;
  padding:6px 8px;
  border-radius:8px;
}
.miniLabel{
  font-size:13px;
  color:var(--muted);
}

/* Diary modal */
#diaryModal,
#inventoryModal,
#logModal,
#connectionsModal{
  position:fixed;
  left:50%;
  top:12%;
  transform:translateX(-50%);
  max-width:520px;
  width:90%;
  max-height:70vh;
  overflow:auto;
  z-index:990;
  display:none;
  background:rgba(15,17,21,0.95);
  border:1px solid #2a2f3a;
  border-radius:12px;
  padding:12px 14px;
  box-shadow:0 12px 30px rgba(0,0,0,0.45);
  color:#e8ecf1;
}
#diaryModal .diaryHeader,
#inventoryModal .diaryHeader,
#logModal .diaryHeader,
#connectionsModal .diaryHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:8px;
  font-weight:700;
  color:#f5c88f;
}
#diaryModal .diaryEntry,
#inventoryModal .diaryEntry,
#logModal .diaryEntry,
#connectionsModal .diaryEntry{
  border-bottom:1px solid #2f343f;
  padding:6px 0 10px;
}
#diaryModal .diaryMeta,
#inventoryModal .diaryMeta,
#logModal .diaryMeta,
#connectionsModal .diaryMeta{
  font-size:12px;
  color:#9aa4b5;
  margin-bottom:4px;
}
#diaryModal .diaryText,
#inventoryModal .diaryText,
#logModal .diaryText,
#connectionsModal .diaryText{
  line-height:1.5;
  white-space:pre-wrap;
}
#diaryModal .diaryEmpty,
#inventoryModal .diaryEmpty,
#logModal .diaryEmpty,
#connectionsModal .diaryEmpty{
  color:#9aa4b5;
  padding:10px 0;
}


