:root{
  --bg:#09111b;
  --bg2:#10243b;
  --panel:#0e1d2f;
  --panel2:#14304c;
  --line:rgba(244,200,97,.20);
  --gold:#f4c861;
  --gold2:#ffe3a6;
  --text:#f6efdc;
  --muted:#b9c5d2;
  --blue:#79c0ff;
  --green:#73d789;
  --red:#e37d7d;
  --shadow:0 12px 28px rgba(0,0,0,.32);
}

*{box-sizing:border-box}

html,body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  font-family:Verdana,Arial,sans-serif;
  background:
    radial-gradient(circle at top, rgba(66,121,179,.18), transparent 28%),
    linear-gradient(180deg,var(--bg2),var(--bg));
  color:var(--text);
}

body{
  position:fixed;
  inset:0;
}

.crt{
  position:fixed;
  inset:0;
  pointer-events:none;
  background:repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.02) 0px,
    rgba(255,255,255,.02) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity:.12;
  z-index:20;
}

.gameShell{
  width:100vw;
  height:100svh;
  padding:10px;
  display:grid;
  grid-template-rows:auto 1fr;
  gap:10px;
  overflow:hidden;
}

.topBar{
  display:grid;
  grid-template-columns:auto 1fr;
  gap:12px;
  align-items:end;
  min-height:0;
}

.titleBlock h1{
  margin:0;
  font-size:clamp(2.2rem,4vw,3.2rem);
  line-height:1;
  color:var(--gold2);
  letter-spacing:.08em;
  text-shadow:0 0 12px rgba(244,200,97,.14);
}

.eyebrow{
  color:var(--gold);
  text-transform:uppercase;
  letter-spacing:.08em;
  font-size:.68rem;
  margin-bottom:5px;
}

.topHud{
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  gap:8px;
}

.hudChip,
.panel,
.dockPanel{
  background:linear-gradient(180deg,var(--panel2),var(--panel));
  border:1px solid var(--line);
  border-radius:12px;
  box-shadow:var(--shadow);
}

.hudChip{
  padding:8px 10px;
  min-width:0;
}

.hudLabel{
  color:var(--muted);
  font-size:.66rem;
  margin-bottom:3px;
}

.hudValue{
  color:var(--gold2);
  font-size:.88rem;
  font-weight:bold;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.gameStage{
  min-height:0;
  padding:8px;
  display:grid;
  grid-template-rows:1fr auto;
  gap:8px;
}

.journeyViewport{
  min-height:0;
  position:relative;
  border-radius:12px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.08);
  background:#0a1420;
}

.seaScene,
.minigameMount{
  position:absolute;
  inset:0;
}

.seaScene{
  overflow:hidden;
}

.minigameMount{
  z-index:15;
  background:rgba(5,11,18,.94);
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
}

.minigameMount.active{
  opacity:1;
  pointer-events:auto;
}

.minigameIdle{
  color:var(--muted);
  text-align:center;
  padding:24px;
  font-size:.95rem;
  line-height:1.45;
}

