@font-face {
  font-family: 'VT323';
  src: url('./vt323-latin.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --nyx-bg: #05020d;
  --nyx-cyan: #00ffe0;
  --nyx-blue: #00aaff;
  --nyx-magenta: #ff2bf2;
  --nyx-green: #00ff7f;
  --nyx-red: #ff315a;
  --nyx-yellow: #ffe95c;
  --nyx-panel: rgba(5, 2, 13, 0.84);
  --nyx-border: rgba(0, 255, 224, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--nyx-cyan);
  background:
    linear-gradient(rgba(255, 43, 242, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 224, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 20% 15%, rgba(0, 255, 224, 0.16), transparent 38%),
    radial-gradient(circle at 82% 76%, rgba(255, 43, 242, 0.13), transparent 35%),
    var(--nyx-bg);
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
  font-family: 'VT323', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.35rem;
  line-height: 1.45;
  overflow-x: hidden;
  text-shadow: 0 0 8px rgba(0, 255, 224, 0.55);
}

a {
  color: var(--nyx-cyan);
}

.nyx-shell {
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.nyx-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.nyx-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nyx-brand img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.nyx-title {
  margin: 0;
  color: #f4fbff;
  font-size: clamp(1.9rem, 6vw, 3.8rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nyx-subtitle {
  margin: -6px 0 0;
  color: var(--nyx-green);
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nyx-link-button,
.nyx-back,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--nyx-border);
  border-radius: 4px;
  color: var(--nyx-cyan);
  background: rgba(0, 255, 224, 0.06);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 0 16px rgba(0, 255, 224, 0.08);
}

.nyx-link-button:hover,
.nyx-back:hover,
button:hover {
  border-color: var(--nyx-magenta);
  color: #ffffff;
  background: rgba(255, 43, 242, 0.12);
}

.nyx-panel,
#game-container,
#output {
  border: 1px solid var(--nyx-border);
  background: var(--nyx-panel);
  box-shadow: 0 0 28px rgba(0, 255, 224, 0.14), inset 0 0 22px rgba(255, 43, 242, 0.08);
}

#game-wrapper {
  position: relative;
  width: 100%;
}

#game-container {
  padding: 14px;
}

#hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(0, 255, 127, 0.65);
  color: var(--nyx-green);
  font-size: 1.05rem;
}

#hud span {
  white-space: pre;
}

.crt-container {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 12px solid #101018;
  border-radius: 8px;
  background: #000;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.86), 0 18px 50px rgba(0, 0, 0, 0.65);
}

#game-canvas,
#raycaster-view {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  image-rendering: pixelated;
}

.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.18) 50%),
    radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.28) 100%);
  background-size: 100% 4px, 100% 100%;
}

#instructions {
  margin-top: 12px;
  color: var(--nyx-magenta);
  text-align: center;
}

#game-over-ui {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(5, 2, 13, 0.82);
  text-align: center;
}

#game-over-title {
  color: var(--nyx-red);
  font-size: clamp(2rem, 8vw, 4rem);
}

.hidden {
  display: none !important;
}

#output {
  min-height: min(62vh, 560px);
  max-height: 68vh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 8px;
}

#input-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

#input-label {
  color: var(--nyx-magenta);
}

#command-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--nyx-border);
  border-radius: 4px;
  padding: 9px 12px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.38);
  font: inherit;
  outline: none;
}

#touch-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 18px;
  z-index: 30;
  display: none;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
}

#touch-dpad {
  display: grid;
  grid-template-areas: '. up .' 'left . right' '. down .';
  gap: 6px;
}

#touch-jump {
  grid-area: up;
}

#touch-left {
  grid-area: left;
}

#touch-right {
  grid-area: right;
}

#touch-down {
  grid-area: down;
}

.touch-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border: 1px solid var(--nyx-border);
  border-radius: 12px;
  color: var(--nyx-cyan);
  background: rgba(5, 2, 13, 0.72);
  pointer-events: auto;
  user-select: none;
}

#touch-shoot {
  align-self: end;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  color: var(--nyx-green);
}

@media (hover: none), (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
}

@media (max-width: 680px) {
  .nyx-shell {
    width: min(100vw - 18px, 520px);
    padding-top: 14px;
  }

  .nyx-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nyx-brand img {
    width: 58px;
    height: 58px;
  }

  #hud {
    font-size: 0.82rem;
  }
}
