
:root{
  --bg:#07090d;
  --text:#edf3f7;
  --muted:#8998a8;
  --line:#2b3744;
  --paper:#dfe7ee;
  --dark:#090c11;
}
*{box-sizing:border-box}
html,body{margin:0;width:100%;height:100%;background:#000;color:var(--text);font-family:"Yu Gothic","Hiragino Kaku Gothic ProN","Meiryo",sans-serif}
body{overflow:hidden}
button{font:inherit}

.screen{display:none;width:100vw;height:100vh;position:relative}
.screen.active{display:block}

#titleScreen{
  background:
    radial-gradient(circle at 50% 35%,rgba(122,142,164,.13),transparent 34%),
    linear-gradient(180deg,#05070a,#0b0f15 55%,#040506);
}
.scanlines{
  position:absolute;inset:0;pointer-events:none;opacity:.12;
  background:repeating-linear-gradient(0deg,rgba(255,255,255,.03) 0,rgba(255,255,255,.03) 1px,transparent 1px,transparent 4px)
}
.title-wrap{position:absolute;left:8vw;bottom:12vh;max-width:1000px}
.eyebrow{font-size:12px;letter-spacing:.22em;color:#8190a0;margin-bottom:20px}
h1{font-size:clamp(58px,9vw,142px);line-height:.86;margin:0;font-weight:800;letter-spacing:-.055em}
h1 span{font-weight:300;color:#aab6c1}
.tagline{font-size:clamp(18px,2vw,28px);margin:30px 0 38px;color:#dce4ea;letter-spacing:.08em}
.title-actions{display:flex;gap:12px;flex-wrap:wrap}
button{
  border:1px solid #44515f;background:rgba(13,17,23,.88);color:#dfe7ee;
  padding:12px 18px;cursor:pointer;transition:.16s ease
}
button:hover:not(:disabled){background:#e6edf2;color:#080a0d;border-color:#e6edf2}
button:disabled{opacity:.35;cursor:not-allowed}
button.primary{background:#dfe7ee;color:#07090d;border-color:#dfe7ee;font-weight:700}
.version{margin-top:26px;font-size:11px;color:#64717f;letter-spacing:.18em}

.topbar{
  height:54px;background:#080b10;border-bottom:1px solid #1e2833;display:flex;
  align-items:center;justify-content:space-between;padding:0 18px;position:absolute;top:0;left:0;right:0;z-index:20
}
.system-id{font-family:ui-monospace,Consolas,monospace;color:#9aa8b6;font-size:12px;letter-spacing:.08em}
.dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#c3ccd5;margin-right:8px;box-shadow:0 0 10px rgba(220,230,240,.35)}
.top-actions{display:flex;gap:7px}
button.small{font-size:10px;padding:7px 9px;color:#aeb9c4}

#stage{position:absolute;top:54px;left:0;right:0;bottom:0;background:#090b0f;overflow:hidden}
#bgLayer{position:absolute;inset:0;transition:background .7s,filter .7s}
.bg-black{background:#030405}
.bg-street{
  background:
    linear-gradient(180deg,rgba(31,38,47,.08),rgba(10,12,16,.62)),
    radial-gradient(circle at 68% 35%,rgba(225,194,137,.18),transparent 17%),
    linear-gradient(120deg,#18202a 0 30%,#11171e 30% 52%,#20242b 52% 60%,#10141a 60%)
}
.bg-rain{
  background:
    repeating-linear-gradient(100deg,rgba(210,225,235,.028) 0,rgba(210,225,235,.028) 1px,transparent 1px,transparent 13px),
    radial-gradient(circle at 30% 25%,rgba(134,151,171,.11),transparent 30%),
    linear-gradient(150deg,#111822,#0b1017 55%,#06080c)
}
.bg-night{
  background:
    radial-gradient(circle at 60% 28%,rgba(116,130,151,.08),transparent 22%),
    linear-gradient(160deg,#0b0f15,#111720 45%,#06080d)
}
.bg-room{
  background:
    radial-gradient(circle at 72% 32%,rgba(233,185,112,.11),transparent 18%),
    linear-gradient(135deg,#17171a 0 26%,#0c0f14 26% 66%,#151319 66%)
}
.bg-riverside{
  background:
    linear-gradient(180deg,rgba(80,102,125,.13),transparent 35%),
    linear-gradient(170deg,#111a25 0 48%,#0a1119 48% 62%,#10151b 62%)
}
.bg-white{
  background:linear-gradient(180deg,#dfe5ea,#cfd7de);
  filter:brightness(.9)
}
#pulseLayer{position:absolute;inset:0;pointer-events:none;opacity:0}
.pulse{animation:pulseFlash .65s ease}
@keyframes pulseFlash{0%{opacity:0}35%{opacity:.18;background:#fff}100%{opacity:0}}

.vignette{position:absolute;inset:0;pointer-events:none;box-shadow:inset 0 0 190px rgba(0,0,0,.84)}
.textbox{
  position:absolute;left:5vw;right:5vw;bottom:5vh;min-height:190px;
  background:linear-gradient(180deg,rgba(9,12,16,.92),rgba(7,10,13,.97));
  border:1px solid #2b3643;border-left:3px solid #bac4ce;
  padding:28px 34px 34px;z-index:10;box-shadow:0 20px 80px rgba(0,0,0,.45)
}
.speaker{
  position:absolute;top:-18px;left:24px;background:#dfe7ee;color:#0b0d10;
  min-width:120px;padding:7px 14px;font-weight:700;font-size:14px;letter-spacing:.04em
}
.text{font-size:clamp(18px,1.55vw,24px);line-height:1.9;letter-spacing:.04em;white-space:pre-wrap;min-height:92px}
.advance-hint{position:absolute;right:20px;bottom:12px;font-size:10px;color:#5f6d7c;letter-spacing:.14em}
.system-overlay{
  position:absolute;left:7vw;top:8vh;max-width:min(760px,80vw);z-index:12;
  bottom:calc(5vh + 230px + 18px);
  font-family:ui-monospace,Consolas,monospace;color:#bac6d2;
  padding:23px 27px;border-left:2px solid #5b6978;background:rgba(7,10,14,.72);
  letter-spacing:.04em;line-height:1.82;white-space:pre-wrap;
  overflow:auto
}
.system-overlay.alert{border-left-color:#d9e0e6;color:#eef2f5;background:rgba(11,8,10,.78)}
.hidden{display:none!important}
.choice-box{
  position:absolute;left:50%;top:40%;transform:translate(-50%,-50%);
  width:min(720px,82vw);z-index:30;display:flex;flex-direction:column;gap:12px
}
.choice-btn{
  text-align:left;padding:16px 20px;font-size:17px;background:rgba(11,15,21,.96);
  border:1px solid #384656
}
.choice-btn:hover{padding-left:28px}
.panel{position:fixed;inset:0;background:rgba(0,0,0,.88);z-index:100;padding:5vh 8vw}
.panel-inner{height:90vh;background:#0b0f14;border:1px solid #27323e;padding:24px;overflow:hidden}
.panel-head{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #27323e;padding-bottom:12px}
.panel-head h2{font-family:ui-monospace,Consolas,monospace;letter-spacing:.16em;font-size:15px;margin:0}
.log-content{height:calc(100% - 58px);overflow:auto;padding:18px 8px 40px}
.log-entry{border-bottom:1px solid #171f29;padding:12px 4px;color:#b8c3cd;line-height:1.7}
.log-entry strong{color:#eef3f7;margin-right:10px}
.toast{
  position:fixed;left:50%;bottom:28px;transform:translateX(-50%);z-index:200;
  background:#e6edf2;color:#0a0c0f;padding:10px 18px;font-size:12px;font-weight:700;letter-spacing:.06em
}

@media(max-width:760px){
  html,body{height:100%;min-height:100%;overscroll-behavior:none}
  body{overflow:hidden}

  /* --- title screen: mobile-first layout --- */
  #titleScreen.active{
    display:flex;
    align-items:center;
    justify-content:center;
    padding:
      max(22px, env(safe-area-inset-top))
      20px
      max(26px, env(safe-area-inset-bottom));
  }
  #titleScreen{
    background:
      radial-gradient(circle at 50% 32%,rgba(122,142,164,.14),transparent 35%),
      linear-gradient(180deg,#05070a,#0b0f15 54%,#040506);
  }
  .title-wrap{
    position:relative;
    left:auto;right:auto;bottom:auto;
    width:100%;max-width:520px;
  }
  .eyebrow{
    font-size:9px;
    line-height:1.65;
    letter-spacing:.18em;
    margin-bottom:16px;
    max-width:320px;
  }
  h1{
    font-size:clamp(42px,13vw,58px);
    line-height:.95;
    letter-spacing:-.05em;
    white-space:nowrap;
  }
  h1 span{font-size:.72em;letter-spacing:-.035em}
  .tagline{
    font-size:15px;
    line-height:1.75;
    letter-spacing:.06em;
    margin:24px 0 28px;
    white-space:nowrap;
  }
  .title-actions{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
    width:100%;
  }
  .title-actions button{
    width:100%;
    min-height:60px;
    padding:11px 8px;
    font-size:13px;
    line-height:1.35;
    letter-spacing:.03em;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  .version{
    margin-top:22px;
    font-size:9px;
    line-height:1.5;
    letter-spacing:.13em;
  }

  /* --- in-game top navigation --- */
  .topbar{
    height:82px;
    flex-direction:column;
    align-items:stretch;
    justify-content:center;
    gap:7px;
    padding:7px 10px;
    padding-top:max(7px, env(safe-area-inset-top));
  }
  .system-id{
    width:100%;
    font-size:9px;
    line-height:1.2;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .dot{width:6px;height:6px;margin-right:6px}
  .top-actions{
    display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:4px;
    width:100%;
  }
  button.small{
    min-width:0;
    padding:6px 2px;
    font-size:8px;
    line-height:1.15;
    white-space:nowrap;
  }
  #stage{top:82px}

  /* --- novel UI --- */
  .textbox{
    left:4vw;right:4vw;
    bottom:max(14px, env(safe-area-inset-bottom));
    height:clamp(260px,31dvh,390px);
    min-height:260px;
    max-height:40dvh;
    overflow:auto;
    padding:48px 18px 30px;
  }
  .speaker{
    top:0;
    left:0;
    min-width:96px;
    max-width:70%;
    padding:7px 14px;
    font-size:12px;
    line-height:1.2;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    border-right:1px solid #2b3643;
    border-bottom:1px solid #2b3643;
  }
  .text{
    min-height:78px;
    font-size:16px;
    line-height:1.8;
    letter-spacing:.025em;
  }
  .advance-hint{right:14px;bottom:10px;font-size:8px}
  .system-overlay{
    left:4vw;right:4vw;top:18px;
    max-width:none;
    max-height:39vh;
    overflow:auto;
    padding:16px 17px;
    font-size:12px;
    line-height:1.65;
  }
  .choice-box{
    width:90vw;
    top:32%;
    gap:9px;
  }
  .choice-btn{
    padding:13px 15px;
    font-size:14px;
  }
  .choice-btn:hover{padding-left:15px}

  /* --- panels --- */
  .panel{
    padding:
      max(18px, env(safe-area-inset-top))
      4vw
      max(18px, env(safe-area-inset-bottom));
  }
  .panel-inner{height:100%;padding:16px}
  .panel-head h2{font-size:12px}
  .log-content{font-size:13px}
  .toast{
    bottom:max(18px, env(safe-area-inset-bottom));
    max-width:88vw;
    text-align:center;
  }
}

@media(max-width:390px){
  #titleScreen.active{padding-left:16px;padding-right:16px}
  h1{font-size:43px}
  h1 span{font-size:.68em}
  .tagline{font-size:14px;letter-spacing:.035em}
  .title-actions button{min-height:58px;font-size:12px}
  .version{font-size:8px}
}



/* v0.3.3 bilingual system subtitles */
.system-overlay .jp-sub,
.text .jp-sub {
  display:block;
  margin-top:10px;
  padding-top:9px;
  border-top:1px solid rgba(180,196,210,.18);
  color:#8fa0b1;
  font-family:"Yu Gothic","Hiragino Kaku Gothic ProN","Meiryo",sans-serif;
  font-size:.88em;
  line-height:1.7;
  letter-spacing:.02em;
}


/* v0.5.0 mobile title grid: 6 buttons = 2 columns x 3 rows */
@media (max-width: 760px){
  .title-actions{
    display:grid !important;
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    grid-auto-rows:minmax(72px,auto) !important;
    gap:10px !important;
    width:100% !important;
  }

  .title-actions button,
  #newBtn,
  #continueBtn,
  #extraBtn,
  #extra2Btn,
  #extra3Btn,
  #extra4Btn{
    grid-column:auto !important;
    width:100% !important;
    min-width:0 !important;
    min-height:72px !important;
    margin:0 !important;
    padding:10px 8px !important;
    font-size:clamp(11px,3.2vw,14px) !important;
    line-height:1.25 !important;
    text-align:center !important;
    white-space:normal !important;
    overflow-wrap:anywhere !important;
  }
}


/* v0.5.4: seventh title button gets the final full-width row on mobile */
@media (max-width: 760px){
  #extra5Btn{
    grid-column:1 / -1 !important;
    width:100% !important;
  }
}


/* v0.5.5 PC fix: record/system panel must stay visible above textbox */
@media (min-width: 761px){
  .system-overlay{
    bottom:calc(5vh + 230px + 18px) !important;
    overflow:auto !important;
    z-index:12 !important;
  }
  .textbox{
    z-index:10;
  }
}


/* v0.5.7 17:32 ARCHIVE */
.archive-title-btn{
  border-color:#66788a;
  background:linear-gradient(180deg,rgba(18,25,33,.96),rgba(8,12,17,.96));
  letter-spacing:.08em;
}
.archive-screen{
  overflow:auto;
  background:
    radial-gradient(circle at 74% 10%,rgba(111,134,158,.12),transparent 32%),
    linear-gradient(180deg,#05070a,#090d12 42%,#030405);
}
.archive-shell{
  position:relative;
  z-index:2;
  width:min(1440px,92vw);
  margin:0 auto;
  padding:7vh 0 9vh;
}
.archive-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:28px;
  padding-bottom:24px;
  margin-bottom:28px;
  border-bottom:1px solid #26313d;
}
.archive-eyebrow{
  font-family:ui-monospace,Consolas,monospace;
  color:#748597;
  font-size:10px;
  letter-spacing:.18em;
  margin-bottom:10px;
}
.archive-head h2{
  margin:0;
  font-family:ui-monospace,Consolas,monospace;
  font-size:clamp(34px,5vw,74px);
  line-height:.95;
  letter-spacing:-.035em;
}
.archive-head p{
  margin:16px 0 0;
  color:#8d9baa;
  font-size:13px;
  letter-spacing:.06em;
}
.archive-head-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex:0 0 auto;
}
.archive-count{
  min-width:96px;
  padding:12px 14px;
  border:1px solid #2b3744;
  color:#c9d3dc;
  background:rgba(7,10,14,.74);
  font-family:ui-monospace,Consolas,monospace;
  font-size:12px;
  text-align:center;
  letter-spacing:.12em;
}
.archive-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:16px;
}
.archive-card{
  display:flex;
  min-width:0;
  flex-direction:column;
  padding:0;
  text-align:left;
  overflow:hidden;
  border:1px solid #25303b;
  background:#080b0f;
  color:#dfe7ee;
}
.archive-card:hover{
  background:#0b1016 !important;
  color:#f1f5f8 !important;
  border-color:#637284 !important;
  transform:translateY(-2px);
}
.archive-card.locked:hover{
  transform:none;
  border-color:#34404c !important;
  background:#080b0f !important;
  color:#93a0ac !important;
}
.archive-thumb{
  position:relative;
  display:block;
  width:100%;
  aspect-ratio:4 / 3;
  overflow:hidden;
  background:#040608;
  border-bottom:1px solid #202934;
}
.archive-thumb img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
  filter:saturate(.84) contrast(1.04);
  transition:transform .35s ease,filter .35s ease;
}
.archive-card:hover .archive-thumb img{
  transform:scale(1.025);
  filter:saturate(1) contrast(1.04);
}
.archive-thumb-locked{
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  background:
    repeating-linear-gradient(135deg,rgba(255,255,255,.018) 0,rgba(255,255,255,.018) 1px,transparent 1px,transparent 12px),
    radial-gradient(circle at 50% 40%,rgba(115,133,151,.08),transparent 36%),
    #05070a;
}
.archive-lock-mark{
  color:#5f6d7b;
  font-family:ui-monospace,Consolas,monospace;
  font-size:11px;
  letter-spacing:.22em;
}
.archive-lock-no{
  margin-top:8px;
  color:#28323c;
  font-family:ui-monospace,Consolas,monospace;
  font-size:42px;
  font-weight:700;
  letter-spacing:-.05em;
}
.archive-card-copy{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height:116px;
  padding:14px 15px 16px;
}
.archive-card-no{
  color:#617181;
  font-family:ui-monospace,Consolas,monospace;
  font-size:9px;
  letter-spacing:.14em;
}
.archive-card-copy strong{
  color:#e7edf2;
  font-family:ui-monospace,Consolas,monospace;
  font-size:12px;
  line-height:1.35;
  letter-spacing:.06em;
}
.archive-card-copy > span:last-child{
  color:#7f8d9a;
  font-size:11px;
  line-height:1.65;
}

.still-viewer{
  position:fixed;
  inset:0;
  z-index:300;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:5vh 7vw;
  background:rgba(0,0,0,.94);
  backdrop-filter:blur(8px);
}
.still-viewer-figure{
  width:min(1260px,86vw);
  height:min(88vh,900px);
  margin:0;
  display:flex;
  flex-direction:column;
  min-height:0;
}
.still-viewer-figure img{
  flex:1 1 auto;
  width:100%;
  min-height:0;
  object-fit:contain;
  background:#020304;
  border:1px solid #303c48;
  box-shadow:0 30px 100px rgba(0,0,0,.6);
}
.still-viewer-figure figcaption{
  flex:0 0 auto;
  padding:14px 4px 0;
}
.still-viewer-no{
  color:#637486;
  font-family:ui-monospace,Consolas,monospace;
  font-size:9px;
  letter-spacing:.18em;
}
.still-viewer-title{
  margin-top:5px;
  color:#edf3f7;
  font-family:ui-monospace,Consolas,monospace;
  font-size:16px;
  letter-spacing:.08em;
}
.still-viewer-meta{
  margin-top:5px;
  color:#8b99a6;
  font-size:12px;
  line-height:1.6;
}
.still-viewer-close{
  position:fixed;
  top:22px;
  right:24px;
  z-index:302;
  font-size:10px;
  letter-spacing:.12em;
}
.still-nav{
  position:fixed;
  top:50%;
  z-index:302;
  width:48px;
  height:74px;
  padding:0;
  transform:translateY(-50%);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:34px;
  font-family:serif;
  color:#9eacb9;
  background:rgba(5,8,11,.72);
}
.still-prev{left:18px}
.still-next{right:18px}

@media(max-width:1100px){
  .archive-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}

@media(max-width:760px){
  #archiveBtn{
    grid-column:1 / -1 !important;
    width:100% !important;
  }
  .archive-shell{
    width:92vw;
    padding:
      max(28px, env(safe-area-inset-top))
      0
      max(36px, env(safe-area-inset-bottom));
  }
  .archive-head{
    align-items:stretch;
    flex-direction:column;
    gap:18px;
    margin-bottom:18px;
    padding-bottom:18px;
  }
  .archive-head h2{font-size:38px;white-space:nowrap}
  .archive-head p{font-size:12px;line-height:1.7}
  .archive-head-actions{
    width:100%;
    justify-content:space-between;
  }
  .archive-count{min-width:86px;padding:10px 11px}
  .archive-head-actions button{padding:10px 14px}
  .archive-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
  }
  .archive-card-copy{
    min-height:106px;
    padding:11px 10px 12px;
  }
  .archive-card-copy strong{font-size:10px}
  .archive-card-copy > span:last-child{
    font-size:9px;
    line-height:1.55;
  }
  .archive-lock-no{font-size:34px}

  .still-viewer{
    padding:
      max(58px, env(safe-area-inset-top))
      12px
      max(24px, env(safe-area-inset-bottom));
  }
  .still-viewer-figure{
    width:100%;
    height:100%;
  }
  .still-viewer-figure img{
    border-left:0;
    border-right:0;
  }
  .still-viewer-close{
    top:max(12px, env(safe-area-inset-top));
    right:12px;
  }
  .still-nav{
    top:auto;
    bottom:max(18px, env(safe-area-inset-bottom));
    width:42px;
    height:42px;
    transform:none;
    border-radius:50%;
    font-size:25px;
  }
  .still-prev{left:12px}
  .still-next{right:12px}
  .still-viewer-figure figcaption{
    padding:10px 48px 0;
    min-height:72px;
  }
  .still-viewer-title{font-size:13px}
  .still-viewer-meta{font-size:10px}
}

@media(max-width:430px){
  .archive-grid{grid-template-columns:1fr 1fr}
  .archive-head h2{font-size:34px}
  .archive-eyebrow{font-size:8px}
}

