:root {
  --void: #0e0805;
  --deep: #1a0f08;
  --ember: #8b2500;
  --lava: #c43d00;
  --amber: #d4700a;
  --gold: #e8a020;
  --ivory: #f5e6c8;
  --crimson: #7a1518;
  --sienna: #a03020;
  --glow: #ff6a1a;
  --hot: #ffaa44;
  --white: #fdf5e8;
  --theme-glow: #ff6a1a;
  --theme-hot: #ffaa44;
  --theme-amber: #d4700a;
  --theme-particle-a: #ff6a1a;
  --theme-particle-b: #e8a020;
  --theme-inst-shadow: rgba(255,170,68,0.9);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  background: var(--void);
  font-family: 'Crimson Pro', serif;
  cursor: none;
}

#canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

#cur-dot, #cur-ring {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
#cur-dot {
  width: 6px; height: 6px;
  background: var(--theme-glow);
  box-shadow: 0 0 10px var(--theme-glow), 0 0 20px var(--theme-amber);
  transition: background 0.4s, box-shadow 0.4s;
}
#cur-ring {
  width: 32px; height: 32px;
  border: 1px solid rgba(232,160,32,0.6);
  transition: width 0.2s, height 0.2s, border-color 0.4s;
}

nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(14,8,5,0.95) 0%, transparent 100%);
}

.back-link {
  font-family: 'Courier Prime', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--hot);
  text-decoration: none;
  opacity: 1;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 0 10px rgba(255,170,68,0.6);
}
.back-link:hover { color: var(--ivory); text-shadow: 0 0 16px rgba(255,170,68,0.9); }

.nav-title {
  font-family: 'Syncopate', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--ivory);
  text-shadow: 0 0 12px rgba(245,230,200,0.5);
}

.nav-tag {
  font-family: 'Courier Prime', monospace;
  font-size: 0.55rem;
  letter-spacing: 0.3em;
  color: var(--hot);
  text-shadow: 0 0 10px rgba(255,170,68,0.6);
}

#hud {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  inset: 0;
}

.hud-corner {
  position: absolute;
  width: 24px; height: 24px;
  opacity: 0.4;
}
.hud-tl { top: 70px; left: 20px; border-top: 1px solid var(--amber); border-left: 1px solid var(--amber); }
.hud-tr { top: 70px; right: 20px; border-top: 1px solid var(--amber); border-right: 1px solid var(--amber); }
.hud-bl { bottom: 20px; left: 20px; border-bottom: 1px solid var(--amber); border-left: 1px solid var(--amber); }
.hud-br { bottom: 20px; right: 20px; border-bottom: 1px solid var(--amber); border-right: 1px solid var(--amber); }

.hud-left {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-right {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
}

.hud-data {
  font-family: 'Courier Prime', monospace;
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  color: #ffcc88;
  opacity: 0.85;
  line-height: 1.8;
  text-shadow: 0 0 8px rgba(255,170,68,0.6);
}
.hud-data span {
  display: block;
  color: #ff8844;
  opacity: 1;
  text-shadow: 0 0 10px rgba(255,106,26,0.8);
}

#instructions {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  text-align: center;
  pointer-events: none;
  width: 90%;
  max-width: 600px;
}

.inst-text {
  font-family: 'Courier Prime', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ffe0a0;
  opacity: 1;
  white-space: normal;
  text-align: center;
  padding: 0 20px;
  line-height: 2;
  text-shadow:
    0 0 6px rgba(255,200,80,0.95),
    0 0 14px rgba(255,140,40,0.8),
    0 0 28px rgba(255,100,20,0.5);
}

.inst-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.inst-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #ffcc66;
  opacity: 0.9;
  box-shadow: 0 0 6px rgba(255,200,80,0.8);
  animation: dotPulse 2s ease infinite;
}
.inst-dot:nth-child(2) { animation-delay: 0.3s; }
.inst-dot:nth-child(3) { animation-delay: 0.6s; }

#shape-controls {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 8px;
  pointer-events: all;
  flex-wrap: wrap;
  justify-content: center;
}

.shape-btn {
  font-family: 'Courier Prime', monospace;
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 8px 16px;
  background: rgba(139,37,0,0.3);
  border: 1px solid rgba(255,170,68,0.6);
  color: var(--hot);
  text-shadow: 0 0 8px rgba(255,170,68,0.4);
  cursor: none;
  transition: all 0.3s ease;
  clip-path: polygon(4px 0%, 100% 0%, calc(100% - 4px) 100%, 0% 100%);
}
.shape-btn:hover, .shape-btn.active {
  background: rgba(212,112,10,0.35);
  border-color: var(--glow);
  color: var(--ivory);
  box-shadow: 0 0 16px rgba(255,106,26,0.4);
}

#control-panel {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: all;
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ctrl-label {
  font-family: 'Courier Prime', monospace;
  font-size: 0.42rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #ffcc88;
  text-shadow: 0 0 6px rgba(255,200,80,0.7);
  opacity: 0.85;
  margin-bottom: 2px;
}

