:root {
  color-scheme: dark;
  --ink: #f2f5fc;
  --muted: #9ba9bf;
  --dim: #68778c;
  --accent: #8be3d2;
  --line: rgba(190, 214, 244, 0.12);
  --coral: #ff7893;
  --amber: #f8b86c;
  --lime: #d4e78a;
  --mint: #72dfbd;
  --sky: #72c9fa;
  --violet: #b09aff;
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; min-height: 100%; }

body {
  overflow: hidden;
  background: #080d18;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100vw;
  height: 100vh;
  min-height: 620px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 55% 62% at 42% 53%, rgba(25, 43, 64, 0.9) 0%, rgba(14, 25, 42, 0.68) 48%, rgba(8, 13, 24, 0) 100%),
    linear-gradient(125deg, #080e1a 0%, #0b1323 42%, #080c16 100%);
}

.ambient, .field-grid, .field-ring, #life-canvas { position: absolute; pointer-events: none; }
.ambient { border-radius: 50%; filter: blur(70px); opacity: .48; }
.ambient-one { width: 43vw; height: 40vw; left: 13vw; top: 16vh; background: radial-gradient(circle, rgba(53, 134, 134, .21), transparent 68%); }
.ambient-two { width: 37vw; height: 37vw; right: 13vw; bottom: -16vw; background: radial-gradient(circle, rgba(93, 82, 168, .24), transparent 70%); }
.field-grid {
  inset: 0;
  opacity: .46;
  background-image: linear-gradient(rgba(135, 170, 210, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(135, 170, 210, .035) 1px, transparent 1px);
  background-size: 66px 66px;
  mask-image: radial-gradient(ellipse 75% 80% at 44% 55%, #000, transparent 90%);
}
.field-ring { width: min(50vw, 710px); aspect-ratio: 1; left: 20%; top: 14%; border: 1px solid rgba(163, 198, 223, .045); border-radius: 50%; }
.field-ring-two { width: min(35vw, 500px); left: 28%; top: 27%; border-color: rgba(163, 198, 223, .036); }
#life-canvas { inset: 0; display: block; width: 100%; height: 100%; pointer-events: auto; touch-action: none; z-index: 1; }

.site-header {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  height: 89px;
  padding: 0 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(184, 215, 244, .08);
  pointer-events: none;
}
.brand { display: inline-flex; gap: 14px; align-items: center; font-size: 13px; font-weight: 780; letter-spacing: .19em; white-space: nowrap; }
.brand-slash { color: var(--accent); opacity: .8; }
.brand-symbol { width: 21px; height: 22px; position: relative; display: inline-block; }
.brand-symbol i { position: absolute; display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 9px currentColor; }
.brand-symbol i:nth-child(1) { left: 8px; top: 0; color: var(--coral); background: currentColor; }
.brand-symbol i:nth-child(2) { right: 0; top: 5px; color: var(--amber); background: currentColor; }
.brand-symbol i:nth-child(3) { right: 0; bottom: 5px; color: var(--lime); background: currentColor; }
.brand-symbol i:nth-child(4) { left: 8px; bottom: 0; color: var(--mint); background: currentColor; }
.brand-symbol i:nth-child(5) { left: 0; bottom: 5px; color: var(--sky); background: currentColor; }
.brand-symbol i:nth-child(6) { left: 0; top: 5px; color: var(--violet); background: currentColor; }
.header-status, .eyebrow, .panel-kicker, .section-heading, .section-hint, .matrix-legend, .range-scale, .species-readout, .field-footer, .field-coordinates { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.header-status { display: flex; align-items: center; gap: 10px; color: #a6b6c6; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.status-led, .footer-pulse { width: 7px; height: 7px; border-radius: 50%; background: #8ce7cf; box-shadow: 0 0 0 4px rgba(140, 231, 207, .08), 0 0 18px rgba(140, 231, 207, .9); animation: pulse 2.4s ease-in-out infinite; }
.header-divider { color: #59687a; padding: 0 7px; }
@keyframes pulse { 50% { opacity: .5; box-shadow: 0 0 0 7px rgba(140, 231, 207, .035), 0 0 10px rgba(140, 231, 207, .5); } }

.intro { position: absolute; z-index: 2; top: 145px; left: 6.4vw; width: min(525px, 45vw); pointer-events: none; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: #acd1ce; font-size: 10px; font-weight: 700; letter-spacing: .18em; white-space: nowrap; }
.eyebrow-line { width: 22px; height: 1px; background: var(--accent); opacity: .8; }
.eyebrow-index { color: #607c86; margin-left: 3px; }
.intro h1 { margin: 18px 0 18px; font-size: clamp(49px, 5.5vw, 86px); line-height: 1.04; letter-spacing: -.066em; font-weight: 710; text-wrap: nowrap; text-shadow: 0 3px 30px rgba(3, 7, 16, .45); }
.intro h1 em { color: #b2eee0; font-style: normal; font-weight: 620; }
.intro p { margin: 0; max-width: 375px; color: #b3c0cf; line-height: 1.65; font-size: 14px; font-weight: 400; text-shadow: 0 2px 17px #09101d; }
.field-coordinates { z-index: 2; position: absolute; font-size: 10px; letter-spacing: .13em; line-height: 1.75; color: rgba(148, 176, 194, .45); pointer-events: none; }
.field-coordinates-left { bottom: 105px; left: 6.4vw; }
.field-coordinates-right { bottom: 106px; right: 435px; text-align: right; }

.control-panel {
  position: absolute;
  z-index: 4;
  top: 109px;
  right: 40px;
  width: 350px;
  max-height: calc(100vh - 148px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(141, 173, 195, .3) transparent;
  padding: 18px 22px 0;
  border: 1px solid rgba(181, 211, 237, .17);
  border-radius: 15px;
  background: linear-gradient(155deg, rgba(20, 31, 47, .99) 0%, rgba(12, 20, 34, .985) 55%, rgba(11, 18, 31, .99) 100%);
  box-shadow: 0 24px 84px rgba(1, 5, 13, .39), inset 0 1px 0 rgba(221, 242, 255, .065);
}
.panel-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-kicker { font-size: 10px; font-weight: 750; letter-spacing: .15em; color: #aabdd0; }
.panel-kicker span { color: #5a7183; padding: 0 3px; }
.auto-toggle { display: flex; align-items: center; gap: 7px; height: 25px; padding: 0 8px; border: 1px solid rgba(130, 223, 199, .23); border-radius: 6px; background: rgba(94, 198, 174, .085); color: #9ee5d3; font-size: 9px; font-family: ui-monospace, monospace; font-weight: 800; letter-spacing: .1em; transition: background .2s, border-color .2s; }
.auto-toggle:hover { background: rgba(94, 198, 174, .16); border-color: rgba(130, 223, 199, .5); }
.auto-toggle[aria-pressed="false"] { color: #98a6b7; border-color: var(--line); background: rgba(255, 255, 255, .025); }
.auto-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.panel-heading { margin: 12px 0 16px; }
.panel-heading h2 { margin: 0 0 6px; font-size: 25px; font-weight: 650; letter-spacing: -.045em; line-height: 1.15; }
.panel-heading h2 span { color: var(--accent); }
.panel-heading p { margin: 0; color: #91a4b7; font-size: 12px; line-height: 1.5; }
.control-section { border-top: 1px solid var(--line); padding: 12px 0 10px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 9px; }
.section-heading h3 { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 10px; text-transform: uppercase; letter-spacing: .13em; font-weight: 760; color: #d7e2eb; }
.section-heading h3 span { color: #77c8bb; font-size: 9px; }
.section-hint { color: #718598; font-size: 9px; letter-spacing: .055em; white-space: nowrap; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.preset-button { height: 35px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid rgba(158, 189, 216, .13); border-radius: 7px; background: rgba(130, 160, 190, .035); color: #b4c3d0; text-align: left; font-size: 12px; font-weight: 600; transition: color .18s, background .18s, border-color .18s, transform .18s; }
.preset-button:hover { transform: translateY(-1px); color: #f6ffff; border-color: rgba(159, 226, 213, .4); }
.preset-button[aria-pressed="true"] { color: #edfff9; background: linear-gradient(100deg, rgba(105, 210, 183, .2), rgba(92, 167, 188, .095)); border-color: rgba(126, 225, 201, .43); box-shadow: inset 0 0 20px rgba(83, 200, 168, .065); }
.preset-button:last-child { grid-column: span 2; }
.preset-index { color: #6a8391; font-family: ui-monospace, monospace; font-size: 10px; font-weight: 700; }
.preset-button[aria-pressed="true"] .preset-index { color: #a3e9d7; }
.preset-ornament { margin-left: auto; width: 10px; height: 10px; border: 1px solid currentColor; border-radius: 50%; opacity: .34; }
.preset-button[aria-pressed="true"] .preset-ornament { opacity: .85; background: currentColor; box-shadow: 0 0 9px currentColor; width: 6px; height: 6px; margin-right: 2px; }
.transition-track { height: 2px; margin: 8px 1px 0; background: rgba(156, 200, 211, .08); border-radius: 2px; overflow: hidden; }
.transition-track span { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, #77d9c4, #95ccfb); box-shadow: 0 0 9px #77d9c4; }
.matrix-section { padding-bottom: 11px; }
.matrix-section .section-heading { margin-bottom: 5px; }
.randomize-button { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 6px; border: 1px solid rgba(123, 204, 193, .28); border-radius: 5px; background: rgba(84, 190, 171, .08); color: #a4dfd4; font-family: ui-monospace, monospace; font-size: 9px; font-weight: 750; letter-spacing: .035em; white-space: nowrap; transition: background .2s, border-color .2s; }
.randomize-button:hover { background: rgba(84, 190, 171, .18); border-color: rgba(123, 204, 193, .55); }
.shuffle-icon { font-size: 15px; line-height: 0; font-family: sans-serif; transform: translateY(-1px); }
.matrix-description { margin: 0 0 7px; color: #8599ac; font-size: 11px; line-height: 1.4; }
.matrix-grid { display: grid; grid-template-columns: 17px repeat(6, minmax(0, 1fr)); gap: 4px; align-items: center; }
.matrix-axis-dot { width: 7px; height: 7px; justify-self: center; border-radius: 50%; background: var(--species-color); box-shadow: 0 0 9px var(--species-color); }
.matrix-corner { height: 11px; }
.matrix-cell { height: 21px; width: 100%; padding: 0; border: 1px solid transparent; border-radius: 4px; background: rgba(120, 160, 180, .12); color: rgba(235, 247, 253, .7); font-family: ui-monospace, monospace; font-size: 14px; font-weight: 500; line-height: 1; transition: filter .12s, transform .12s; }
.matrix-cell:hover { transform: scale(1.065); filter: brightness(1.5); z-index: 1; }
.matrix-legend { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; color: #697e91; font-size: 8px; letter-spacing: .055em; }
.matrix-legend > span { display: flex; align-items: center; gap: 4px; }
.matrix-legend i { display: block; width: 6px; height: 6px; border-radius: 2px; }
.legend-negative { background: #ed829f; }
.legend-positive { background: #84dfce; }
.conditions-section { padding-bottom: 7px; }
.conditions-section .section-heading { margin-bottom: 10px; }
.range-control { margin-bottom: 10px; }
.range-control:last-child { margin-bottom: 4px; }
.range-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.range-label label { color: #c3d0dd; font-size: 11px; font-weight: 600; }
.range-label output { color: #e9f5f4; font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; }
input[type="range"] { display: block; width: 100%; height: 4px; margin: 0; appearance: none; border-radius: 99px; background: linear-gradient(90deg, #79d9c5 var(--range-progress, 30%), rgba(143, 167, 188, .22) var(--range-progress, 30%)); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border: 3px solid #a5ebdb; border-radius: 50%; background: #143a3d; box-shadow: 0 0 0 3px rgba(116, 220, 195, .15), 0 0 12px rgba(116, 220, 195, .28); }
input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border: 3px solid #a5ebdb; border-radius: 50%; background: #143a3d; box-shadow: 0 0 0 3px rgba(116, 220, 195, .15); }
.range-scale { display: flex; justify-content: space-between; margin-top: 7px; color: #63798c; font-size: 8px; letter-spacing: .09em; }
.panel-footer { position: sticky; bottom: 0; display: flex; align-items: center; gap: 16px; margin: 0 -22px; padding: 10px 22px 11px; border-top: 1px solid var(--line); background: rgba(9, 18, 31, .97); }
.fps-readout { display: flex; align-items: center; gap: 7px; }
.fps-readout strong { min-width: 35px; color: #9de7d9; font-family: ui-monospace, monospace; font-size: 27px; line-height: 1; font-weight: 500; letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.fps-readout span { color: #6f8899; font-family: ui-monospace, monospace; font-size: 8px; line-height: 1.3; letter-spacing: .07em; }
.panel-footer-divider { width: 1px; height: 28px; background: var(--line); }
.species-readout { display: flex; flex-direction: column; gap: 5px; color: #8798ab; font-size: 8px; letter-spacing: .07em; white-space: nowrap; }
.species-dots { display: flex; gap: 5px; }
.species-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 7px currentColor; }
.species-dots i:nth-child(2) { background: var(--amber); }
.species-dots i:nth-child(3) { background: var(--lime); }
.species-dots i:nth-child(4) { background: var(--mint); }
.species-dots i:nth-child(5) { background: var(--sky); }
.species-dots i:nth-child(6) { background: var(--violet); }

.field-footer { position: absolute; z-index: 3; left: 6.4vw; right: 435px; bottom: 36px; display: flex; align-items: center; gap: 23px; color: #a2b7c5; font-size: 10px; font-weight: 650; letter-spacing: .11em; white-space: nowrap; pointer-events: none; }
.footer-instruction, .footer-live { display: inline-flex; align-items: center; gap: 10px; }
.drag-icon { width: 17px; height: 17px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(157, 216, 213, .7); border-radius: 50%; }
.drag-icon i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.footer-divider { width: 1px; height: 17px; background: rgba(181, 212, 225, .2); }
.footer-live { color: #b8d5d5; }
.footer-pulse { width: 5px; height: 5px; }
.footer-separator { color: #536e7e; }
.cursor-ring { position: absolute; z-index: 3; width: 122px; height: 122px; border: 1px solid rgba(148, 238, 215, .28); border-radius: 50%; box-shadow: 0 0 36px rgba(109, 230, 203, .12), inset 0 0 28px rgba(109, 230, 203, .08); pointer-events: none; opacity: 0; transform: translate(-50%, -50%) scale(.6); transition: opacity .18s, transform .18s; }
.cursor-ring.visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.error-banner { position: absolute; z-index: 9; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 420px; padding: 22px; border: 1px solid #e18591; border-radius: 10px; background: #1b2231; color: #fff; text-align: center; box-shadow: 0 20px 60px #0008; }

@media (max-width: 1150px) {
  .intro { left: 5vw; width: 46vw; }
  .intro h1 { font-size: clamp(45px, 5.8vw, 68px); }
  .control-panel { right: 24px; width: 330px; }
  .field-footer { left: 5vw; right: 380px; gap: 12px; font-size: 9px; }
  .field-coordinates-left { left: 5vw; }
  .field-coordinates-right { right: 380px; }
}

@media (max-width: 800px) {
  .app-shell { min-height: 100vh; }
  .site-header { height: 70px; padding: 0 24px; }
  .header-status { font-size: 9px; }
  .intro { top: 107px; left: 6vw; width: 80vw; }
  .intro h1 { font-size: clamp(43px, 8vw, 70px); }
  .intro p { max-width: 340px; font-size: 12px; }
  .control-panel { top: auto; bottom: 18px; right: 18px; width: 330px; max-height: min(60vh, 610px); }
  .field-footer { bottom: 34px; right: 370px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .footer-divider { display: none; }
  .field-coordinates-left { bottom: 125px; }
  .field-coordinates-right { display: none; }
}

@media (max-width: 620px) {
  .site-header { height: 62px; padding: 0 18px; }
  .brand { font-size: 11px; gap: 10px; }
  .brand-symbol { transform: scale(.85); }
  .header-status { font-size: 0; gap: 0; }
  .header-status .status-led { width: 7px; height: 7px; }
  .intro { top: 94px; left: 22px; width: calc(100% - 44px); }
  .intro h1 { margin: 16px 0 12px; font-size: clamp(43px, 11vw, 62px); }
  .intro p { width: min(310px, 80vw); font-size: 12px; }
  .eyebrow { font-size: 8px; letter-spacing: .12em; gap: 7px; }
  .eyebrow-line { width: 15px; }
  .control-panel { left: 12px; right: 12px; bottom: 10px; width: auto; max-height: 47vh; border-radius: 13px; padding: 17px 18px 0; }
  .panel-heading { margin: 11px 0 16px; }
  .panel-heading h2 { font-size: 22px; }
  .control-section { padding: 14px 0; }
  .panel-footer { margin: 0 -18px; padding: 12px 18px; }
  .field-footer { bottom: calc(47vh + 25px); left: 22px; right: 22px; gap: 6px; font-size: 8px; }
  .field-coordinates { display: none; }
  .field-ring { left: -18%; top: 20%; width: 110vw; }
  .field-ring-two { left: 1%; top: 29%; width: 70vw; }
}

@media (max-height: 820px) and (min-width: 801px) {
  .panel-heading { margin: 8px 0 11px; }
  .panel-heading p, .matrix-description, .range-scale { display: none; }
  .control-section { padding: 9px 0 7px; }
  .section-heading { margin-bottom: 6px; }
  .preset-button { height: 32px; }
  .matrix-grid { gap: 3px; }
  .matrix-cell { height: 19px; }
  .range-control { margin-bottom: 8px; }
  .range-label { margin-bottom: 7px; }
}

@media (max-height: 720px) and (min-width: 801px) {
  .intro { top: 119px; }
  .intro h1 { font-size: clamp(47px, 5vw, 70px); }
  .field-footer { bottom: 24px; }
  .field-coordinates { display: none; }
}
