:root {
  --vc-pink: #ff3ea5;
  --vc-pink-deep: #ff1f7a;
  --vc-cyan: #20e9ff;
  --vc-purple: #6f2dbd;
  --vc-orange: #ff8a3d;
  --vc-yellow: #ffe85c;
  --vc-bg: #0c0420;
  --vc-glass: rgba(20, 6, 40, 0.55);
  --vc-border: rgba(255, 62, 165, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: "Orbitron", "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

.hidden {
  display: none !important;
}

/* ---------- Loader ---------- */
#loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
      ellipse at center bottom,
      #ff3ea5 0%,
      #6f2dbd 35%,
      #1a0640 75%,
      #000 100%
    );
  z-index: 100;
}

.loader-inner {
  text-align: center;
  width: 80%;
  max-width: 520px;
}

.logo {
  font-family: "Monoton", "Orbitron", sans-serif;
  font-size: 96px;
  line-height: 1;
  margin: 0;
  letter-spacing: 6px;
  background: linear-gradient(180deg, #fff 0%, #ff3ea5 60%, #20e9ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(255, 62, 165, 0.7),
    0 0 60px rgba(32, 233, 255, 0.4);
}

.logo.big {
  font-size: 168px;
}

.tagline {
  margin: 8px 0 30px;
  font-size: 14px;
  letter-spacing: 8px;
  text-transform: uppercase;
  color: #fff;
  opacity: 0.8;
}

.bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--vc-cyan), var(--vc-pink));
  transition: width 0.2s ease;
  box-shadow: 0 0 12px var(--vc-pink);
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  letter-spacing: 3px;
  opacity: 0.7;
}

/* ---------- Start ---------- */
#start {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
      ellipse at center bottom,
      rgba(255, 62, 165, 0.55) 0%,
      rgba(111, 45, 189, 0.7) 35%,
      rgba(12, 4, 32, 0.95) 75%,
      #000 100%
    );
  z-index: 90;
  backdrop-filter: blur(4px);
}

.start-inner {
  text-align: center;
  width: 90%;
  max-width: 640px;
}

.controls-card {
  margin: 24px auto;
  padding: 18px 24px;
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 14px;
  text-align: left;
  box-shadow: 0 0 40px rgba(255, 62, 165, 0.25),
    inset 0 0 30px rgba(32, 233, 255, 0.1);
}

.controls-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--vc-cyan);
}

.controls-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  font-size: 13px;
}

.controls-card b {
  color: var(--vc-pink);
  letter-spacing: 1px;
}

.quality {
  margin: 12px auto 14px;
  padding: 12px 16px;
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 12px;
  text-align: center;
}

.qlbl {
  display: block;
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--vc-cyan);
  margin-bottom: 8px;
}

.qrow {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.q-btn {
  padding: 8px 14px;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 3px;
  color: #fff;
  background: rgba(255, 62, 165, 0.18);
  border: 1px solid rgba(255, 62, 165, 0.5);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.q-btn:hover {
  background: rgba(255, 62, 165, 0.35);
}

.q-btn.selected {
  background: linear-gradient(90deg, var(--vc-pink), var(--vc-purple));
  border-color: #fff;
  box-shadow: 0 0 14px rgba(255, 62, 165, 0.55);
}

.qhint {
  margin: 8px 0 0;
  font-size: 10px;
  letter-spacing: 2px;
  opacity: 0.6;
}

#play-btn {
  margin-top: 10px;
  padding: 14px 28px;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 4px;
  color: #fff;
  background: linear-gradient(90deg, var(--vc-pink), var(--vc-purple));
  border: 2px solid #fff;
  border-radius: 999px;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 24px rgba(255, 62, 165, 0.6),
    0 0 50px rgba(32, 233, 255, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#play-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 30px rgba(255, 62, 165, 0.9),
    0 0 80px rgba(32, 233, 255, 0.5);
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  font-family: "Orbitron", sans-serif;
}

#hud-top-left {
  position: absolute;
  top: 16px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  font-family: "Monoton", sans-serif;
  font-size: 32px;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #fff 0%, var(--vc-pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 14px rgba(255, 62, 165, 0.7);
}

#status-line {
  font-size: 11px;
  letter-spacing: 3px;
  padding: 6px 10px;
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 6px;
  color: var(--vc-cyan);
}

#hud-top-right {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
}

#hud-top-right .stat,
#hud-top-right .clock {
  padding: 8px 12px;
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 6px;
  font-size: 13px;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 62, 165, 0.5);
}

#hud-top-right .lbl {
  color: var(--vc-cyan);
  margin-right: 6px;
  font-size: 10px;
  letter-spacing: 3px;
}

#hud-bottom-left {
  position: absolute;
  bottom: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-lbl {
  width: 60px;
  font-size: 10px;
  letter-spacing: 3px;
  color: #fff;
  opacity: 0.85;
}

.bar.small {
  width: 200px;
  height: 12px;
  background: rgba(0, 0, 0, 0.55);
  border-color: var(--vc-border);
}

.bar-fill.health {
  background: linear-gradient(90deg, #ff3e3e, #ff8a3d, var(--vc-yellow));
  box-shadow: 0 0 10px rgba(255, 138, 61, 0.7);
  width: 100%;
}

.bar-fill.armor {
  background: linear-gradient(90deg, var(--vc-cyan), #5cf2ff);
  box-shadow: 0 0 10px rgba(32, 233, 255, 0.7);
  width: 50%;
}

#hud-bottom-right {
  position: absolute;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

#speedo {
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 10px;
  padding: 10px 16px;
  text-align: right;
  min-width: 160px;
  box-shadow: 0 0 18px rgba(255, 62, 165, 0.35);
}

.speedo-num {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 38px;
  letter-spacing: 2px;
  color: #fff;
  line-height: 1;
  text-shadow: 0 0 14px var(--vc-pink);
}

.speedo-num .unit {
  font-size: 12px;
  margin-left: 6px;
  color: var(--vc-cyan);
  letter-spacing: 4px;
}

.gear {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--vc-cyan);
}