.theme-pills {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-pill {
  font-family: 'Courier Prime', monospace;
  font-size: 0.42rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 5px 10px;
  border: 1px solid;
  background: rgba(0,0,0,0.4);
  cursor: none;
  transition: all 0.25s ease;
  clip-path: polygon(3px 0%, 100% 0%, calc(100% - 3px) 100%, 0% 100%);
}
.theme-pill.ember { border-color: rgba(255,106,26,0.5); color: #ff8844; }
.theme-pill.cyber { border-color: rgba(0,200,255,0.5);  color: #44ddff; }
.theme-pill.acid  { border-color: rgba(80,255,100,0.5);  color: #88ff88; }
.theme-pill.active, .theme-pill:hover {
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 12px currentColor;
  opacity: 1;
}
.theme-pill.ember.active { box-shadow: 0 0 12px rgba(255,106,26,0.8); }
.theme-pill.cyber.active { box-shadow: 0 0 12px rgba(0,200,255,0.8); }
.theme-pill.acid.active  { box-shadow: 0 0 12px rgba(80,255,100,0.8); }

.ctrl-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 2px;
  background: rgba(255,170,68,0.3);
  outline: none;
  border-radius: 2px;
  cursor: none;
}
.ctrl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--theme-glow);
  box-shadow: 0 0 8px var(--theme-glow);
  cursor: none;
}

.count-pills { display: flex; gap: 4px; }

.count-pill {
  font-family: 'Courier Prime', monospace;
  font-size: 0.42rem;
  letter-spacing: 0.1em;
  padding: 5px 8px;
  border: 1px solid rgba(255,170,68,0.4);
  color: #ffaa44;
  background: rgba(0,0,0,0.4);
  cursor: none;
  transition: all 0.25s ease;
  clip-path: polygon(3px 0%, 100% 0%, calc(100% - 3px) 100%, 0% 100%);
}
.count-pill.active, .count-pill:hover {
  background: rgba(255,106,26,0.2);
  border-color: var(--theme-glow);
  color: #fff;
  box-shadow: 0 0 8px rgba(255,106,26,0.5);
}

.ctrl-sep {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,170,68,0.3), transparent);
}

#key-hints {
  position: fixed;
  left: 20px;
  bottom: 100px;
  z-index: 50;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.key-row { display: flex; align-items: center; gap: 6px; }

.key-badge {
  font-family: 'Courier Prime', monospace;
  font-size: 0.4rem;
  letter-spacing: 0.1em;
  padding: 3px 6px;
  border: 1px solid rgba(255,170,68,0.4);
  color: #ffcc88;
  background: rgba(0,0,0,0.5);
  text-shadow: 0 0 6px rgba(255,170,68,0.6);
  line-height: 1;
}

.key-desc {
  font-family: 'Courier Prime', monospace;
  font-size: 0.4rem;
  letter-spacing: 0.15em;
  color: #ffaa44;
  opacity: 0.7;
  text-transform: uppercase;
  text-shadow: 0 0 5px rgba(255,150,40,0.5);
}

#center-title {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  text-align: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1s ease;
}
#center-title.hidden { opacity: 0; }

.ct-eyebrow {
  font-family: 'Courier Prime', monospace;
  font-size: 0.55rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--amber);
  opacity: 0.6;
  margin-bottom: 12px;
}
.ct-main {
  font-family: 'Syncopate', sans-serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 5vw, 4rem);
  color: var(--ivory);
  line-height: 1;
  letter-spacing: 0.05em;
  text-shadow: 0 0 40px rgba(255,106,26,0.4);
}
.ct-main span {
  color: var(--glow);
  display: block;
  text-shadow: 0 0 30px rgba(255,106,26,0.8);
}
.ct-sub {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--ivory);
  opacity: 0.5;
  margin-top: 12px;
  letter-spacing: 0.1em;
}
.ct-hint {
  font-family: 'Courier Prime', monospace;
  font-size: 0.5rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--glow);
  opacity: 0.5;
  margin-top: 24px;
  animation: fadeInOut 2s ease infinite;
}

.explode-ring {
  position: fixed;
  border-radius: 50%;
  border: 1px solid var(--glow);
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -50%) scale(0);
  animation: explodeRing 0.8s ease-out forwards;
}
@keyframes explodeRing {
  0%   { transform: translate(-50%,-50%) scale(0); opacity: 1; width: 10px;  height: 10px; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 0; width: 200px; height: 200px; }
}

.implode-ring {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -50%);
  animation: implodeRing 0.6s ease-in forwards;
}
@keyframes implodeRing {
  0%   { width: 220px; height: 220px; opacity: 0.9; border-width: 2px; }
  60%  { width: 40px;  height: 40px;  opacity: 1;   border-width: 3px; }
  100% { width: 4px;   height: 4px;   opacity: 0;   border-width: 6px; }
}

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.3); }
}
@keyframes fadeInOut {
  0%, 100% { opacity: 0.2; }
  50%       { opacity: 0.7; }
}

.scanlines {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.04) 2px, rgba(0,0,0,0.04) 4px);
}
.vignette {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(14,8,5,0.7) 100%);
}

@media (max-width: 600px) {
  #shape-controls { gap: 5px; bottom: 110px; }
  .shape-btn { padding: 6px 10px; font-size: 0.45rem; }
  .hud-left, .hud-right, #key-hints { display: none; }
  nav { padding: 16px 20px; }
  #control-panel { right: 8px; }
}
