/* ========================================================================== 
   Kreativ Code Lab
   Specimen 004 — Sonorous Driftfield
   ========================================================================== */

:root {
  color-scheme: dark;
  --cosmic-black: #03050f;
  --panel-background: rgba(6, 8, 25, 0.5);
  --panel-border: rgba(190, 222, 255, 0.17);
  --text-primary: rgba(248, 247, 255, 0.95);
  --text-secondary: rgba(218, 209, 248, 0.74);
  --text-muted: rgba(190, 183, 224, 0.53);
  --accent-cyan: #79e8ff;
  --accent-violet: #b79aff;
  --accent-magenta: #ff8edc;
  --accent-gold: #ffe7a8;
  --accent-sonic: #9fffdc;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, #101744 0%, #090a29 34%, #03050f 74%),
    #03050f;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body {
  position: relative;
  color: var(--text-primary);
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

#cosmic-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.interface {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding: clamp(1rem, 2.6vw, 2rem);
  pointer-events: none;
  transition:
    opacity 280ms ease,
    transform 280ms ease;
}

.interface.is-hidden {
  opacity: 0;
  transform: scale(0.985);
}

.identity-panel {
  align-self: start;
  text-align: center;
  text-shadow:
    0 0 24px rgba(157, 131, 255, 0.2),
    0 0 44px rgba(74, 201, 255, 0.08);
}

.lab-name,
.specimen-number {
  margin: 0;
  color: var(--text-secondary);
  font-size: clamp(0.66rem, 1vw, 0.78rem);
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.identity-panel h1 {
  margin: 0.28rem 0 0.22rem;
  font-size: clamp(1.35rem, 3vw, 2.4rem);
  font-weight: 300;
  letter-spacing: 0.08em;
}

.status-panel {
  align-self: start;
  display: grid;
  grid-template-columns: minmax(9.5rem, 1.5fr) repeat(4, minmax(5.4rem, 0.78fr));
  gap: 0.35rem;
  width: min(49rem, calc(100vw - 2rem));
  margin-top: clamp(1rem, 5vh, 3.4rem);
  padding: 0.45rem;
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  background: var(--panel-background);
  box-shadow:
    0 1rem 3rem rgba(0, 0, 0, 0.17),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(12px);
}

.status-item {
  position: relative;
  display: flex;
  min-height: 3rem;
  flex-direction: column;
  justify-content: center;
  padding: 0.5rem 0.72rem;
  overflow: hidden;
  border-radius: 0.72rem;
  background: rgba(255, 255, 255, 0.022);
}

.status-label {
  color: var(--text-muted);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.status-value {
  margin-top: 0.12rem;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.charge-track {
  position: absolute;
  right: 0.68rem;
  bottom: 0.46rem;
  left: 0.68rem;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.charge-meter {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    var(--accent-cyan),
    var(--accent-violet),
    var(--accent-magenta),
    var(--accent-gold)
  );
  box-shadow: 0 0 14px rgba(194, 162, 255, 0.76);
  transition: width 80ms linear;
}

.instructions-panel {
  align-self: end;
  max-width: min(54rem, calc(100vw - 2rem));
  padding: 0.78rem 1.05rem;
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  background: rgba(5, 6, 20, 0.5);
  text-align: center;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(12px);
}

.instructions-panel p {
  margin: 0;
}

.primary-instruction {
  color: var(--text-secondary);
  font-size: clamp(0.72rem, 1.25vw, 0.86rem);
  letter-spacing: 0.025em;
}

.keyboard-instruction {
  margin-top: 0.38rem !important;
  color: var(--text-muted);
  font-size: clamp(0.62rem, 1.05vw, 0.72rem);
  line-height: 1.65;
}

kbd {
  display: inline-block;
  min-width: 1.5rem;
  margin: 0 0.12rem;
  padding: 0.04rem 0.34rem 0.08rem;
  border: 1px solid rgba(205, 192, 255, 0.19);
  border-bottom-color: rgba(205, 192, 255, 0.3);
  border-radius: 0.32rem;
  background: rgba(171, 151, 255, 0.065);
  color: rgba(239, 234, 255, 0.8);
  font-family: inherit;
  font-size: 0.88em;
  font-weight: 700;
  line-height: 1.25;
}

.noscript-message {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 5;
  width: min(30rem, calc(100vw - 2rem));
  margin: 0;
  padding: 1rem;
  transform: translate(-50%, -50%);
  border: 1px solid var(--panel-border);
  border-radius: 0.8rem;
  background: rgba(5, 6, 20, 0.92);
  color: var(--text-primary);
  text-align: center;
}

@media (max-width: 820px) {
  .interface {
    padding: 0.82rem;
  }

  .status-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(24rem, calc(100vw - 1rem));
    margin-top: 0.8rem;
  }

  .status-charge {
    grid-column: span 2;
  }

  .instructions-panel {
    max-width: calc(100vw - 1rem);
    padding: 0.68rem 0.78rem;
  }
}

@media (max-height: 650px) {
  .status-panel {
    margin-top: 0.5rem;
  }

  .instructions-panel {
    padding-block: 0.5rem;
  }

  .keyboard-instruction {
    margin-top: 0.18rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .interface,
  .charge-meter {
    transition: none;
  }
}