.skyLayer{
  position:absolute;
  inset:0;
  background:linear-gradient(180deg,#86bce9 0%, #5a8cbb 32%, #2f5f8c 58%, #173a5c 100%);
}

.sunPixel{
  position:absolute;
  top:24px;
  right:32px;
  width:54px;
  height:54px;
  background:#ffd978;
  box-shadow:0 0 0 8px rgba(255,217,120,.12), 0 0 0 16px rgba(255,217,120,.06);
}

.cloudPixel{
  position:absolute;
  width:84px;
  height:18px;
  background:#e7f1fb;
  box-shadow:
    18px 0 0 #e7f1fb,
    36px 0 0 #e7f1fb,
    12px -10px 0 #e7f1fb,
    30px -10px 0 #e7f1fb;
}

.cloudA{ top:58px; left:110px; }
.cloudB{ top:102px; left:360px; }

.islandPixel,
.reefPixel{
  position:absolute;
}

.islandPixel{
  bottom:142px;
  width:82px;
  height:24px;
  background:#417d35;
  box-shadow:
    0 -10px 0 #559843,
    18px -10px 0 #559843,
    36px -10px 0 #559843,
    18px -20px 0 #6dba58;
}

.islandLeft{ left:72px; }
.islandRight{ right:140px; }

.reefPixel{
  bottom:118px;
  width:40px;
  height:16px;
  background:#59636d;
  box-shadow:
    12px -8px 0 #6c7780,
    22px 0 0 #59636d,
    30px -6px 0 #6c7780;
}

.reefLeft{ left:320px; }
.reefRight{ right:330px; }

.seaBand{
  position:absolute;
  left:0;
  right:0;
}

.seaBack{
  bottom:140px;
  height:22px;
  background:repeating-linear-gradient(90deg,#5da7e1 0 24px,#73b8ec 24px 48px);
}

.seaMid{
  bottom:86px;
  height:54px;
  background:repeating-linear-gradient(90deg,#2f6da2 0 24px,#3a80bc 24px 48px);
}

.seaFront{
  bottom:0;
  height:86px;
  background:repeating-linear-gradient(90deg,#16476f 0 26px,#1e5b8b 26px 52px);
}

.shipLane{
  position:absolute;
  left:0;
  right:0;
  bottom:92px;
  height:110px;
  pointer-events:none;
}

.shipSprite{
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  bottom:0;
  font-size:2.4rem;
  filter:drop-shadow(0 6px 10px rgba(0,0,0,.26));
  z-index:2;
}

.overlay{
  position:absolute;
  background:rgba(7,13,22,.78);
  border:1px solid rgba(255,255,255,.08);
  border-radius:10px;
  padding:10px;
  backdrop-filter:blur(2px);
  overflow:hidden;
  z-index:5;
}

.overlayTop{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
  margin-bottom:8px;
}

.compactTop{
  align-items:center;
}

.overlay h2{
  margin:0;
  font-size:.9rem;
  color:var(--gold2);
  letter-spacing:.05em;
}

.storyOverlay{
  top:12px;
  left:12px;
  width:min(42%, 700px);
  min-height:160px;
  max-height:28%;
}

.statusOverlay{
  top:12px;
  right:12px;
  width:min(28%, 400px);
  min-height:92px;
  max-height:20%;
}

.sceneOverlay{
  left:50%;
  transform:translateX(-50%);
  bottom:12px;
  width:300px;
  text-align:center;
}

.logOverlay{
  top:12px;
  left:50%;
  transform:translateX(-50%);
  width:300px;
  max-height:132px;
  opacity:.92;
  z-index:6;
}

.badge{
  padding:6px 10px;
  border-radius:999px;
  font-size:.7rem;
  font-weight:bold;
  white-space:nowrap;
}

.badge.gold{
  border:1px solid rgba(244,200,97,.24);
  background:rgba(244,200,97,.08);
  color:var(--gold2);
}

.badge.blue{
  border:1px solid rgba(121,192,255,.28);
  background:rgba(121,192,255,.08);
  color:var(--blue);
}

.storyText{
  min-height:0;
  max-height:72px;
  overflow:auto;
  white-space:pre-wrap;
  line-height:1.36;
  font-size:.8rem;
}

.choiceArea{
  display:grid;
  gap:6px;
  margin-top:8px;
}

.statusBanner{
  padding:8px 10px;
  border-radius:8px;
  background:rgba(244,200,97,.07);
  border:1px solid rgba(244,200,97,.14);
  line-height:1.34;
  font-size:.76rem;
}

.miniTitle{
  color:var(--gold2);
  font-size:.7rem;
  font-weight:bold;
  letter-spacing:.06em;
  margin-bottom:8px;
}

.miniMeta{
  color:var(--muted);
  font-size:.64rem;
}

.sceneText{
  color:var(--muted);
  font-size:.72rem;
  line-height:1.28;
}

.log{
  max-height:84px;
  overflow:auto;
  display:flex;
  flex-direction:column-reverse;
  gap:6px;
}

.logEntry{
  background:rgba(255,255,255,.03);
  border-left:3px solid rgba(244,200,97,.40);
  border-radius:0 8px 8px 0;
  padding:7px 9px;
  color:var(--muted);
  line-height:1.28;
  font-size:.72rem;
}

.sideTab{
  position:absolute;
  z-index:7;
  width:38px;
  height:102px;
  writing-mode:vertical-rl;
  text-orientation:mixed;
  letter-spacing:.08em;
  font-size:.68rem;
  font-weight:bold;
  border-radius:10px;
  padding:8px 6px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.leftTab{
  left:8px;
}

.routeTab{
  bottom:120px;
}

.sidePanel{
  position:absolute;
  z-index:7;
  background:rgba(7,13,22,.84);
  border:1px solid rgba(255,255,255,.08);
  border-radius:10px;
  padding:10px;
  backdrop-filter:blur(2px);
  overflow:hidden;
  opacity:0;
  pointer-events:none;
  transition:opacity .15s ease, transform .15s ease;
}

.sidePanel.open{
  opacity:1;
  pointer-events:auto;
}

.leftPanel{
  left:50px;
}

.routePanel{
  bottom:12px;
  width:min(320px, 24%);
  max-height:36%;
  transform:translateX(-8px);
}

.routePanel.open{
  transform:translateX(0);
}

.panelTopRow{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
  margin-bottom:8px;
}

.routeMap{
  display:grid;
  gap:6px;
  overflow:auto;
  max-height:180px;
}

.routeNode{
  padding:7px 8px;
  border-radius:8px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.06);
  font-size:.66rem;
}

.routeNode.active{
  border-color:rgba(121,192,255,.36);
  box-shadow:0 0 10px rgba(121,192,255,.10);
}

.routeNode.completed{
  border-color:rgba(115,215,137,.28);
  background:rgba(115,215,137,.05);
}

.routeTitle{
  font-weight:bold;
  margin-bottom:3px;
}

.routeDesc{
  color:var(--muted);
  font-size:.6rem;
  line-height:1.2;
}

.bottomDock{
  display:grid;
  gap:8px;
}

.actionBar{
  display:grid;
  grid-template-columns:1.05fr repeat(8,1fr);
  gap:6px;
}

.primaryAction{
  background:linear-gradient(180deg, rgba(121,192,255,.44), rgba(121,192,255,.12));
  border-color:rgba(121,192,255,.40);
}

button{
  appearance:none;
  border:1px solid rgba(244,200,97,.24);
  background:linear-gradient(180deg, rgba(244,200,97,.18), rgba(244,200,97,.06));
  color:var(--text);
  border-radius:10px;
  padding:8px 10px;
  font-size:.74rem;
  font-weight:bold;
  cursor:pointer;
  min-height:38px;
}

button:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.infoDock{
  display:grid;
  grid-template-columns:220px 180px 1fr;
  gap:8px;
  min-height:130px;
}

.dockPanel{
  min-height:0;
  padding:10px;
  overflow:hidden;
}

.dockTitle{
  color:var(--gold2);
  font-size:.72rem;
  font-weight:bold;
  letter-spacing:.06em;
  margin-bottom:8px;
}

.dockGrid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:6px;
}

.singleCol{
  grid-template-columns:1fr;
}

.statCard,
.inventoryCard,
.crewCard{
  padding:7px 8px;
  border-radius:8px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.06);
}

.statLabel,
.inventoryKey{
  color:var(--muted);
  font-size:.58rem;
  margin-bottom:3px;
}

.statValue,
.inventoryValue{
  font-size:.76rem;
  font-weight:bold;
}

.crewDockList{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:6px;
  overflow:auto;
  max-height:84px;
}

.crewTop{
  display:flex;
  justify-content:space-between;
  gap:8px;
  margin-bottom:5px;
}

.crewName{
  font-weight:bold;
  font-size:.7rem;
}

.crewRole{
  color:var(--gold);
  font-size:.58rem;
}

.healthBarOuter{
  width:100%;
  height:7px;
  background:rgba(255,255,255,.08);
  border-radius:999px;
  overflow:hidden;
}

.healthBarInner{
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg,#df7474,#efcf85,#73d789);
}

.good{color:var(--green)}
.bad{color:var(--red)}

canvas{
  display:block;
  width:100%;
  height:auto;
  background:#08111b;
  image-rendering:pixelated;
}

.minigameInfo{
  position:absolute;
  top:10px;
  left:10px;
  right:10px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  z-index:16;
  color:#fff;
  font-size:.74rem;
  font-weight:bold;
  text-shadow:0 1px 4px rgba(0,0,0,.45);
}

@media (max-width:1500px){
  .topHud{grid-template-columns:repeat(3,1fr)}
  .actionBar{grid-template-columns:repeat(3,1fr)}
  .infoDock{grid-template-columns:1fr}
  .crewDockList{grid-template-columns:repeat(3,minmax(0,1fr))}
}

@media (max-width:1200px){
  .storyOverlay{width:min(52%, 700px)}
  .statusOverlay{width:min(34%, 400px)}
}

@media (max-width:1000px){
  html,body{
    overflow:auto;
    position:static;
  }
  .gameShell{
    height:auto;
  }
  .journeyViewport{
    min-height:1100px;
  }
}
