:root {
  --cyan: #8df6ff;
  --blue: #00a8ff;
  --rose: #ff69b4;
  --violet: #aa7dff;
  --ink: #02030a;
  --glass: rgba(0, 5, 18, 0.58);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: #000;
  color: white;
  font-family: 'Space Mono', monospace;
}

canvas { width: 100%; height: 100%; display: block; }

button, .hud-panel, .dg * {
  font-family: 'Press Start 2P', monospace !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-panel {
  position: absolute;
  z-index: 10;
  color: white;
  background: var(--glass);
  border: 1px solid rgba(141, 246, 255, 0.48);
  box-shadow: 0 0 24px rgba(0,168,255,0.23), inset 0 0 30px rgba(141,246,255,0.04);
  backdrop-filter: blur(8px);
  text-shadow: 0 0 8px var(--blue);
}

#title {
  top: 18px;
  left: 50%;
  width: min(760px, calc(100vw - 40px));
  transform: translateX(-50%);
  padding: 16px 22px;
  text-align: center;
  border-radius: 18px;
}

#title .kicker {
  color: var(--rose);
  font-size: 8px;
  margin-bottom: 10px;
}

#title h1 {
  margin: 0;
  font-size: clamp(15px, 2vw, 26px);
  line-height: 1.35;
}

#title p {
  margin: 10px 0 0;
  color: rgba(255,255,255,0.72);
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.02em;
}

#wall-text {
  left: 20px;
  bottom: 288px;
  width: 330px;
  padding: 18px;
  border-radius: 16px;
  opacity: 0.9;
}

#wall-text p {
  margin: 0;
  font-family: 'Space Mono', monospace;
  text-transform: none;
  line-height: 1.5;
  font-size: 14px;
}

#status {
  bottom: 20px;
  left: 50%;
  width: min(760px, calc(100vw - 40px));
  transform: translateX(-50%);
  padding: 14px 18px;
  border-radius: 16px;
  text-align: center;
  font-size: 10px;
  line-height: 1.6;
}

#status.pulse { animation: statusPulse 1.1s ease; }

#gui-container {
  left: 12px;
  top: 12px;
  padding: 6px;
  border-radius: 12px;
  z-index: 20;
}

#autoRotateBtn, #soundBtn {
  position: absolute;
  top: 18px;
  z-index: 25;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(141, 246, 255, 0.62);
  background: rgba(0, 7, 20, 0.72);
  color: white;
  cursor: pointer;
  text-shadow: 0 0 8px var(--blue);
  box-shadow: 0 0 18px rgba(0,168,255,0.22);
  font-size: 8px;
}

#autoRotateBtn { right: 18px; }
#soundBtn { right: 196px; }
#autoRotateBtn:hover, #soundBtn:hover, #export-panel button:hover { border-color: white; box-shadow: 0 0 28px rgba(141,246,255,0.45); }

#graph-container, #data-table {
  bottom: 70px;
  width: 330px;
  height: 210px;
  border-radius: 16px;
  overflow: hidden;
}

#graph-container { left: 20px; }
#data-table { right: 20px; overflow-y: auto; padding-bottom: 10px; }

#graph-container header, #data-table header {
  padding: 10px 12px;
  color: var(--cyan);
  font-size: 8px;
  border-bottom: 1px solid rgba(141,246,255,0.25);
}

#graphCanvas { width: 100%; height: calc(100% - 30px); }

#data-table table {
  width: 100%;
  border-collapse: collapse;
  color: var(--cyan);
  font-size: 8px;
}

#data-table th, #data-table td {
  padding: 7px 5px;
  border-bottom: 1px solid rgba(141,246,255,0.18);
  text-align: center;
}

#data-table th { color: white; background: rgba(0,168,255,0.12); }

#data-panel {
  right: 20px;
  top: 78px;
  width: 340px;
  padding: 16px;
  border-radius: 16px;
  font-size: 8px;
}

.data-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0;
  align-items: baseline;
}

.data-label { color: var(--cyan); }
.data-value { color: #fff; font-weight: bold; text-align: right; }

#export-panel {
  right: 20px;
  top: 284px;
  width: 340px;
  padding: 12px;
  border-radius: 16px;
  display: flex;
  gap: 8px;
}

#export-panel button {
  flex: 1;
  background: rgba(0, 7, 20, 0.8);
  color: #fff;
  border: 1px solid rgba(141,246,255,0.5);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  font-size: 7px;
  line-height: 1.5;
}

#vignette, #scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

#vignette {
  background: radial-gradient(circle at center, transparent 34%, rgba(0,0,0,0.28) 66%, rgba(0,0,0,0.78) 100%);
  mix-blend-mode: multiply;
}

#scanline {
  opacity: 0.18;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.07) 0, rgba(255,255,255,0.07) 1px, transparent 1px, transparent 4px);
  animation: scan 9s linear infinite;
}

.dg.ac { z-index: 30 !important; }
.dg.main { text-shadow: none; }
.dg li.title { background: rgba(0, 30, 70, 0.95) !important; }
.dg .cr { background: rgba(0,0,0,0.45) !important; }

.gallery-mode #gui-container,
.gallery-mode #export-panel,
.gallery-mode #autoRotateBtn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}

.gallery-mode #title {
  top: 22px;
  opacity: 0.82;
}

.gallery-mode #wall-text {
  opacity: 0.72;
}

.gallery-mode #data-panel,
.gallery-mode #graph-container,
.gallery-mode #data-table {
  opacity: 0.78;
}

body.rupture #installation { animation: ruptureShake 0.62s steps(2, end); }
body.rupture #vignette { background: radial-gradient(circle at center, rgba(255,105,180,0.22), rgba(0,0,0,0.82)); }

@keyframes scan {
  from { transform: translateY(-40px); }
  to { transform: translateY(40px); }
}

@keyframes statusPulse {
  0% { box-shadow: 0 0 10px rgba(255,105,180,0.1); }
  35% { box-shadow: 0 0 48px rgba(255,105,180,0.48), inset 0 0 30px rgba(141,246,255,0.11); }
  100% { box-shadow: 0 0 24px rgba(0,168,255,0.23), inset 0 0 30px rgba(141,246,255,0.04); }
}

@keyframes ruptureShake {
  0% { filter: hue-rotate(0deg) saturate(1); transform: translate(0,0); }
  22% { filter: hue-rotate(80deg) saturate(1.8); transform: translate(8px,-5px); }
  52% { filter: hue-rotate(-120deg) saturate(2); transform: translate(-7px,5px); }
  100% { filter: hue-rotate(0deg) saturate(1); transform: translate(0,0); }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  #title, #status, #wall-text, #graph-container, #data-table, #data-panel, #export-panel, #gui-container, #autoRotateBtn, #soundBtn {
    position: absolute;
  }
  #title { top: 10px; width: calc(100vw - 20px); }
  #soundBtn { top: 132px; right: 10px; }
  #autoRotateBtn { top: 176px; right: 10px; }
  #gui-container { top: 132px; left: 10px; transform: scale(0.82); transform-origin: top left; }
  #data-panel { top: 390px; right: 10px; width: calc(100vw - 20px); }
  #wall-text { top: 545px; left: 10px; bottom: auto; width: calc(100vw - 20px); }
  #graph-container { top: 665px; left: 10px; bottom: auto; width: calc(100vw - 20px); }
  #data-table { top: 890px; left: 10px; right: auto; bottom: auto; width: calc(100vw - 20px); }
  #export-panel { top: 1115px; right: 10px; width: calc(100vw - 20px); }
  #status { bottom: 14px; width: calc(100vw - 20px); font-size: 8px; }
}
