:root {
  color-scheme: dark;
  --bg: #05060c;
  --panel: #111526;
  --panel-2: #1b2440;
  --text: #f6fbff;
  --muted: #aab6cc;
  --line: #33405d;
  --accent: #20f5d7;
  --accent-2: #ffcf4a;
  --accent-3: #ff4faa;
  --danger: #ff5f76;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  width: 100%;
  height: 100%;
}

.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 79, 170, 0.24), transparent 23rem),
    radial-gradient(circle at 72% 62%, rgba(32, 245, 215, 0.2), transparent 27rem),
    radial-gradient(circle at 54% 46%, rgba(255, 207, 74, 0.16), transparent 24rem),
    linear-gradient(135deg, #05060c 0%, #111a35 49%, #070816 100%);
}

#atomCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#atomCanvas:active {
  cursor: grabbing;
}

.hud {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: flex;
  gap: 12px;
  pointer-events: none;
}

.hud > div {
  min-width: 116px;
  padding: 10px 12px;
  border: 1px solid rgba(32, 245, 215, 0.28);
  border-radius: 8px;
  background: rgba(7, 10, 22, 0.7);
  box-shadow: 0 0 28px rgba(32, 245, 215, 0.12);
  backdrop-filter: blur(10px);
}

.label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.hud strong {
  font-size: 19px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 22px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 79, 170, 0.08), transparent 220px),
    var(--panel);
  overflow-y: auto;
}

.panel header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.control-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 10px;
}

.control-row label,
.triple span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
}

select,
input[type="number"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
  box-shadow: inset 0 0 0 1px rgba(32, 245, 215, 0.04);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

output {
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.triple label {
  display: grid;
  gap: 7px;
}

.color-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 18, 33, 0.78);
}

.color-controls legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
}

.color-controls label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.color-controls input[type="color"] {
  width: 44px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  cursor: pointer;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  height: 40px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #06100f;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(32, 245, 215, 0.24);
}

button:nth-child(2) {
  background: var(--accent-3);
  color: #17050f;
  box-shadow: 0 0 22px rgba(255, 79, 170, 0.22);
}

.science-button {
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  color: #05060c;
  box-shadow: 0 0 30px rgba(255, 79, 170, 0.2);
}

.readout {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(32, 245, 215, 0.07), rgba(255, 79, 170, 0.05)), #0d1221;
}

.readout div {
  display: grid;
  gap: 4px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

dd {
  margin: 0;
  color: var(--text);
  line-height: 1.35;
}

.invalid {
  color: var(--danger);
}

.science-panel {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 6, 12, 0.72);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.science-panel.open {
  display: flex;
}

.science-sheet {
  width: min(820px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  border: 1px solid rgba(32, 245, 215, 0.28);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 79, 170, 0.18), transparent 17rem),
    radial-gradient(circle at 86% 22%, rgba(32, 245, 215, 0.14), transparent 18rem),
    #101526;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.science-sheet > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.science-sheet h2,
.science-sheet h3 {
  margin: 0;
  letter-spacing: 0;
}

.science-sheet h2 {
  font-size: 24px;
}

.science-sheet h3 {
  margin-top: 22px;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 16px;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  background: var(--panel-2);
  color: var(--text);
  box-shadow: none;
}

.science-copy {
  max-height: calc(min(760px, 100vh - 48px) - 78px);
  padding: 4px 20px 22px;
  overflow-y: auto;
}

.science-copy p {
  margin: 0 0 12px;
  color: #d7e2ef;
}

.science-copy pre {
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid rgba(32, 245, 215, 0.18);
  border-radius: 7px;
  background: rgba(5, 6, 12, 0.6);
  overflow-x: auto;
}

.science-copy code {
  color: #ffcf4a;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
}

.science-link {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.science-link a {
  color: var(--accent);
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 58vh auto;
    min-height: 100%;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 460px) {
  .control-row {
    grid-template-columns: 1fr;
  }

  output {
    text-align: left;
  }

  .hud {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .hud > div {
    min-width: 0;
    flex: 1;
  }

  .science-panel {
    padding: 10px;
  }

  .science-sheet {
    max-height: calc(100vh - 20px);
  }
}
