:root {
  --gold: #f4cc62;
  --cyan: #58dcff;
  --violet: #a55cff;
  --ink: #080912;
  --panel: rgba(11, 13, 26, 0.88);
}

* { box-sizing: border-box; }

html, body, #game {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: #f4f1e5;
  background: #05060b;
  font-family: "Courier New", monospace;
}

button, kbd { font: inherit; }
button { cursor: pointer; }

#game { position: relative; }

#glCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(#09091a, #242038);
}

.top-hud {
  position: absolute;
  z-index: 5;
  top: 18px;
  left: 20px;
  right: 20px;
  display: grid;
  grid-template-columns: 58px auto minmax(220px, 1fr) repeat(3, auto);
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 7px 10px;
  border: 1px solid rgba(115, 130, 188, .55);
  background: linear-gradient(90deg, rgba(7, 8, 18, .95), rgba(16, 17, 35, .82));
  box-shadow: 0 8px 30px rgba(0,0,0,.45), inset 0 -3px rgba(0,0,0,.25);
  backdrop-filter: blur(8px);
}

.top-hud img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
}

.identity { display: flex; flex-direction: column; }
.identity span { color: var(--cyan); font-size: 9px; letter-spacing: 3px; }
.identity strong { color: var(--gold); font-size: clamp(12px, 1.5vw, 19px); }

.status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 10px;
}

.health {
  height: 12px;
  padding: 2px;
  border: 1px solid #727998;
  background: #24283d;
}
.health i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #df3d55, #ff7c72);
  box-shadow: 0 0 10px rgba(255,67,90,.6);
  transition: width .2s;
}

.top-hud button,
.start-screen button,
.chapter-screen button {
  padding: 11px 13px;
  border: 1px solid #7882a7;
  color: #f3efdd;
  background: #1c213b;
  font-size: 10px;
  font-weight: bold;
}

.top-hud button:hover,
.start-screen button:hover,
.chapter-screen button:hover {
  color: #121420;
  background: var(--gold);
}

.start-home-link {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  margin-top: 10px;
  padding: 0 14px;
  border: 1px solid #667091;
  color: var(--cyan);
  background: rgba(12, 15, 29, .82);
  font-size: 9px;
  font-weight: bold;
  text-decoration: none;
}

.start-home-link:hover {
  color: #121420;
  background: var(--gold);
}

.quest {
  position: absolute;
  z-index: 4;
  top: 104px;
  right: 20px;
  width: min(320px, 38vw);
  padding: 12px 14px;
  border-left: 3px solid var(--gold);
  background: var(--panel);
  box-shadow: 0 10px 25px rgba(0,0,0,.35);
}
.quest small { color: var(--gold); font-size: 8px; letter-spacing: 2px; }
.quest strong { display: block; margin: 4px 0; font-size: 13px; }
.quest p { margin: 0; color: #b7bdd4; font-size: 10px; line-height: 1.5; }

.location {
  position: absolute;
  top: 112px;
  left: 22px;
  padding-left: 10px;
  border-left: 3px solid var(--cyan);
  text-shadow: 0 2px 4px #000;
}
.location span { display: block; color: var(--cyan); font-size: 10px; letter-spacing: 2px; }
.location strong { font-size: 13px; }

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  opacity: .6;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.crosshair::before, .crosshair::after {
  content: "";
  position: absolute;
  background: #d9f8ff;
}
.crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; }
.crosshair::after { left: 0; top: 8px; width: 18px; height: 2px; }

.interaction {
  position: absolute;
  left: 50%;
  bottom: 120px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  color: var(--gold);
  background: rgba(6,8,16,.88);
  transform: translateX(-50%);
  font-size: 10px;
}
.interaction[hidden] { display: none; }

kbd {
  padding: 3px 6px;
  color: #10121c;
  background: #f3efdd;
  font-weight: bold;
}

.dialog {
  position: absolute;
  z-index: 8;
  left: 8%;
  right: 8%;
  bottom: 7%;
  min-height: 125px;
  padding: 30px 24px 18px;
  border: 1px solid #9da7cf;
  background: rgba(10,12,25,.96);
  box-shadow: 0 0 45px rgba(0,0,0,.7), inset 0 0 35px rgba(74,89,150,.12);
}
.dialog strong {
  position: absolute;
  top: -14px;
  left: 18px;
  padding: 7px 13px;
  color: #11131f;
  background: var(--gold);
}
.dialog p { margin: 0; max-width: 90%; line-height: 1.65; }
.dialog small { position: absolute; right: 15px; bottom: 10px; color: #818aa9; }

.combat-message {
  position: absolute;
  left: 50%;
  top: 28%;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 2px 8px #000;
  transform: translateX(-50%);
  pointer-events: none;
}

.controls {
  position: absolute;
  left: 50%;
  bottom: 18px;
  display: flex;
  gap: 18px;
  padding: 8px 14px;
  color: #9198b3;
  background: rgba(7,8,16,.72);
  transform: translateX(-50%);
  font-size: 9px;
  white-space: nowrap;
}

.start-screen,
.chapter-screen {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 25px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(110,58,168,.22), transparent 35%),
    linear-gradient(rgba(5,6,14,.55), rgba(5,6,14,.92));
  backdrop-filter: blur(5px);
}
.start-screen[hidden], .chapter-screen[hidden], .dialog[hidden] { display: none; }
.start-screen img { width: 150px; height: 150px; object-fit: cover; border-radius: 50%; box-shadow: 0 0 45px rgba(147,80,230,.5); }
.start-screen p, .chapter-screen small { margin: 14px 0 2px; color: var(--gold); letter-spacing: 5px; font-size: 10px; }
.start-screen h1, .chapter-screen h2 {
  margin: 0;
  font-size: clamp(38px, 7vw, 86px);
  line-height: .92;
  text-shadow: 0 5px 0 #111326, 0 0 30px rgba(124,73,198,.6);
}
.start-screen h1 span { color: #b976ff; }
.tagline { margin: 20px 0 24px; color: var(--cyan); letter-spacing: 3px; }
.start-screen button, .chapter-screen button { padding: 15px 25px; color: #11131f; background: var(--gold); font-size: 13px; }
.start-screen > small { margin-top: 15px; color: #757d9b; }
.chapter-screen p { color: #c7ccdd; line-height: 1.7; }

@media (max-width: 720px) {
  .top-hud { grid-template-columns: 44px 1fr; top: 8px; left: 8px; right: 8px; }
  .top-hud img { width: 40px; height: 40px; }
  .status { grid-column: 1 / -1; }
  #legacyButton { display: none; }
  .quest { top: 128px; right: 8px; width: 48vw; }
  .location { top: 132px; left: 10px; }
  .controls { gap: 7px; font-size: 7px; }
  .controls span:nth-child(2), .controls span:nth-child(3) { display: none; }
}
