:root {
  --ink: #e9eef2;
  --dim: #8fa3ad;
  --gold: #c8a24a;
  --blood: #b2323a;
  --gas: #6fc3d8;
  --steel: #cfd8dd;
  --panel: rgba(9, 14, 17, .55);
  --edge: rgba(200, 162, 74, .35);
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0b0f12;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ── HUD ──────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; }

.panel {
  position: absolute;
  padding: 14px 16px;
  font-size: 12px;
  letter-spacing: .14em;
}
.bottom-left  { left: 22px;  bottom: 20px; }
.bottom-right { right: 22px; bottom: 20px; text-align: right; }
.top-right    { right: 22px; top: 18px;    text-align: right; }
.top-left     { left: 22px;  top: 18px; }

.meter { margin-bottom: 9px; width: 210px; }
.meter label { display: block; font-size: 10px; color: var(--dim); margin-bottom: 4px; }
.bar {
  height: 7px;
  background: rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 255, 255, .13);
  overflow: hidden;
}
.fill { display: block; height: 100%; width: 100%; transition: width .12s linear; }
.fill.health { background: linear-gradient(90deg, #8e2028, #d8474f); }
.fill.gas    { background: linear-gradient(90deg, #2b7f96, #7fdcf0); }
.fill.blade  { background: linear-gradient(90deg, #6d7a82, #dfe9ee); }
.fill.low    { animation: pulse .55s infinite alternate; }
@keyframes pulse { from { opacity: .45; } to { opacity: 1; } }

.stat { line-height: 1; margin-bottom: 10px; }
.stat span {
  display: block;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .8);
}
.stat label { font-size: 10px; color: var(--dim); }

/* ── ODM gear readout (bottom centre) ─────────────────────────────── */
#gear {
  position: absolute;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 16px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(9, 14, 17, .28), rgba(9, 14, 17, .62));
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 2px;
  backdrop-filter: blur(3px);
}

.gauges { display: grid; gap: 8px; width: min(38vw, 300px); }
.gauge label {
  display: flex; justify-content: space-between;
  font-size: 9px; letter-spacing: .22em; color: var(--dim);
  margin-bottom: 4px;
}
.gauge output { color: var(--ink); letter-spacing: .06em; }
.bar.tall { height: 11px; }

.hook {
  position: relative;
  width: 64px; padding: 7px 4px 6px;
  text-align: center; line-height: 1.15;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .38);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.hook b {
  display: block; font-size: 15px; font-weight: 700;
  color: var(--steel); letter-spacing: .04em;
}
.hook em { display: block; font-size: 8px; font-style: normal; color: #5f7078; letter-spacing: .2em; }
.hook .state {
  display: block; margin-top: 4px;
  font-size: 8px; letter-spacing: .14em; color: var(--dim);
}
/* the little cable stub that lights up when anchored */
.hook .cable {
  position: absolute; left: 50%; top: -9px;
  width: 1px; height: 8px; margin-left: -.5px;
  background: rgba(255, 255, 255, .16);
  transition: background .12s, box-shadow .12s, height .12s;
}

.hook.on {
  background: rgba(111, 195, 216, .18);
  border-color: var(--gas);
  box-shadow: 0 0 14px rgba(111, 195, 216, .35);
}
.hook.on b { color: #cdf1fa; }
.hook.on .state { color: var(--gas); }
.hook.on .cable { background: var(--gas); height: 13px; box-shadow: 0 0 7px var(--gas); }

.hook.lock {
  background: rgba(200, 162, 74, .2);
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(200, 162, 74, .45);
  animation: lockPulse .9s ease-in-out infinite alternate;
}
.hook.lock b { color: #f6e4b4; }
.hook.lock .state { color: var(--gold); }
.hook.lock .cable { background: var(--gold); height: 15px; box-shadow: 0 0 8px var(--gold); }
@keyframes lockPulse {
  from { box-shadow: 0 0 10px rgba(200, 162, 74, .3); }
  to   { box-shadow: 0 0 22px rgba(200, 162, 74, .6); }
}

#view-mode { font-size: 10px; color: var(--dim); }
#view-mode b { color: var(--gold); }

#compass { opacity: .85; }
#radar { display: block; }

/* Crosshair */
#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  transition: transform .12s ease-out, opacity .12s;
}
#crosshair i {
  position: absolute; background: rgba(255, 255, 255, .8);
  box-shadow: 0 0 4px rgba(0, 0, 0, .9);
}
#crosshair i:nth-child(1) { left: 50%; top: 0;  width: 1px; height: 9px; margin-left: -.5px; }
#crosshair i:nth-child(2) { left: 50%; bottom: 0; width: 1px; height: 9px; margin-left: -.5px; }
#crosshair i:nth-child(3) { top: 50%; left: 0;  height: 1px; width: 9px; margin-top: -.5px; }
#crosshair i:nth-child(4) { top: 50%; right: 0; height: 1px; width: 9px; margin-top: -.5px; }
#crosshair b {
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 2px; margin: -1px 0 0 -1px;
  background: var(--gold); border-radius: 50%;
}
/* Over a nape: the reticle flares red and rotates into a target. */
#crosshair.locked i { background: var(--blood); }
#crosshair.locked b { background: var(--blood); }
#crosshair.locked { transform: scale(1.4) rotate(45deg); }
/* Right mouse held — the camera has the mouse, so the reticle greys out. */
#crosshair.camlock { opacity: .4; }

#hit-marker {
  position: absolute; left: 50%; top: 50%;
  width: 28px; height: 28px; margin: -14px 0 0 -14px;
  opacity: 0; transform: scale(1.6);
}
#hit-marker::before, #hit-marker::after {
  content: ""; position: absolute; left: 50%; top: 0;
  width: 2px; height: 100%; background: #fff; margin-left: -1px;
}
#hit-marker::before { transform: rotate(45deg); }
#hit-marker::after  { transform: rotate(-45deg); }
#hit-marker.show { animation: hm .28s ease-out; }
@keyframes hm {
  from { opacity: 1; transform: scale(.55); }
  to   { opacity: 0; transform: scale(1.5); }
}

#vignette {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(150, 20, 26, .85) 100%);
  transition: opacity .25s;
}
#speedlines {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(255, 255, 255, .16) 78%, transparent 100%);
  mix-blend-mode: screen;
  transition: opacity .2s;
}

