/* USELESS JOURNEY — interface styling (dark / thriller) */
@font-face { font-family: 'Orbitron'; src: url('/fonts/orbitron.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Oxanium'; src: url('/fonts/oxanium.woff2') format('woff2'); font-weight: 300 800; font-display: swap; }

:root {
  --bg: #030107;
  --panel: #07050e;
  --panel2: #0b0716;
  --line: #2a1840;
  --line-hot: #57203a;
  --cyan: #46c8f0;
  --cyan-hi: #9beaff;
  --green: #35ff9e;
  --gold: #ffd34d;
  --red: #ff2444;
  --blood: #c4112e;
  --magenta: #ff9efb;
  --text: #cdd9e4;
  --font-ui: 'Oxanium', 'Avenir Next', sans-serif;
  --font-display: 'Orbitron', 'Oxanium', sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  touch-action: manipulation;
}

.screen { position: fixed; inset: 0; display: none; }
.screen.open { display: flex; flex-direction: column; }

/* scanlines + blood vignette + film grain */
#game::after, #title::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 90;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.14) 0 1px, transparent 1px 3px),
    radial-gradient(135% 105% at 50% 42%, transparent 52%, rgba(20, 0, 6, .55) 100%);
}
#game::before, #title::before {
  content: ''; position: absolute; inset: -50%; pointer-events: none; z-index: 91; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain .5s steps(4) infinite;
}
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-2%,3%)} 50%{transform:translate(3%,-2%)} 75%{transform:translate(-3%,-3%)} 100%{transform:translate(2%,2%)} }

/* ============ buttons ============ */
.btn {
  background: linear-gradient(180deg, #150c22, #080411);
  border: 1px solid var(--line);
  color: var(--cyan-hi);
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 3px;
  transition: border-color .15s, box-shadow .15s, transform .05s;
  user-select: none;
}
.btn:hover:not(:disabled) { border-color: var(--blood); box-shadow: 0 0 14px rgba(196,17,46,.4), inset 0 0 12px rgba(196,17,46,.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary { border-color: var(--blood); color: #fff; box-shadow: 0 0 12px rgba(196,17,46,.35); }
.btn.big { font-size: 1.1rem; padding: 14px 22px; }
.btn.small { padding: 5px 10px; font-size: .8rem; }
.btn.icon { width: 42px; height: 42px; padding: 0; font-size: 1.25rem; line-height: 1; }
.btn.back { color: #8aa6b5; }

.hint { color: #6e93a5; font-size: .8rem; line-height: 1.5; }

/* ============ title ============ */
#title {
  background:
    linear-gradient(180deg, rgba(3,1,7,.82) 0%, rgba(3,1,7,.55) 45%, var(--bg) 96%),
    url('/assets/landing/banner.webp') center 30% / cover no-repeat #030107;
  align-items: center; justify-content: center;
}
.title-inner { text-align: center; padding: 24px; max-width: 540px; width: 100%; }
.title-logo {
  width: clamp(84px, 14vw, 124px); margin-bottom: 8px;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.95)) drop-shadow(0 0 24px rgba(196,17,46,.35));
  animation: logobob 4.2s ease-in-out infinite;
}
@keyframes logobob { 0%,100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-8px) rotate(1.5deg); } }
.title-glitch {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 11vw, 4.6rem);
  font-weight: 900; letter-spacing: .14em; color: #fff; position: relative; line-height: 1.06;
  text-shadow: 0 0 24px rgba(70,200,240,.8), 0 0 60px rgba(70,200,240,.4);
  animation: flicker 4s infinite;
}
.title-glitch.sub { color: var(--red); text-shadow: 0 0 24px rgba(196,17,46,.85), 0 0 70px rgba(196,17,46,.4); }
@keyframes flicker { 0%, 100% { opacity: 1; } 92% { opacity: 1; } 93% { opacity: .6; } 94% { opacity: 1; } 97% { opacity: .8; } 98% { opacity: 1; } }
.tagline { margin: 18px 0 26px; color: var(--cyan-hi); line-height: 1.6; letter-spacing: .06em; }
.title-form { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-bottom: 22px; }
.title-form input {
  background: var(--panel); border: 1px solid var(--line); color: #fff;
  font: inherit; text-align: center; letter-spacing: .15em; text-transform: uppercase;
  padding: 12px; width: min(320px, 80vw); border-radius: 4px; outline: none;
}
.title-form input:focus { border-color: var(--cyan); box-shadow: 0 0 14px rgba(70,200,240,.3); }
.title-form .btn { width: min(320px, 80vw); }

