@font-face {
  font-family: 'Clacon2';
  src: url('assets/fonts/clacon2.ttf') format('truetype');
  font-display: swap;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Clacon2', 'Courier New', monospace;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

::selection { background: transparent; color: inherit; }

input, textarea {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
}

input::selection, textarea::selection {
  background: #c23b3b;
  color: #150808;
}

#scene {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  display: block;
}

/* subtle CRT scanline + vignette overlay for retro feel */
#crt {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0.18) 0px,
      rgba(0,0,0,0.18) 1px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0) 3px
    );
  box-shadow: inset 0 0 160px rgba(0,0,0,0.85);
  mix-blend-mode: multiply;
}

#crosshair {
  position: fixed;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  background: rgba(220,60,60,0.85);
  z-index: 11;
  pointer-events: none;
}

/* ---------- generic full screen menu ---------- */
.screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #050002;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.hidden { display: none !important; }

#startBox { text-align: center; color: #c23b3b; }

#startBox h1 {
  font-size: 62px;
  text-align: center;
  letter-spacing: 14px;
  text-shadow: 0 0 12px #c23b3b, 0 0 30px #4a0505;
  margin-bottom: 30px;
}

.titleBtn {
  display: block;
  width: 220px;
  margin: 10px auto 0;
  padding: 11px 0;
  background: transparent;
  border: 1px solid #6a3a3a;
  color: #d8b9b9;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.titleBtn:hover,
.titleBtn.selected {
  background: #c23b3b;
  border-color: #c23b3b;
  color: #150808;
}

#titleEnterBtn {
  color: #e8caca;
  border-color: #c23b3b;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* ---------- locker ---------- */
#lockerBox {
  width: 560px;
  text-align: center;
  color: #d8b9b9;
}

#lockerBox h2 {
  color: #c23b3b;
  letter-spacing: 8px;
  font-size: 26px;
  margin-bottom: 26px;
  text-shadow: 0 0 10px #4a0505;
}

.lockerLabel {
  display: block;
  font-size: 12px;
  letter-spacing: 2px;
  color: #8a6a6a;
  margin: 14px 0 8px;
  text-align: left;
}

#nameInput {
  width: 100%;
  background: #150808;
  border: 1px solid #5a2626;
  color: #e8caca;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 8px 10px;
  outline: none;
}

#nameInput:focus { border-color: #c23b3b; }

/* ---------- color picker ---------- */
#colorPicker {
  display: flex;
  gap: 18px;
  text-align: left;
  align-items: flex-start;
}

#basicColorsPanel { width: 210px; flex-shrink: 0; }

.pickerLabel {
  font-size: 11px;
  letter-spacing: 2px;
  color: #8a6a6a;
  margin: 10px 0 6px;
}

.colorGrid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid transparent;
  cursor: pointer;
  box-sizing: border-box;
  background: #150808;
}

.swatch.empty {
  border: 1px dashed #5a2626;
  background: transparent;
}

.swatch.selected {
  border-color: #ffffff;
  box-shadow: 0 0 6px #ffffff;
}

#defineCustomBtn {
  margin-top: 12px;
  width: 100%;
  padding: 7px;
  background: transparent;
  border: 1px solid #6a3a3a;
  color: #d8b9b9;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#defineCustomBtn:hover {
  background: #c23b3b;
  border-color: #c23b3b;
  color: #150808;
}

#customPanel { flex: 1; }

#pickerTop {
  display: flex;
  gap: 10px;
}

#svSquareWrap {
  position: relative;
  width: 180px;
  height: 160px;
  cursor: crosshair;
  border: 1px solid #5a2626;
}

#svSquare { width: 100%; height: 100%; }

#svMarker {
  position: absolute;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border: 1px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 2px #000;
  pointer-events: none;
}

#hueSliderWrap {
  position: relative;
  width: 20px;
  height: 160px;
  cursor: ns-resize;
  border: 1px solid #5a2626;
}

#hueSlider { width: 100%; height: 100%; }

#hueMarker {
  position: absolute;
  left: -3px; right: -3px;
  height: 4px;
  margin-top: -2px;
  border: 1px solid #fff;
  box-shadow: 0 0 2px #000;
  pointer-events: none;
  background: rgba(255,255,255,0.3);
}

#pickerBottom {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  align-items: flex-start;
}

#pickerPreviewWrap {
  width: 60px;
  height: 42px;
  border: 1px solid #5a2626;
  flex-shrink: 0;
}

#pickerPreview { width: 100%; height: 100%; }

#pickerFields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  flex: 1;
}

.fieldRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 1px;
  color: #8a6a6a;
}

.fieldRow input {
  width: 52px;
  background: #150808;
  border: 1px solid #5a2626;
  color: #e8caca;
  font-family: inherit;
  font-size: 12px;
  padding: 3px 5px;
  outline: none;
}