#toast {
  /* Sits below the tutorial panel and objective line so they never collide. */
  position: absolute; left: 50%; top: 41%;
  transform: translateX(-50%);
  font-size: 15px; letter-spacing: .3em;
  color: var(--gold); text-shadow: 0 2px 12px #000;
  opacity: 0; transition: opacity .3s;
}
#toast.show { opacity: 1; }

/* ── Overlay / cards ──────────────────────────────────────────────── */
#overlay {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 35%, #16202608, #05080ad9 70%), #05080a99;
  backdrop-filter: blur(6px);
  z-index: 10;
}
#overlay.hidden { display: none; }

.card {
  width: min(620px, 92vw);
  max-height: 92vh; overflow-y: auto;
  padding: 34px 38px;
  background: linear-gradient(180deg, rgba(16, 22, 26, .96), rgba(9, 12, 15, .97));
  border: 1px solid var(--edge);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .75), inset 0 1px 0 rgba(255, 255, 255, .05);
  text-align: center;
}

h1 {
  /* Scales with the card so a long title can't overflow the border. */
  font-size: clamp(22px, 5.4vw, 42px);
  letter-spacing: .24em; font-weight: 700;
  color: var(--gold); text-indent: .24em;
  text-shadow: 0 3px 22px rgba(200, 162, 74, .25);
}
h2 { font-size: 26px; letter-spacing: .3em; text-indent: .3em; }
h2.danger { color: var(--blood); }
.sub { color: var(--dim); font-size: 13px; margin: 10px 0 22px; letter-spacing: .06em; }