/* ============ HUD ============ */
#hud {
  display: flex; align-items: center; gap: 10px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  background: linear-gradient(180deg, #04101a, #030a12);
  border-bottom: 1px solid var(--line);
  z-index: 20; min-height: 52px;
}
.hud-cell {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 5px 10px; background: rgba(5,20,32,.7);
  font-size: .85rem; letter-spacing: .06em; white-space: nowrap;
}
.hud-cell b { color: #6e93a5; font-size: .7rem; }
.hud-spacer { flex: 1; }
.big-dir { color: var(--cyan-hi); font-size: 1.1rem; font-weight: 700; }
.floor-tag { color: var(--green); font-weight: 700; letter-spacing: .12em; }
#hud-useless { color: var(--gold); font-weight: 700; }
#hud-moon-icon {
  width: 18px; height: 18px; border-radius: 50%; display: inline-block;
  background: radial-gradient(circle at calc(20% + var(--phase, 0) * 10%) 50%, #0a1822 58%, #ffe9b0 60%);
  border: 1px solid #44607a;
}

/* ============ viewport ============ */
#viewport-wrap { position: relative; flex: 1; min-height: 0; background: #000; }
#viewport { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: filter .3s; }
#viewport-wrap.blurred #viewport { filter: blur(7px) brightness(.55) saturate(1.3); }

#banner {
  position: absolute; top: 14%; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: clamp(1rem, 4vw, 1.6rem); letter-spacing: .2em; font-weight: 700;
  text-shadow: 0 0 18px var(--cyan); opacity: 0; pointer-events: none; white-space: nowrap; z-index: 15;
}
#banner.show { animation: banner 2.8s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: translateX(-50%) translateY(-12px); } 15% { opacity: 1; transform: translateX(-50%); } 80% { opacity: 1; } 100% { opacity: 0; } }

#automap {
  position: absolute; top: 10px; right: 10px;
  width: clamp(120px, 22vw, 190px); aspect-ratio: 1;
  border: 1px solid var(--line); border-radius: 4px; z-index: 10;
  box-shadow: 0 0 18px rgba(0,0,0,.6);
}
.mapbtn { position: absolute; top: 10px; right: clamp(136px, calc(22vw + 16px), 206px); z-index: 10; }

#log {
  position: absolute; left: 10px; bottom: 10px; z-index: 10;
  width: min(46vw, 380px); max-height: 130px; overflow-y: auto;
  font-size: .74rem; line-height: 1.45; color: #bfe3f2;
  text-shadow: 0 1px 2px #000; mask-image: linear-gradient(180deg, transparent, #000 22%);
  pointer-events: none;
}
.logline { animation: login .25s ease; }
@keyframes login { from { opacity: 0; transform: translateY(4px); } }

/* touch pad */
#touch { position: absolute; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 12; opacity: .92; }
.tgrid { display: grid; grid-template-columns: repeat(3, 56px); gap: 7px; }
.tbtn {
  height: 52px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(7,20,31,.72); color: var(--cyan-hi); font-size: 1.25rem;
  backdrop-filter: blur(3px); user-select: none; touch-action: none;
}
.tbtn:active { background: rgba(70,200,240,.25); border-color: var(--cyan); }
@media (hover: hover) and (pointer: fine) { #touch { opacity: .35; } #touch:hover { opacity: .95; } }

/* chat */
.chatbtn { position: absolute; left: 10px; top: 10px; z-index: 12; }
#chat {
  position: absolute; left: 10px; top: 60px; z-index: 12;
  width: min(78vw, 330px); display: none; flex-direction: column; gap: 6px;
}
#chat.open { display: flex; }
#chatlog {
  background: rgba(3,12,20,.85); border: 1px solid var(--line); border-radius: 4px;
  max-height: 160px; min-height: 60px; overflow-y: auto; padding: 8px; font-size: .76rem; line-height: 1.5;
}
.chatline b { color: var(--magenta); }
.chatline.sys { color: #6e93a5; font-style: italic; }
#chatform { display: flex; gap: 6px; }
#chatform input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  color: #fff; font: inherit; font-size: .8rem; padding: 8px; outline: none;
}