#minimap {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--vc-border);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 62, 165, 0.45),
    inset 0 0 24px rgba(0, 0, 0, 0.5);
}

.prompt {
  position: absolute;
  bottom: 35%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 8px var(--vc-pink);
  box-shadow: 0 0 20px rgba(255, 62, 165, 0.5);
  animation: pulse 1.4s ease-in-out infinite;
}

.prompt b {
  color: var(--vc-cyan);
  font-size: 16px;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, 0) scale(1); }
  50% { transform: translate(-50%, -4px) scale(1.04); }
}

.toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 22px;
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 10px;
  font-size: 13px;
  letter-spacing: 3px;
  color: #fff;
  box-shadow: 0 0 24px rgba(32, 233, 255, 0.5);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Error log overlay (for runtime debugging) */
.errlog {
  position: fixed;
  left: 12px;
  bottom: 12px;
  max-width: 60vw;
  max-height: 35vh;
  overflow: auto;
  background: rgba(40, 6, 20, 0.85);
  color: #ffd2e3;
  border: 1px solid #ff3ea5;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  z-index: 200;
  box-shadow: 0 0 24px rgba(255, 62, 165, 0.4);
}
.errlog .row {
  margin: 0 0 4px;
  word-break: break-word;
}
.errlog .row b {
  color: #ff8ed6;
}

/* Crosshair (when on foot first person) */
.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px var(--vc-cyan);
  opacity: 0.85;
}

/* ---------- AI Game Master Console ---------- */
.agent-console {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 720px;
  max-width: calc(100vw - 32px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--vc-glass);
  border: 1px solid var(--vc-border);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 28px rgba(255, 62, 165, 0.35),
    0 0 64px rgba(32, 233, 255, 0.18),
    inset 0 0 18px rgba(111, 45, 189, 0.18);
  pointer-events: auto;
  font-family: "Orbitron", "Segoe UI", system-ui, sans-serif;
  color: #fff;
}

.ac-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ac-title {
  font-family: "Monoton", "Orbitron", sans-serif;
  font-size: 22px;
  letter-spacing: 4px;
  line-height: 1;
  background: linear-gradient(
    90deg,
    var(--vc-pink) 0%,
    #fff 50%,
    var(--vc-cyan) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 14px rgba(255, 62, 165, 0.45);
}

.ac-status {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(84, 230, 164, 0.55);
  color: #54e6a4;
  text-shadow: 0 0 8px rgba(84, 230, 164, 0.55);
  transition: color 0.2s ease, border-color 0.2s ease,
    text-shadow 0.2s ease;
}

.ac-status.offline {
  border-color: rgba(255, 90, 140, 0.65);
  color: #ff5a8c;
  text-shadow: 0 0 8px rgba(255, 90, 140, 0.55);
}

.ac-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 62, 165, 0.18);
  border: 1px solid var(--vc-border);
  color: #fff;
  font-family: "Orbitron", sans-serif;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}

.ac-close:hover {
  background: rgba(255, 62, 165, 0.4);
  transform: scale(1.05);
}

.ac-input {
  width: 100%;
  resize: vertical;
  min-height: 52px;
  max-height: 220px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 62, 165, 0.5);
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  caret-color: var(--vc-pink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.3px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ac-input:focus {
  border-color: var(--vc-pink);
  box-shadow: 0 0 0 1px var(--vc-pink), 0 0 18px rgba(255, 62, 165, 0.4);
}

.ac-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
}

.ac-input.pending {
  border-color: var(--vc-cyan);
  background-image: linear-gradient(
    90deg,
    rgba(32, 233, 255, 0) 0%,
    rgba(32, 233, 255, 0.22) 50%,
    rgba(32, 233, 255, 0) 100%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: ac-shimmer 1.2s linear infinite;
  box-shadow: 0 0 0 1px var(--vc-cyan), 0 0 18px rgba(32, 233, 255, 0.5);
}

@keyframes ac-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.ac-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ac-hint {
  flex: 1 1 auto;
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

.ac-send {
  padding: 8px 18px;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 3px;
  color: #fff;
  background: linear-gradient(90deg, var(--vc-pink), var(--vc-purple));
  border: 1px solid #fff;
  border-radius: 999px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 18px rgba(255, 62, 165, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    opacity 0.12s ease;
}

.ac-send:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 0 26px rgba(255, 62, 165, 0.75);
}

.ac-send:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
  box-shadow: 0 0 10px rgba(255, 62, 165, 0.3);
}

.ac-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.ac-history:empty {
  display: none;
}

.ac-history-item {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.38);
  border-left: 2px solid var(--vc-pink);
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.ac-history-item.error {
  border-left-color: #ff5a8c;
}

.ac-history-prompt {
  color: var(--vc-cyan);
  text-shadow: 0 0 6px rgba(32, 233, 255, 0.45);
  word-break: break-word;
}

.ac-history-narration {
  color: #fff;
  opacity: 0.92;
  margin-top: 2px;
  word-break: break-word;
}

.ac-history-narration.ac-history-error {
  color: #ff8ed6;
  opacity: 1;
}

.ac-history-ts {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 9px;
  letter-spacing: 1px;
}

.ac-history::-webkit-scrollbar {
  width: 6px;
}

.ac-history::-webkit-scrollbar-thumb {
  background: rgba(255, 62, 165, 0.45);
  border-radius: 3px;
}

.ac-history::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}