.keys {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 7px 18px; text-align: left; margin-bottom: 20px;
}
.keys div { display: flex; align-items: baseline; gap: 10px; font-size: 12px; }
.keys b {
  min-width: 74px; color: var(--gold); font-size: 11px;
  letter-spacing: .1em; border: 1px solid var(--edge);
  padding: 3px 6px; text-align: center; background: rgba(200, 162, 74, .07);
}
.keys span { color: var(--dim); }

.tip {
  font-size: 12px; color: #a9bcc6; line-height: 1.65;
  background: rgba(178, 50, 58, .08);
  border-left: 2px solid var(--blood);
  padding: 10px 14px; text-align: left; margin-bottom: 24px;
}
.tip b { color: var(--blood); }

button {
  font-family: var(--font); font-size: 13px; letter-spacing: .26em;
  padding: 13px 30px; cursor: pointer; border: 1px solid var(--edge);
  background: transparent; color: var(--ink);
  transition: background .15s, color .15s, transform .1s;
  margin: 4px;
}
button:hover { background: var(--gold); color: #10161a; }
button:active { transform: translateY(1px); }
button.primary { background: rgba(200, 162, 74, .16); }
button.ghost { border-color: rgba(255, 255, 255, .15); color: var(--dim); font-size: 11px; padding: 10px 22px; }

.settings { text-align: left; margin: 6px 0 22px; display: grid; gap: 13px; }
.settings label { display: block; font-size: 11px; color: var(--dim); letter-spacing: .12em; }
.settings label.row { display: flex; align-items: center; gap: 9px; }
.settings output { float: right; color: var(--gold); }
.settings input[type=range] { width: 100%; margin-top: 6px; accent-color: var(--gold); }
.settings input[type=checkbox] { accent-color: var(--gold); width: 15px; height: 15px; }

.loadbar {
  height: 3px; background: rgba(255, 255, 255, .1);
  overflow: hidden; margin-top: 8px;
}
.loadbar span { display: block; height: 100%; width: 0%; background: var(--gold); transition: width .2s; }

.score { margin: 18px 0 26px; }
.score span { display: block; font-size: 60px; font-weight: 700; color: var(--gold); line-height: 1; }
.score label { font-size: 10px; color: var(--dim); letter-spacing: .3em; }

.fine { font-size: 10px; color: #5d6f78; margin-top: 14px; letter-spacing: .08em; }

@media (max-width: 620px) {
  .keys { grid-template-columns: 1fr; }
  .panel { transform: scale(.85); }
  #gear { gap: 9px; padding: 9px 10px; bottom: 12px; }
  #gear .hook { width: 52px; }
  .gauges { width: 46vw; }
}

/* ── menu: mode + map pickers ─────────────────────────────────────── */
.menu-block { text-align: left; margin-bottom: 16px; }
.menu-block > label {
  display: block; font-size: 10px; letter-spacing: .3em;
  color: var(--dim); margin-bottom: 7px;
}
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick {
  margin: 0; padding: 13px 6px; font-size: 12px; letter-spacing: .16em;
  border: 1px solid rgba(255, 255, 255, .14); background: rgba(0, 0, 0, .3);
}
.pick b { color: var(--gold); font-size: 11px; margin-left: 3px; }
.pick.selected {
  border-color: var(--gold); background: rgba(200, 162, 74, .18); color: var(--ink);
}
.pick.selected:hover { background: rgba(200, 162, 74, .3); color: var(--ink); }
.pick[data-locked] { opacity: .32; cursor: not-allowed; }
.pick[data-locked]:hover { background: rgba(0, 0, 0, .3); color: var(--ink); }

/* ── tutorial: instructor dialogue ────────────────────────────────── */
#tutorial {
  position: absolute; left: 50%; bottom: 132px;
  transform: translateX(-50%);
  width: min(720px, 92vw);
  display: flex; align-items: flex-end; gap: 0;
}
#tutorial.pop { animation: tutPop .28s ease-out; }
@keyframes tutPop {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#tutorial .portrait {
  width: 104px; flex: none;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .7));
}
#tutorial .portrait svg { display: block; width: 100%; height: auto; }