/* ============ party bar ============ */
#party {
  display: flex; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #030a12, #04101a);
  border-top: 1px solid var(--line); z-index: 20; overflow-x: auto;
}
.pcard {
  display: flex; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 4px;
  background: linear-gradient(180deg, #0d0818, #070411);
  padding: 6px 10px 6px 6px; min-width: 168px; flex: 1; max-width: 240px;
  transition: opacity .3s;
  position: relative; overflow: visible;
}
.pcard.dead { opacity: .45; filter: grayscale(.8); }
.pcard.hit { animation: phit .35s ease; }
@keyframes phit { 0%, 100% { background: linear-gradient(180deg, #07141f, #050d14); } 30% { background: #4a1020; } }
.pface { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; background: radial-gradient(circle at 50% 30%, #160d26, #070411); }
.pface.agent { object-fit: contain; padding: 2px; }
.pinfo { flex: 1; min-width: 0; }
.pname { font-size: .78rem; font-weight: 700; color: #eaf7ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plv { color: #6e93a5; font-weight: 400; font-size: .68rem; }
.bar { position: relative; height: 11px; background: #03070c; border: 1px solid #11293a; border-radius: 3px; margin-top: 3px; overflow: hidden; }
.bar i { position: absolute; inset: 0; display: block; transition: width .35s ease; }
.bar.hp i { background: linear-gradient(90deg, #1d9e57, var(--green)); }
.bar.mp i { background: linear-gradient(90deg, #1c5f9e, #53b6ff); }
.bar b { position: absolute; right: 4px; top: -1px; font-size: .6rem; color: #eaf7ff; font-weight: 600; }

/* ============ overlays / panels ============ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(1,4,8,.78); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: ovin .18s ease;
}
@keyframes ovin { from { opacity: 0; } }
.panel {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line-hot); border-radius: 4px;
  box-shadow: 0 0 36px rgba(196,17,46,.22), inset 0 0 44px rgba(196,17,46,.045);
  max-width: 560px; width: 100%; padding: 16px;
  max-height: 86vh; display: flex; flex-direction: column;
}
.panel.wide { max-width: 680px; }
.ptitle {
  font-family: var(--font-display);
  color: #fbdde4; letter-spacing: .16em; font-weight: 700; font-size: .82rem;
  border-bottom: 1px solid var(--line-hot); padding-bottom: 8px; margin-bottom: 12px; text-transform: uppercase;
  text-shadow: 0 0 12px rgba(196,17,46,.5);
}
/* portrait dialogs (NPC speaker) */
.pspeaker { display: flex; gap: 14px; align-items: flex-start; }
.pspeaker img {
  width: 86px; height: 86px; object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.9)) drop-shadow(0 0 16px rgba(196,17,46,.25));
}
.pspeaker .ptext { flex: 1; }
.ptext { line-height: 1.7; font-size: .92rem; overflow-y: auto; }
.prow { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }
.prow.col { flex-direction: column; align-items: stretch; }
.scrolly { overflow-y: auto; min-height: 0; }
.drow {
  display: flex; gap: 10px; align-items: center; padding: 8px;
  border: 1px solid #0f2738; border-radius: 5px; margin-bottom: 6px; background: rgba(4,13,21,.6);
}
.drow img { width: 52px; height: 52px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); flex-shrink: 0; }
.drow .dmeta { flex: 1; font-size: .85rem; line-height: 1.45; min-width: 0; }
.drow small { color: #8fb6c8; font-size: .74rem; }
.drow .aff { color: var(--gold); }
hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* story screens */
.overlay.story { background: radial-gradient(110% 100% at 50% 0%, #07243a 0%, rgba(1,4,8,.97) 70%); cursor: pointer; }
.overlay.story.ending { background: radial-gradient(110% 100% at 50% 0%, #0a3a24 0%, rgba(1,6,4,.97) 70%); }
.storybox { max-width: 640px; padding: 24px; text-align: center; }
.storytext { font-size: clamp(1rem, 2.6vw, 1.25rem); line-height: 1.9; color: #eaf7ff; text-shadow: 0 0 14px rgba(70,200,240,.4); animation: login .5s ease; }
.storyhint { margin-top: 28px; color: #6e93a5; font-size: .75rem; letter-spacing: .2em; animation: flicker 2.4s infinite; }

/* ============ battle ============ */
#battle {
  position: absolute; inset: 0; z-index: 40; display: none; flex-direction: column;
  background: radial-gradient(calc(100% * var(--arena, 1)) calc(72% * var(--arena, 1)) at 50% 0%, rgba(20,10,34,.55) 0%, rgba(2,5,10,.25) 62%);
}
#battle.open { display: flex; }
#battle.boss { background: radial-gradient(calc(105% * var(--arena, 1)) calc(75% * var(--arena, 1)) at 50% 0%, rgba(58,6,20,.6) 0%, rgba(2,5,10,.3) 62%); }
#battle.shake { animation: bshake .4s ease; }
@keyframes bshake { 0%, 100% { transform: none; } 25% { transform: translate(-7px, 3px); } 50% { transform: translate(6px, -4px); } 75% { transform: translate(-4px, 2px); } }

#foes { flex: 1; display: flex; align-items: center; justify-content: center; gap: clamp(8px, 4vw, 40px); padding: 16px; min-height: 0; flex-wrap: wrap; }
.foe { text-align: center; position: relative; transition: opacity .5s, transform .5s; }
.foe.gone { opacity: 0; transform: scale(.6) translateY(20px); pointer-events: none; }
.foe img {
  width: clamp(110px, 26vw, 230px); height: clamp(110px, 26vw, 230px); object-fit: contain;
  filter: drop-shadow(0 0 22px rgba(70,200,240,.45)) drop-shadow(0 14px 18px rgba(0,0,0,.7));
  animation: idlebob 2.6s ease-in-out infinite;
}
@keyframes idlebob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.foe.hit img { animation: fhit .35s ease; }
@keyframes fhit { 0% { filter: brightness(3) drop-shadow(0 0 30px #fff); transform: translateX(0); } 30% { transform: translateX(-9px); } 60% { transform: translateX(7px); } 100% { transform: none; } }
.foe.weakhit img { animation: fweak .5s ease; }
@keyframes fweak { 0% { filter: brightness(4) saturate(0) drop-shadow(0 0 40px #ffd34d); transform: scale(1.06); } 100% { transform: none; } }
.foe.acting img { animation: fact .32s ease; }
@keyframes fact { 0% { transform: scale(1); } 40% { transform: scale(1.12) translateY(6px); } 100% { transform: scale(1); } }
.foename {
  font-size: .8rem; color: #fff; letter-spacing: .08em; margin-bottom: 6px;
  text-shadow: 0 0 8px rgba(70,200,240,.8);
}
.foename span { color: #8fb6c8; }
.foehp { height: 5px; width: 70%; margin: 8px auto 0; background: #03070c; border: 1px solid #11293a; border-radius: 3px; overflow: hidden; }
.foehp i { display: block; height: 100%; background: linear-gradient(90deg, #9e1d3c, var(--red)); transition: width .3s; }

#battle-log {
  margin: 0 10px; max-height: 110px; overflow-y: auto;
  background: rgba(3,10,17,.88); border: 1px solid var(--line); border-radius: 6px 6px 0 0;
  padding: 8px 10px; font-size: .78rem; line-height: 1.5;
}
#bmenu {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 10px;
  background: rgba(4,13,21,.92); border-top: 1px solid var(--line);
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
#bmenu .btn { flex: 1 1 calc(33% - 6px); min-width: 110px; }
#bmenu .btn small { display: block; color: #6e93a5; font-size: .65rem; text-transform: none; }
.bactor { width: 100%; color: var(--cyan-hi); font-size: .85rem; letter-spacing: .1em; padding: 2px 4px 6px; }
.bactor.talkq { color: var(--magenta); line-height: 1.5; letter-spacing: 0; }
.bribe { width: 100%; color: var(--gold); font-size: .8rem; padding: 4px; }

/* ============ full map ============ */
#fullmap { position: absolute; inset: 0; z-index: 60; display: none; flex-direction: column; background: rgba(1,4,8,.96); padding: 14px; gap: 12px; }
#fullmap.open { display: flex; }
#fullmap-canvas { flex: 1; width: 100%; border: 1px solid var(--line); border-radius: 6px; min-height: 0; }
#btn-closemap { align-self: center; min-width: 200px; margin-bottom: env(safe-area-inset-bottom); }

/* ============ VN dialog (animated 2D) ============ */
#vn {
  position: fixed; inset: 0; z-index: 120; display: none;
  background: linear-gradient(180deg, rgba(2,1,5,.25) 0%, rgba(2,1,5,.55) 55%, rgba(2,1,5,.92) 100%);
  animation: ovin .2s ease;
}
#vn.open { display: block; }
.vn-stage { position: absolute; inset: 0 0 26vh 0; pointer-events: none; }
.vn-port {
  position: absolute; bottom: -2vh; max-height: 62vh; max-width: 42vw;
  object-fit: contain; opacity: 0; transform: translateY(30px);
  transition: opacity .25s, transform .25s, filter .25s;
  filter: drop-shadow(0 14px 30px rgba(0,0,0,.9)) drop-shadow(0 0 26px rgba(196,17,46,.22));
}
.vn-port.left  { left: 3vw; }
.vn-port.right { right: 3vw; transform: translateY(30px) scaleX(-1); }
.vn-port.show { opacity: 1; transform: translateY(0); animation: vnbreathe 3.2s ease-in-out infinite; }
.vn-port.right.show { animation: vnbreatheR 3.2s ease-in-out infinite; }
.vn-port.dim { filter: brightness(.35) saturate(.6) drop-shadow(0 14px 30px rgba(0,0,0,.9)); }
.vn-port.enter { animation: vnenter .35s ease, vnbreathe 3.2s ease-in-out .35s infinite !important; }
.vn-port.talking { animation: vntalk .32s ease-in-out infinite !important; }
.vn-port.right.talking { animation: vntalkR .32s ease-in-out infinite !important; }
@keyframes vnenter { from { opacity: 0; transform: translateY(46px) scale(.96); } }
@keyframes vnbreathe { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.012); } }
@keyframes vnbreatheR { 0%,100% { transform: translateY(0) scaleX(-1); } 50% { transform: translateY(-6px) scaleX(-1.012) scaleY(1.012); } }
@keyframes vntalk { 0%,100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-3px) rotate(-.5deg); } 70% { transform: translateY(-1px) rotate(.5deg); } }
@keyframes vntalkR { 0%,100% { transform: scaleX(-1) translateY(0); } 30% { transform: scaleX(-1) translateY(-3px) rotate(.5deg); } 70% { transform: scaleX(-1) translateY(-1px) rotate(-.5deg); } }
.vn-port.mood-shake { animation: vnshake .45s ease !important; }
.vn-port.mood-hop { animation: vnhop .5s ease !important; }
@keyframes vnshake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-12px,2px); } 40% { transform: translate(10px,-2px); } 60% { transform: translate(-8px,0); } 80% { transform: translate(6px,0); } }
@keyframes vnhop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-26px); } 70% { transform: translateY(-4px); } }

.vn-box {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(860px, calc(100vw - 24px));
  min-height: 21vh;
  background: linear-gradient(180deg, rgba(13,7,22,.96), rgba(5,3,10,.98));
  border: 1px solid var(--line-hot); border-radius: 6px;
  box-shadow: 0 0 40px rgba(196,17,46,.25), inset 0 0 50px rgba(196,17,46,.05);
  padding: 14px 18px 26px;
}
.vn-name {
  display: inline-block; transform: translateY(-26px);
  font-family: var(--font-display); font-size: .82rem; letter-spacing: .16em;
  color: #fff; text-transform: uppercase;
  background: linear-gradient(180deg, #3d0a18, #1c050c);
  border: 1px solid var(--blood); border-radius: 3px;
  padding: 5px 14px; box-shadow: 0 0 16px rgba(196,17,46,.5);
  text-shadow: 0 0 8px rgba(255,36,68,.8); margin-bottom: -16px;
}
.vn-text { font-size: clamp(.92rem, 2.4vw, 1.06rem); line-height: 1.75; color: #e8f2f8; min-height: 3.4em; }
.vn-hint { position: absolute; right: 14px; bottom: 8px; color: var(--red); opacity: 0; animation: bobv 1s ease-in-out infinite; }
.vn-hint.show { opacity: 1; }
@keyframes bobv { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
.vn-choices {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(23vh + 24px); width: min(640px, calc(100vw - 40px));
  display: flex; flex-direction: column; gap: 8px;
}
.vn-opt {
  background: linear-gradient(180deg, rgba(21,12,34,.97), rgba(8,4,17,.97));
  border: 1px solid var(--line); color: #dfeaf2; font: inherit; font-size: .92rem;
  padding: 12px 16px; border-radius: 4px; cursor: pointer; text-align: left;
  animation: vnoptin .3s ease backwards;
}
@keyframes vnoptin { from { opacity: 0; transform: translateX(-14px); } }
.vn-opt:hover { border-color: var(--blood); box-shadow: 0 0 16px rgba(196,17,46,.4); color: #fff; }

/* ============ Expedition Command (hub) ============ */
#hub {
  position: fixed; inset: 0; z-index: 70; display: none; flex-direction: column;
  background:
    linear-gradient(180deg, rgba(3,1,7,.86) 0%, rgba(3,1,7,.94) 100%),
    url('/assets/landing/banner.webp') center 20% / cover no-repeat #030107;
  overflow-y: auto; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}
#hub.open { display: flex; }
.hub-head { text-align: center; margin: 8px 0 4px; }
.hub-title { font-family: var(--font-display); font-weight: 900; letter-spacing: .2em; color: #fff; font-size: clamp(1.1rem, 4.5vw, 1.7rem); text-shadow: 0 0 20px rgba(70,200,240,.6); }
.hub-sub { color: #7d93a5; font-size: .8rem; letter-spacing: .12em; margin-top: 6px; }
.hub-frag { color: var(--gold); font-family: var(--font-display); letter-spacing: .3em; margin-top: 8px; font-size: .95rem; text-shadow: 0 0 14px rgba(255,211,77,.6); }
.hub-section { max-width: 980px; margin: 18px auto 0; width: 100%; }
.hub-section h3 { font-family: var(--font-display); color: #fbdde4; font-size: .78rem; letter-spacing: .2em; margin-bottom: 10px; }
.hub-section h3::before { content: '▸ '; color: var(--red); }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dcard {
  position: relative; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  padding: 12px 10px 10px; min-height: 150px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  text-align: center;
}
.dcard:hover:not(.locked) { transform: translateY(-3px); border-color: var(--blood); box-shadow: 0 0 22px rgba(196,17,46,.35); }
.dcard img.dboss { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); height: 74px; max-width: 86%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.9)); }
.dcard .dname { font-family: var(--font-display); font-size: .68rem; letter-spacing: .1em; color: #fff; text-shadow: 0 1px 6px #000; }
.dcard .dmetaa { font-size: .62rem; color: #aebecb; }
.dcard.cleared::after { content: '✔ FRAGMENT'; position: absolute; top: 6px; right: 6px; font-size: .56rem; color: var(--green); letter-spacing: .1em; text-shadow: 0 0 8px rgba(53,255,158,.8); }
.dcard.locked { filter: grayscale(.85) brightness(.55); cursor: default; }
.dcard.locked::after { content: '🔒'; position: absolute; top: 6px; right: 8px; }
.crewgrid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.crewcard {
  flex: 0 0 auto; width: 104px; text-align: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 6px 8px;
  background: linear-gradient(180deg, rgba(13,8,24,.85), rgba(6,3,12,.9));
  transition: transform .15s, border-color .15s;
}
.crewcard:hover { transform: translateY(-3px); border-color: var(--cyan); }
.crewcard img { height: 64px; max-width: 92px; object-fit: contain; filter: drop-shadow(0 5px 9px rgba(0,0,0,.85)); }
.crewcard .cname { font-size: .68rem; color: #fff; font-weight: 700; margin-top: 6px; }
.crewcard .crole { font-size: .56rem; color: #7d93a5; letter-spacing: .06em; }
.hub-actions { display: flex; gap: 10px; justify-content: center; margin: 22px 0 8px; flex-wrap: wrap; }

/* item icons */
.iticon { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; filter: drop-shadow(0 3px 6px rgba(0,0,0,.8)); }

/* ============ identity gate (title) ============ */
.idbadge {
  color: var(--green); font-size: .8rem; letter-spacing: .1em;
  border: 1px solid #14422e; border-radius: 4px; padding: 7px 12px;
  background: rgba(5, 24, 16, .6); text-shadow: 0 0 10px rgba(53,255,158,.5);
}
#identity-step, #start-step { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
#identity-step[hidden], #start-step[hidden] { display: none; }
#identity-status { min-height: 1.2em; color: var(--red); }

/* ============ status screen ============ */
.statcard {
  border: 1px solid #1c1430; border-radius: 6px; padding: 12px;
  background: linear-gradient(180deg, rgba(13,8,24,.85), rgba(6,3,12,.9));
  margin-bottom: 10px;
}
.stathead { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.stathead img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.8)); }
.stathead b { color: #fff; font-size: 1rem; }
.bar.xp { width: 180px; max-width: 48vw; }
.bar.xp i { background: linear-gradient(90deg, #7a5a12, var(--gold)); }
.statgrid {
  display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 4px 10px;
  font-size: .8rem; margin-bottom: 10px;
}
.statgrid span { color: #6e93a5; letter-spacing: .1em; font-size: .68rem; align-self: center; }
.statgrid b { color: #eaf7ff; }
.statgrid b.aff { color: var(--gold); font-weight: 600; font-size: .72rem; }
.statgrid span:nth-last-child(2), .statgrid b:last-child { grid-column: span 2; }
.statskills .sklabel { color: var(--cyan-hi); letter-spacing: .18em; font-size: .64rem; display: block; margin: 8px 0 4px; }
.statskills .sklabel.upcoming { color: var(--gold); }
.skrow { padding: 5px 8px; border-left: 2px solid var(--line); margin-bottom: 4px; font-size: .8rem; background: rgba(4,13,21,.5); }
.skrow i { color: #8fb6c8; font-style: normal; font-size: .68rem; }
.skrow small { color: #6e93a5; }
.skrow.locked { opacity: .55; border-left-color: var(--gold); }

/* ============ sound settings ============ */
.sndrow { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.sndrow label { width: 110px; font-size: .76rem; letter-spacing: .1em; color: var(--cyan-hi); }
.sndrow input[type=range] { flex: 1; accent-color: var(--blood); }

/* foe hp numbers */
.foehp-num { font-size: .62rem; color: #ffb3c0; margin-top: 3px; letter-spacing: .06em; text-shadow: 0 1px 3px #000; }
.foe .status-tags { position: absolute; top: -4px; right: 0; display: flex; gap: 3px; }
.status-tag { font-size: .56rem; padding: 2px 5px; border-radius: 3px; letter-spacing: .08em; }
.status-tag.poison { background: #2a0d35; color: #d98aff; border: 1px solid #7a2a99; }
.status-tag.stun { background: #332a05; color: #ffe14d; border: 1px solid #997f1a; }

@media (orientation: portrait) and (max-width: 700px) {
  .vn-port { max-width: 64vw; max-height: 46vh; }
  .vn-port.right { max-width: 52vw; }
  .vn-box { min-height: 24vh; }
  .vn-choices { bottom: calc(26vh + 20px); }
}

/* ============ black-hole encounter transition ============ */
#blackhole {
  position: fixed; inset: 0; z-index: 95; pointer-events: none;
  display: grid; place-items: center; opacity: 0;
}
#blackhole .vortex {
  width: 30vmax; height: 30vmax; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #000 28%, transparent 66%),
    repeating-conic-gradient(from 0deg, #000 0deg 14deg, #2a0716 14deg 22deg, #5e0e26 22deg 26deg, #000 26deg 40deg);
  filter: blur(2px) contrast(1.2);
  transform: scale(0) rotate(0deg);
  box-shadow: 0 0 120px 60px rgba(0,0,0,.9), inset 0 0 80px 40px #000;
}
#blackhole.go { opacity: 1; }
#blackhole.go .vortex { animation: vortexin .75s cubic-bezier(.5,0,.9,.4) forwards; }
@keyframes vortexin {
  0% { transform: scale(0) rotate(0deg); }
  100% { transform: scale(9) rotate(540deg); }
}
#blackhole.out { opacity: 1; animation: holdout .45s ease forwards; }
#blackhole.out .vortex { transform: scale(9) rotate(540deg); background: #000; box-shadow: none; filter: none; }
@keyframes holdout { 0% { opacity: 1; } 100% { opacity: 0; } }

/* fieldfx layer (treasure bursts, validator waves) */
#fieldfx { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }

/* ============ battle FX layer ============ */
.fxwrap { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.dmgnum {
  position: absolute; font-family: var(--font-display); font-weight: 900;
  font-size: clamp(1.3rem, 4.5vw, 2.2rem); color: #fff; z-index: 6;
  text-shadow: 0 0 10px #000, 0 2px 4px #000;
  animation: dmgpop .9s ease-out forwards; pointer-events: none; white-space: nowrap;
}
.dmgnum.weak { color: var(--gold); font-size: clamp(1.7rem, 6vw, 2.9rem); text-shadow: 0 0 18px rgba(255,211,77,.9), 0 2px 4px #000; }
.dmgnum.resist { color: #8fa3b5; font-size: clamp(1rem, 3.4vw, 1.6rem); }
.dmgnum.heal { color: var(--green); text-shadow: 0 0 14px rgba(53,255,158,.8), 0 2px 4px #000; }
@keyframes dmgpop {
  0% { transform: translate(-50%, 0) scale(.4); opacity: 0; }
  18% { transform: translate(-50%, -16px) scale(1.18); opacity: 1; }
  100% { transform: translate(-50%, -64px) scale(.95); opacity: 0; }
}
.fx-slash {
  position: absolute; width: 130%; height: 5px; left: -15%; top: 50%; z-index: 5;
  background: linear-gradient(90deg, transparent, #fff 18%, #fff 82%, transparent);
  box-shadow: 0 0 16px #fff, 0 0 40px rgba(255,255,255,.6);
  transform-origin: center; animation: slashcut .34s ease-out forwards; pointer-events: none;
}
@keyframes slashcut {
  0% { transform: rotate(var(--ang, -28deg)) scaleX(0); opacity: 0; }
  35% { transform: rotate(var(--ang, -28deg)) scaleX(1.05); opacity: 1; }
  100% { transform: rotate(var(--ang, -28deg)) scaleX(1.1); opacity: 0; }
}
.fx-burst {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  z-index: 5; pointer-events: none;
  animation: burst .55s ease-out forwards;
}
@keyframes burst {
  0% { transform: translate(-50%,-50%) scale(.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0); opacity: 0; }
}
.fx-blood {
  position: absolute; border-radius: 60% 40% 55% 45%;
  background: radial-gradient(circle at 38% 35%, #ff3050, #7d0418 70%);
  z-index: 5; pointer-events: none;
  animation: blooddrip .9s cubic-bezier(.2,.5,.6,1) forwards;
}
@keyframes blooddrip {
  0% { transform: translate(-50%,-50%) scale(.3); opacity: 0; }
  16% { opacity: .95; transform: translate(-50%,-50%) scale(1); }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 70px)) scale(.55); opacity: 0; }
}
.fx-ring {
  position: absolute; border: 3px solid; border-radius: 50%; width: 20px; height: 20px;
  z-index: 5; pointer-events: none; transform: translate(-50%,-50%);
  animation: ringout .5s ease-out forwards;
}
@keyframes ringout {
  0% { width: 18px; height: 18px; opacity: 1; }
  100% { width: 190px; height: 190px; opacity: 0; }
}
.fx-flashscreen {
  position: absolute; inset: 0; z-index: 8; pointer-events: none;
  animation: scrflash .3s ease-out forwards;
}
@keyframes scrflash { 0% { opacity: .55; } 100% { opacity: 0; } }

/* ============ responsive (landscape-ish narrow) ============ */
@media (max-width: 700px) {
  #log { width: 52vw; max-height: 100px; font-size: .68rem; bottom: auto; top: calc(10px + 48px); left: 10px; }
  .pcard { min-width: 142px; }
  .tgrid { grid-template-columns: repeat(3, 50px); }
  .tbtn { height: 48px; }
  .hud-cell { padding: 4px 7px; font-size: .74rem; }
  #hud { gap: 6px; }
}

/* ============ phone portrait: map sits lower, above the party bar ============ */
@media (orientation: portrait) and (max-width: 700px) {
  #automap {
    top: auto; right: auto;
    left: 10px; bottom: calc(118px + env(safe-area-inset-bottom));
    width: clamp(128px, 38vw, 170px);
    opacity: .94;
  }
  .mapbtn { top: auto; right: auto; left: 10px; bottom: calc(70px + env(safe-area-inset-bottom)); }
  #touch { right: 8px; bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tgrid { grid-template-columns: repeat(3, 54px); gap: 6px; }
  .tbtn { height: 50px; font-size: 1.15rem; }
  #log { top: 8px; left: 8px; width: 60vw; max-height: 92px; font-size: .66rem; }
  .chatbtn { left: auto; right: 8px; top: 8px; }
  #chat { left: 8px; top: 50px; width: calc(100vw - 16px); }
  #banner { top: 20%; }
  #foes { padding-top: 4px; }
  .foe img { width: clamp(96px, 30vw, 150px); height: clamp(96px, 30vw, 150px); }
  #battle-log { max-height: 88px; font-size: .72rem; }
  #bmenu .btn { flex: 1 1 calc(50% - 6px); min-width: 0; padding: 9px 6px; font-size: .78rem; }
}