.fieldRow input:focus { border-color: #c23b3b; }

.rgbRow { grid-column: 2; }
.fieldRow:nth-child(1) { grid-row: 1; grid-column: 1; }
.fieldRow:nth-child(2) { grid-row: 2; grid-column: 1; }
.fieldRow:nth-child(3) { grid-row: 3; grid-column: 1; }
.fieldRow:nth-child(4) { grid-row: 1; }
.fieldRow:nth-child(5) { grid-row: 2; }
.fieldRow:nth-child(6) { grid-row: 3; }

#addCustomBtn {
  margin-top: 12px;
  width: 100%;
  padding: 7px;
  background: transparent;
  border: 1px solid #6a3a3a;
  color: #d8b9b9;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#addCustomBtn:hover {
  background: #c23b3b;
  border-color: #c23b3b;
  color: #150808;
}

#namePreview {
  margin-top: 22px;
  font-size: 20px;
  letter-spacing: 2px;
  min-height: 26px;
  text-align: center;
}

#enterWorldBtn {
  margin-top: 26px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid #c23b3b;
  color: #e8caca;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#enterWorldBtn:hover {
  background: #c23b3b;
  color: #150808;
}

/* ---------- options ---------- */
#optionsBox {
  width: 380px;
  text-align: center;
  color: #d8b9b9;
}

#optionsBox h2 {
  color: #c23b3b;
  letter-spacing: 8px;
  font-size: 26px;
  margin-bottom: 26px;
  text-shadow: 0 0 10px #4a0505;
}

.optRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  text-align: left;
}

.optLabel {
  font-size: 13px;
  letter-spacing: 2px;
  color: #d8b9b9;
  width: 130px;
  flex-shrink: 0;
}

.toggleBtn {
  width: 70px;
  padding: 6px 0;
  background: transparent;
  border: 1px solid #6a3a3a;
  color: #d8b9b9;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.toggleBtn:hover {
  border-color: #c23b3b;
}

.toggleBtn.on {
  background: #c23b3b;
  border-color: #c23b3b;
  color: #150808;
}

.sliderRow input[type="range"] {
  flex: 1;
  accent-color: #c23b3b;
}

.optValue {
  width: 42px;
  text-align: right;
  font-size: 12px;
  color: #8a6a6a;
  flex-shrink: 0;
}

#optionsBackBtn {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid #c23b3b;
  color: #e8caca;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#optionsBackBtn:hover {
  background: #c23b3b;
  color: #150808;
}

/* ---------- fps / mem stats overlay ---------- */
#statsOverlay {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 25;
  color: #9fe89f;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 1px;
  text-shadow: 0 0 4px #000;
  pointer-events: none;
  white-space: pre;
}

/* ---------- volume osd ---------- */
#volumeOsd {
  position: fixed;
  top: 20px;
  right: 26px;
  z-index: 25;
  pointer-events: none;
  transition: opacity 0.3s ease;
  opacity: 1;
}

#volumeOsd.fade { opacity: 0; }

#volumeBars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 34px;
}

#volumeBars .vbar {
  width: 6px;
  background: #3a2020;
}

#volumeBars .vbar.lit {
  background: #e8caca;
  box-shadow: 0 0 4px #c23b3b;
}

/* ---------- pause ---------- */
#pauseScreen {
  background: rgba(5, 0, 2, 0.82);
  transition: opacity 0.25s ease;
  opacity: 1;
}

#pauseScreen.fading {
  opacity: 0;
}

#pauseBox {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 220px;
}

#pauseBox h2 {
  color: #c23b3b;
  letter-spacing: 8px;
  font-size: 22px;
  margin-bottom: 12px;
  text-shadow: 0 0 10px #4a0505;
}

.pauseBtn {
  padding: 10px;
  background: transparent;
  border: 1px solid #6a3a3a;
  color: #d8b9b9;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.pauseBtn:hover,
.pauseBtn.selected {
  background: #c23b3b;
  border-color: #c23b3b;
  color: #150808;
}

/* ---------- pause controls readout (top right) ---------- */
#pauseControls {
  position: absolute;
  top: 22px;
  right: 26px;
  text-align: right;
  color: rgba(216, 185, 185, 0.6);
  font-size: 12px;
  letter-spacing: 1px;
  line-height: 1.9;
  text-shadow: 0 0 4px #000;
  opacity: 0;
  transform: translateY(-14px);
}

#pauseControls.show {
  animation: controlsFadeDown 0.5s ease forwards;
}

@keyframes controlsFadeDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- fade transition ---------- */
#transition {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity 0.4s ease;
}

#transition.active {
  opacity: 1;
  pointer-events: auto;
}