#tutorial .dbox {
  flex: 1; margin-left: -6px;
  background: rgba(10, 14, 18, .93);
  border: 2px solid var(--gold);
}
#tutorial.done .dbox { border-color: #4bd07a; }

.nameplate {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 14px;
  background: rgba(200, 162, 74, .16);
  border-bottom: 1px solid rgba(200, 162, 74, .4);
  font-size: 13px; letter-spacing: .26em; color: var(--gold); font-weight: 700;
}
.nameplate span { font-size: 9px; letter-spacing: .2em; color: var(--dim); font-weight: 400; }

.dbody { padding: 12px 16px 14px; text-align: left; }
#tut-title {
  font-size: 15px; letter-spacing: .2em; color: var(--ink);
  font-weight: 700; margin-bottom: 6px;
}
#tut-note { font-size: 13px; color: #ccd8de; line-height: 1.55; margin-bottom: 10px; }
#tut-hint {
  display: inline-block; padding: 5px 13px;
  border: 1px solid var(--edge); background: rgba(200, 162, 74, .12);
  color: var(--gold); font-size: 11px; letter-spacing: .18em;
}

#objective {
  position: absolute; left: 50%; top: 30%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: .2em; color: var(--gold);
  text-shadow: 0 2px 10px #000;
}
#objective i {
  width: 7px; height: 7px; background: var(--gold);
  transform: rotate(45deg);
  animation: objPulse 1.1s ease-in-out infinite alternate;
}
@keyframes objPulse { from { opacity: .35; } to { opacity: 1; } }

/* ── live session ─────────────────────────────────────────────────── */
#session { margin-bottom: 8px; font-size: 10px; letter-spacing: .18em; }
.sess-row { color: var(--ink); font-size: 12px; }
.sess-row span { color: var(--gold); font-weight: 700; }
.sess-sub { color: var(--dim); font-size: 9px; margin-top: 2px; }
.sess-sub b { color: var(--gold); }

.stat.small span { font-size: 22px; }

#feed {
  position: absolute; right: 22px; top: 92px;
  list-style: none; text-align: right;
  font-size: 11px; letter-spacing: .1em;
}
#feed li {
  margin-bottom: 4px; padding: 4px 9px;
  background: rgba(9, 14, 17, .55);
  border-right: 2px solid var(--dim);
  color: #c6d3da;
  animation: feedIn .25s ease-out;
}
#feed li.titan  { border-right-color: var(--blood); }
#feed li.player { border-right-color: var(--gold); color: #f0e0b8; }
#feed li.join   { border-right-color: var(--gas); }
#feed li.fade   { opacity: 0; transition: opacity .5s; }
@keyframes feedIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; } }

#playerlist {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  min-width: min(520px, 88vw);
  padding: 20px 24px;
  background: rgba(8, 12, 15, .92);
  border: 1px solid var(--edge);
}
#playerlist h4 {
  font-size: 11px; letter-spacing: .3em; color: var(--gold);
  margin-bottom: 12px; font-weight: 700;
}
#playerlist table { width: 100%; border-collapse: collapse; font-size: 12px; }
#playerlist th {
  text-align: left; font-size: 9px; letter-spacing: .2em;
  color: var(--dim); font-weight: 400; padding-bottom: 7px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
#playerlist td { padding: 6px 0; color: #cfd8dd; }
#playerlist td:first-child { display: flex; align-items: center; gap: 8px; }
#playerlist i { width: 8px; height: 8px; display: inline-block; }
#playerlist tr.me td { color: var(--gold); }
#playerlist tr.down td { opacity: .4; }
