:root {
  --bg-color: #030304;
  --text-color: rgba(255, 255, 255, 0.5);
}

* {
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  touch-action: none;
  /* Prevent scroll on touch devices */
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 0;
}

#ui-layer {
  position: absolute;
  top: 40px;
  left: 40px;
  color: var(--text-color);
  pointer-events: none;
  transition: opacity 1.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

h1 {
  font-weight: 200;
  letter-spacing: 4px;
  font-size: 28px;
  margin: 0 0 12px 0;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
}

p {
  margin: 0;
  font-size: 13px;
  letter-spacing: 1px;
  line-height: 1.6;
  font-weight: 300;
}

.fade-out {
  opacity: 0;
}

.hud {
  position: absolute;
  top: 40px;
  right: 40px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: auto;
  cursor: pointer;
  transition: color 0.2s;
  z-index: 50;
}

.hud:hover {
  color: rgba(255, 255, 255, 0.8);
}

#debug-panel {
  position: absolute;
  top: 70px;
  right: 40px;
  background: rgba(10, 10, 15, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  z-index: 100;
  display: none;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#debug-panel.visible {
  display: block;
  animation: fadeUp 0.3s ease-out;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.debug-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 30px;
}

.debug-row:last-child {
  margin-bottom: 0;
}

select {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
}

select:focus {
  border-color: rgba(255, 255, 255, 0.6);
}

.expr-input {
  background: rgba(0, 0, 0, 0.7);
  color: #7ceca1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 10px;
  width: 170px;
  outline: none;
  transition: all 0.2s;
}

.expr-input:focus {
  border-color: #7ceca1;
  background: rgba(0, 0, 0, 0.9);
}

.reset-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.8);
}



#dramatic-msg {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  color: rgba(255, 255, 255, 0.4);
  font-size: clamp(10px, 2.5vw, 14px);
  font-weight: 200;
  letter-spacing: clamp(2px, 1.5vw, 6px);
  line-height: 1.6;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 6s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 5;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3), 0 0 5px rgba(255, 255, 255, 0.1);
}

#dramatic-msg.visible {
  opacity: 1;
}

/* Glitch Mechanics for dust.html ending sequence */
@keyframes glitch-minor {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 1px); }
    40% { transform: translate(-1px, -1px); }
    60% { transform: translate(2px, 1px); }
    80% { transform: translate(1px, -1px); }
    100% { transform: translate(0); }
}

@keyframes glitch-major {
    0% { transform: translate(0) skew(0deg); filter: hue-rotate(0deg); }
    20% { transform: translate(-4px, 2px) skew(-2deg); filter: hue-rotate(90deg); }
    40% { transform: translate(4px, -2px) skew(2deg); filter: hue-rotate(-90deg) invert(20%); }
    60% { transform: translate(-2px, 4px) skew(-1deg); filter: hue-rotate(45deg); }
    80% { transform: translate(2px, -4px) skew(1deg); filter: hue-rotate(-45deg) invert(10%); }
    100% { transform: translate(0) skew(0deg); filter: hue-rotate(0deg); }
}

@keyframes glitch-extreme {
    0% { transform: translate(0) scale(1); filter: invert(0%) contrast(100%); }
    10% { transform: translate(-10px, 5px) scale(1.02); filter: invert(100%) contrast(300%) hue-rotate(180deg); }
    20% { transform: translate(10px, -5px) scale(0.95); filter: invert(0%) contrast(150%) hue-rotate(-180deg); }
    30% { transform: translate(-5px, 10px) scale(1.05); filter: invert(80%) contrast(500%) sepia(100%); }
    40% { transform: translate(5px, -10px) scale(0.98); filter: invert(20%) contrast(50%) blur(2px); }
    50% { transform: translate(-15px, 0) scale(1.1); filter: invert(100%) contrast(400%) saturate(500%); }
    60% { transform: translate(15px, 0) scale(0.9); filter: invert(0%) contrast(200%); }
    70% { transform: translate(0, 15px) scale(1.05); filter: invert(90%) contrast(600%) hue-rotate(90deg); }
    80% { transform: translate(0, -15px) scale(0.95); filter: invert(10%) contrast(100%) blur(1px); }
    90% { transform: translate(-8px, -8px) scale(1.01); filter: invert(100%) contrast(300%); }
    100% { transform: translate(0) scale(1); filter: invert(0%) contrast(100%); }
}

/* Chromatic aberration via layered color-offset shadows */
@keyframes chroma-1 {
    0% { text-shadow: 1px 0 rgba(255,0,0,0.3), -1px 0 rgba(0,255,255,0.3); }
    50% { text-shadow: -1px 0 rgba(255,0,0,0.4), 1px 0 rgba(0,255,255,0.4); }
    100% { text-shadow: 1px 0 rgba(255,0,0,0.3), -1px 0 rgba(0,255,255,0.3); }
}
@keyframes chroma-2 {
    0% { text-shadow: 2px 0 rgba(255,0,0,0.5), -2px 0 rgba(0,255,255,0.5); }
    25% { text-shadow: -3px 1px rgba(255,0,0,0.6), 3px -1px rgba(0,255,255,0.6); }
    50% { text-shadow: 2px -1px rgba(255,0,0,0.7), -2px 1px rgba(0,255,255,0.7); }
    75% { text-shadow: -2px 0 rgba(255,0,0,0.5), 2px 0 rgba(0,255,255,0.5); }
    100% { text-shadow: 2px 0 rgba(255,0,0,0.5), -2px 0 rgba(0,255,255,0.5); }
}
@keyframes chroma-3 {
    0% { text-shadow: 4px 0 rgba(255,0,0,0.8), -4px 0 rgba(0,255,255,0.8), 0 2px rgba(0,255,0,0.4); }
    20% { text-shadow: -5px 2px rgba(255,0,0,0.9), 5px -2px rgba(0,255,255,0.9), 0 -3px rgba(0,255,0,0.6); }
    40% { text-shadow: 3px -3px rgba(255,0,0,1), -3px 3px rgba(0,255,255,1), 2px 2px rgba(0,255,0,0.5); }
    60% { text-shadow: -6px 1px rgba(255,0,0,0.8), 6px -1px rgba(0,255,255,0.8), -2px -2px rgba(0,255,0,0.4); }
    80% { text-shadow: 4px 3px rgba(255,0,0,0.9), -4px -3px rgba(0,255,255,0.9), 0 3px rgba(0,255,0,0.5); }
    100% { text-shadow: 4px 0 rgba(255,0,0,0.8), -4px 0 rgba(0,255,255,0.8), 0 2px rgba(0,255,0,0.4); }
}

.glitch-1 {
    animation: glitch-minor 0.2s cubic-bezier(.25, .46, .45, .94) both infinite;
}
.glitch-1 * {
    animation: chroma-1 0.3s linear infinite;
}

.glitch-2 {
    animation: glitch-major 0.15s cubic-bezier(.25, .46, .45, .94) both infinite;
}
.glitch-2 * {
    animation: chroma-2 0.2s linear infinite;
}

.glitch-3 {
    animation: glitch-extreme 0.08s cubic-bezier(.25, .46, .45, .94) both infinite;
}
.glitch-3 * {
    animation: chroma-3 0.1s linear infinite;
}
