/* STARWARD — Echoes of the Farwatch Gate: cockpit styling.
   Cinematic blue glass HUD over deep space: translucent navy panels, cyan
   glow edges, gold reserved for the quest beacon and Union details. */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #04122e; }
body { font-family: system-ui, "Segoe UI", Roboto, sans-serif; color: #d9ecff; }
#game-canvas-host, #game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#vignette-flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.12s; z-index: 5; }
#vignette-flash.on { opacity: 1; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.panel {
  position: absolute;
  background: linear-gradient(160deg, rgba(8, 28, 56, 0.82), rgba(4, 16, 36, 0.78));
  border: 1px solid rgba(55, 200, 255, 0.45);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 0 18px rgba(55, 200, 255, 0.12), inset 0 0 24px rgba(55, 200, 255, 0.05);
  backdrop-filter: blur(3px);
}

/* Objective */
#objective { top: 16px; left: 16px; width: 330px; }
#objective-act { color: #ffd98a; font-size: 12px; letter-spacing: 0.14em; font-weight: 700; }
#objective-text { margin-top: 4px; font-size: 14.5px; line-height: 1.35; }
#heading-line { margin-top: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #7ad7ff; }

/* Radar */
#radar-wrap { top: 16px; right: 16px; width: 176px; text-align: center; }
#radar { width: 150px; height: 150px; }
#coords { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: #7ad7ff; margin-top: 2px; }

/* Boss bar */
#bossbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  width: 430px; padding: 8px 14px 10px; border-radius: 10px;
  background: linear-gradient(160deg, rgba(56, 14, 10, 0.85), rgba(30, 6, 6, 0.82));
  border: 1px solid rgba(255, 90, 60, 0.55);
  opacity: 0; transition: opacity 0.3s;
}
#bossbar.visible { opacity: 1; }
.boss-name { text-align: center; color: #ff9a6a; font-weight: 700; letter-spacing: 0.16em; font-size: 12.5px; margin-bottom: 5px; }
.boss-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.boss-row span { width: 58px; font-size: 10px; color: #ffb59a; letter-spacing: 0.08em; }

/* Bars */
.bar { flex: 1; height: 9px; background: rgba(10, 24, 44, 0.9); border: 1px solid rgba(120, 190, 240, 0.35); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; width: 100%; transition: width 0.25s; }
.bar-fill.hull { background: linear-gradient(90deg, #2f9e6e, #6fe8a8); }
.bar-fill.shield { background: linear-gradient(90deg, #2f7bff, #37c8ff); }
.bar-fill.fuel { background: linear-gradient(90deg, #c77f2a, #ffd98a); }
.bar-fill.boss { background: linear-gradient(90deg, #c22e1c, #ff7a2a); }
.bar-fill.low { background: linear-gradient(90deg, #c22e1c, #ff4d4d) !important; }

/* Ship stats */
#shipstats { bottom: 16px; left: 16px; width: 300px; }
.ship-name { color: #ffd98a; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; margin-bottom: 6px; }
.stat-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.stat-row span { width: 46px; font-size: 10.5px; color: #9fc6e8; letter-spacing: 0.08em; }
.res-grid { display: flex; gap: 6px; margin-top: 9px; }
.res { flex: 1; background: rgba(10, 26, 50, 0.75); border: 1px solid rgba(55, 200, 255, 0.25); border-radius: 6px; padding: 4px 2px; text-align: center; }
.res label { display: block; font-size: 8.5px; color: #8fb8dd; letter-spacing: 0.06em; }
.res b { font-size: 14px; color: #eaf6ff; font-family: ui-monospace, Menlo, monospace; }

/* Weapons + speed pod */
#weapons { bottom: 108px; right: 16px; width: 196px; }
.weapon { font-size: 13px; margin-top: 2px; color: #cfeaff; }
.weapon b { color: #ffd98a; font-family: ui-monospace, Menlo, monospace; }
.wkey { display: inline-block; min-width: 20px; text-align: center; background: rgba(55, 200, 255, 0.16); border: 1px solid rgba(55, 200, 255, 0.5); border-radius: 4px; font-size: 11px; padding: 1px 3px; margin-right: 5px; color: #7ad7ff; }
#weapon-lock { margin-top: 4px; font-size: 12px; color: #ffb59a; font-family: ui-monospace, Menlo, monospace; min-height: 15px; }
#weapon-lock.locked { color: #ff5a4a; font-weight: 700; }
#speedpod {
  position: absolute; bottom: 16px; right: 16px; width: 196px; height: 80px;
  background: linear-gradient(160deg, rgba(8, 28, 56, 0.85), rgba(4, 16, 36, 0.8));
  border: 1px solid rgba(55, 200, 255, 0.45);
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px), 0 18px);
  display: flex; align-items: center; justify-content: space-around; padding: 8px;
}
.pod-cell { text-align: center; }
.pod-cell label { display: block; font-size: 9px; color: #8fb8dd; letter-spacing: 0.1em; }
.pod-cell b { font-size: 19px; color: #eaf6ff; font-family: ui-monospace, Menlo, monospace; }

/* Discovery log */
#log { position: absolute; right: 16px; top: 210px; width: 264px; display: flex; flex-direction: column; gap: 5px; }
.log-entry {
  background: rgba(6, 20, 40, 0.72); border-left: 3px solid #37c8ff; border-radius: 4px;
  padding: 5px 8px; font-size: 12px; line-height: 1.3; color: #cfeaff;
}
.log-entry.fragment { border-left-color: #b78cff; }
.log-entry.danger { border-left-color: #ff4d4d; color: #ffd2c9; }
.log-entry.story { border-left-color: #ffd98a; }
.log-entry.combat { border-left-color: #ff7a2a; }

/* Discovery card */
#discovery-card {
  position: absolute; left: 50%; top: 24%; transform: translate(-50%, -12px);
  width: 430px; max-width: 86vw; padding: 14px 18px; border-radius: 12px;
  background: linear-gradient(165deg, rgba(24, 14, 52, 0.92), rgba(8, 18, 40, 0.92));
  border: 1px solid rgba(183, 140, 255, 0.65);
  box-shadow: 0 0 34px rgba(183, 140, 255, 0.3);
  opacity: 0; transition: opacity 0.35s, transform 0.35s; text-align: center;
}
#discovery-card.visible { opacity: 1; transform: translate(-50%, 0); }
#discovery-title { color: #cdb4ff; font-weight: 700; font-size: 15.5px; letter-spacing: 0.04em; }
#discovery-text { margin-top: 6px; font-size: 13.5px; line-height: 1.45; color: #e8e2ff; }

/* Scan panel */
#scan-panel {
  position: absolute; left: 50%; bottom: 218px; transform: translateX(-50%);
  width: 430px; max-width: 86vw; padding: 10px 14px; border-radius: 10px;
  background: rgba(6, 22, 44, 0.88); border: 1px solid rgba(55, 200, 255, 0.55);
  opacity: 0; transition: opacity 0.25s;
}
#scan-panel.visible { opacity: 1; }
.scan-head { font-size: 11px; letter-spacing: 0.18em; color: #7ad7ff; }
.scan-track { height: 10px; margin-top: 6px; background: rgba(10, 24, 44, 0.9); border: 1px solid rgba(120, 190, 240, 0.35); border-radius: 5px; overflow: hidden; }
#scan-wave { height: 100%; width: 0; background: linear-gradient(90deg, #2f7bff, #37c8ff, #b78cff); transition: width 0.15s; }
#scan-status { margin-top: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #cfeaff; white-space: nowrap; overflow: hidden; }

/* Dialogue */
#dialogue {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  width: 640px; max-width: 88vw; padding: 12px 18px 8px; border-radius: 12px;
  background: linear-gradient(165deg, rgba(8, 24, 48, 0.92), rgba(4, 14, 30, 0.92));
  border: 1px solid rgba(120, 200, 255, 0.5);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.45);
  opacity: 0; transition: opacity 0.25s;
}
#dialogue.visible { opacity: 1; }
#dialogue-name { font-weight: 700; font-size: 13.5px; letter-spacing: 0.05em; }
#dialogue-text { margin-top: 4px; font-size: 15.5px; line-height: 1.5; color: #eef7ff; min-height: 46px; }
.dialogue-hint { margin-top: 4px; font-size: 10px; color: #7d9cbd; letter-spacing: 0.12em; text-align: right; }
#choices {
  position: absolute; left: 50%; bottom: 238px; transform: translateX(-50%);
  width: 640px; max-width: 88vw; display: none; flex-direction: column; gap: 7px;
}
#choices.visible { display: flex; }
.choice-btn {
  pointer-events: auto; cursor: pointer; text-align: left;
  background: rgba(10, 30, 58, 0.94); color: #eaf6ff; border: 1px solid rgba(255, 217, 138, 0.55);
  border-radius: 9px; padding: 10px 14px; font-size: 14.5px; line-height: 1.35;
}
.choice-btn:hover { background: rgba(24, 52, 92, 0.97); border-color: #ffd98a; }

/* Route line + prompt */
#route-line {
  position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%);
  font-size: 14.5px; color: #ffc84d; text-shadow: 0 0 12px rgba(255, 200, 77, 0.5);
  white-space: nowrap; opacity: 0; transition: opacity 0.3s;
}
#route-line.visible { opacity: 1; }
#prompt {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%);
  font-size: 14px; color: #bfe6ff; background: rgba(6, 20, 40, 0.66); padding: 5px 14px;
  border-radius: 16px; border: 1px solid rgba(55, 200, 255, 0.3); white-space: nowrap;
  opacity: 0; transition: opacity 0.25s;
}
#prompt.visible { opacity: 1; }

/* Nav marker */
#nav-marker { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity 0.3s; will-change: transform; }
#nav-marker.visible { opacity: 1; }
#nav-label {
  color: #ffc84d; font-size: 13.5px; font-weight: 700; white-space: nowrap;
  text-shadow: 0 0 10px rgba(255, 200, 77, 0.75), 0 1px 3px rgba(0, 0, 0, 0.8);
}
#nav-marker.edge #nav-label { font-size: 14.5px; }

#toast {
  position: absolute; left: 50%; top: 86px; transform: translateX(-50%);
  background: rgba(8, 24, 48, 0.92); border: 1px solid rgba(255, 217, 138, 0.6); color: #ffe9b8;
  padding: 8px 18px; border-radius: 9px; font-size: 14.5px; opacity: 0; transition: opacity 0.3s;
  max-width: 84vw; text-align: center;
}
#toast.visible { opacity: 1; }
#backend-badge { position: absolute; left: 16px; top: 158px; font-size: 10.5px; color: rgba(140, 180, 220, 0.6); font-family: ui-monospace, Menlo, monospace; }
#surface-hud { position: absolute; left: 16px; top: 130px; font-size: 12px; color: #9fe8b0; }

/* Title screen */
#title-screen {
  position: fixed; inset: 0; z-index: 30; display: none;
  background: radial-gradient(ellipse at 50% 120%, rgba(20, 60, 120, 0.5), rgba(2, 8, 20, 0.88) 70%);
  align-items: center; justify-content: center;
}
#title-screen.visible { display: flex; }
.title-inner { text-align: center; max-width: 720px; padding: 30px; }
.title-kicker { color: #7ad7ff; letter-spacing: 0.34em; font-size: 12px; }
.title-inner h1 { font-size: 74px; letter-spacing: 0.22em; color: #eaf6ff; text-shadow: 0 0 34px rgba(55, 200, 255, 0.55); margin-top: 8px; }
.title-sub { color: #ffd98a; font-size: 21px; letter-spacing: 0.1em; margin-top: 2px; }
.title-story { margin-top: 20px; font-size: 15.5px; line-height: 1.6; color: #cfe4fa; }
.title-guide { margin-top: 12px; font-size: 14.5px; color: #bfe6ff; }
.title-guide .gold { color: #ffc84d; font-weight: 700; }
.controls { margin: 20px auto 6px; font-size: 13px; line-height: 1.85; color: #9fc6e8; }
.controls b { color: #eaf6ff; }
#start-btn {
  margin-top: 18px; pointer-events: auto; cursor: pointer;
  background: linear-gradient(180deg, #1d5f9e, #123f6e); color: #eaf6ff;
  border: 1px solid rgba(55, 200, 255, 0.7); border-radius: 10px;
  font-size: 17px; letter-spacing: 0.08em; padding: 13px 34px;
  box-shadow: 0 0 24px rgba(55, 200, 255, 0.35);
}
#start-btn:hover { background: linear-gradient(180deg, #2a74bd, #17507f); }
.title-foot { margin-top: 14px; font-size: 11.5px; color: #7d9cbd; letter-spacing: 0.1em; }

/* Modals */
.modal {
  position: fixed; z-index: 40; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 430px; max-width: 90vw; max-height: 82vh; overflow-y: auto;
  background: linear-gradient(165deg, rgba(10, 30, 58, 0.97), rgba(5, 16, 34, 0.97));
  border: 1px solid rgba(55, 200, 255, 0.55); border-radius: 14px; padding: 20px 22px;
  display: none; box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6);
}
.modal.visible { display: block; }
.modal h2 { color: #ffd98a; font-size: 18px; letter-spacing: 0.05em; margin-bottom: 10px; }
#trade-wallet { font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: #7ad7ff; margin-bottom: 12px; }
.trade-btn {
  display: flex; justify-content: space-between; width: 100%; margin-top: 8px;
  background: rgba(16, 44, 80, 0.9); color: #eaf6ff; border: 1px solid rgba(55, 200, 255, 0.4);
  border-radius: 9px; padding: 11px 14px; font-size: 14.5px; cursor: pointer;
}
.trade-btn span { color: #ffd98a; }
.trade-btn:disabled { opacity: 0.42; cursor: default; }
.trade-btn.leave { border-color: rgba(255, 217, 138, 0.6); margin-top: 16px; justify-content: center; }
.refit-btn {
  display: block; width: 100%; margin-top: 9px; text-align: left; cursor: pointer;
  background: rgba(16, 44, 80, 0.9); color: #eaf6ff; border: 1px solid rgba(183, 140, 255, 0.5);
  border-radius: 9px; padding: 11px 14px;
}
.refit-btn b { display: block; font-size: 15px; color: #cdb4ff; }
.refit-btn span { font-size: 13px; color: #bcd6f2; }
.codex-entry { margin-top: 10px; padding: 9px 11px; background: rgba(10, 26, 50, 0.7); border-left: 3px solid #b78cff; border-radius: 5px; }
.codex-entry b { display: block; font-size: 13.5px; color: #e8e2ff; }
.codex-entry span { font-size: 12.5px; line-height: 1.45; color: #bcd0ea; }
.codex-entry.locked { border-left-color: #3d5a78; opacity: 0.65; }
.codex-hint { margin-top: 12px; font-size: 11px; color: #7d9cbd; text-align: right; }
#end-stats { font-size: 15.5px; line-height: 1.7; color: #eaf6ff; }
#end-stats b { color: #ffd98a; }
