:root {
  --panel: rgba(15, 18, 17, 0.84);
  --panel-border: rgba(198, 255, 108, 0.16);
  --text: #f4ead2;
  --muted: rgba(244, 234, 210, 0.68);
  --lime: #d8ff72;
  --rust: #c35b2d;
  --amber: #ffb66c;
  --danger: #ff7d6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  font-family: "Cascadia Code", "Consolas", monospace;
  background:
    radial-gradient(circle at top, rgba(195, 91, 45, 0.16), transparent 28%),
    radial-gradient(circle at 85% 18%, rgba(216, 255, 114, 0.08), transparent 24%),
    linear-gradient(135deg, #090b0b 0%, #050606 55%, #121110 100%);
  overflow-x: hidden;
}

.screen-noise,
.scanlines,
.glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.screen-noise {
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  mix-blend-mode: screen;
}

.scanlines {
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 3px,
    rgba(255, 255, 255, 0.03) 3px,
    rgba(255, 255, 255, 0.03) 4px
  );
}

.glow-a {
  background: radial-gradient(circle at 20% 10%, rgba(195, 91, 45, 0.18), transparent 30%);
}

.glow-b {
  background: radial-gradient(circle at 80% 80%, rgba(216, 255, 114, 0.1), transparent 28%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100vw - 18px));
  margin: 0 auto;
  padding: 12px 0 20px;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 26%),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.dns-panel {
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 16px;
}

.topbar-copy {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--lime);
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Bahnschrift Condensed", "Arial Narrow", sans-serif;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  line-height: 0.9;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lead {
  max-width: 72ch;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
  text-wrap: pretty;
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) repeat(2, minmax(170px, 0.8fr));
  gap: 12px;
  align-items: end;
}

.field,
.faction-field {
  margin: 0;
}

label,
legend {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input[type="text"],
select {
  width: 100%;
  border: 1px solid rgba(216, 255, 114, 0.2);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.62);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

select,
select option {
  background-color: #080909;
  color: var(--text);
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: rgba(216, 255, 114, 0.6);
  box-shadow: 0 0 0 4px rgba(216, 255, 114, 0.12);
  transform: translateY(-1px);
}

.faction-field {
  border: 0;
  padding: 0;
  margin-top: 10px;
  display: grid;
  justify-items: center;
}

.faction-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 780px;
}

.faction-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100px;
  padding: 14px 14px 14px 38px;
  border: 1px solid rgba(195, 91, 45, 0.24);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(195, 91, 45, 0.08), rgba(216, 255, 114, 0.03)),
    rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.faction-card:hover {
  transform: translateY(-2px);
  border-color: rgba(216, 255, 114, 0.42);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.18);
}

.faction-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.faction-card.is-selected {
  border-color: rgba(216, 255, 114, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(216, 255, 114, 0.3),
    0 0 32px rgba(216, 255, 114, 0.14);
}

.faction-indicator {
  position: absolute;
  top: 16px;
  left: 14px;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(216, 255, 114, 0.34);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
}

.faction-card.is-selected .faction-indicator {
  background: var(--lime);
  box-shadow: 0 0 16px rgba(216, 255, 114, 0.24);
}

.faction-title {
  font-family: "Bahnschrift Condensed", "Arial Narrow", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.faction-text {
  color: var(--muted);
  line-height: 1.36;
  font-size: 0.84rem;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-direction: column;
}

.form-message {
  min-height: 1.3em;
  margin: 0;
  color: var(--danger);
  text-align: center;
}

.generate-button {
  width: min(100%, 320px);
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  background: linear-gradient(90deg, rgba(195, 91, 45, 0.92), rgba(216, 255, 114, 0.86));
  color: #101110;
  font-family: "Bahnschrift Condensed", "Arial Narrow", sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.generate-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.generate-button:disabled {
  cursor: wait;
  filter: grayscale(0.18);
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(216, 255, 114, 0.2), transparent);
}

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

.status-pill {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(216, 255, 114, 0.24);
  border-radius: 999px;
  color: var(--lime);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.chamber {
  position: relative;
  min-height: 310px;
  padding: 22px;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(216, 255, 114, 0.07), transparent 36%),
    linear-gradient(180deg, rgba(5, 6, 6, 0.86), rgba(12, 13, 12, 0.95));
  border: 1px solid rgba(216, 255, 114, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
  isolation: isolate;
}

.scanner-grid,
.beam {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scanner-grid {
  background:
    linear-gradient(rgba(216, 255, 114, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(216, 255, 114, 0.04) 1px, transparent 1px);
  background-size: 100% 32px, 32px 100%;
  mask-image: linear-gradient(transparent, black 10%, black 90%, transparent);
}

.beam {
  left: -24%;
  width: 36%;
  background: linear-gradient(90deg, transparent, rgba(216, 255, 114, 0.24), transparent);
  transform: skewX(-18deg);
  opacity: 0;
}

.chamber.is-generating .beam {
  opacity: 1;
  animation: beam-scan 1.2s linear infinite;
}

.result-label {
  margin: 0 0 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.78rem;
}

.name-panel {
  margin-bottom: 4px;
}

.name-panel.is-hidden {
  display: none;
}

.result-name {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: "Bahnschrift Condensed", "Arial Narrow", sans-serif;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-wrap: balance;
  text-shadow:
    0 0 22px rgba(216, 255, 114, 0.1),
    0 0 54px rgba(195, 91, 45, 0.14);
}

.result-flavor {
  margin: 14px 0 14px;
  max-width: 56ch;
  color: var(--muted);
  line-height: 1.55;
}

.result-chance {
  margin: 0 0 18px;
  max-width: none;
  width: 100%;
  color: rgba(255, 182, 108, 0.88);
  line-height: 1.55;
  font-size: 0.92rem;
}

.chance-highlight {
  color: var(--lime);
  font-weight: 700;
  text-shadow: 0 0 16px rgba(216, 255, 114, 0.22);
}

.survival-viz {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid rgba(255, 182, 108, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 182, 108, 0.05), transparent 36%),
    rgba(255, 255, 255, 0.02);
}

.survival-viz.is-hidden {
  display: none;
}

.viz-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.viz-title {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
}

.viz-percent {
  margin: 0;
  color: var(--amber);
  font-family: "Bahnschrift Condensed", "Arial Narrow", sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.05em;
}

.viz-bars {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.viz-track {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.viz-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.4s ease;
}

.viz-before {
  width: 100%;
  background: linear-gradient(90deg, rgba(195, 91, 45, 0.88), rgba(255, 182, 108, 0.88));
}

.viz-after {
  width: 0.009%;
  min-width: 4px;
  background: linear-gradient(90deg, rgba(216, 255, 114, 0.9), rgba(150, 255, 193, 0.8));
  box-shadow: 0 0 18px rgba(216, 255, 114, 0.22);
}

.viz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.viz-card {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.viz-card-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.viz-card-value {
  margin: 0;
  font-family: "Bahnschrift Condensed", "Arial Narrow", sans-serif;
  font-size: 1.5rem;
  line-height: 0.95;
  letter-spacing: 0.04em;
}

.meter {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.meter-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rust), var(--lime));
  box-shadow: 0 0 20px rgba(216, 255, 114, 0.26);
  transition: width 0.25s ease;
}

.signal-strip {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 6px;
  margin-top: 18px;
}

.signal-strip span {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.signal-strip span.is-live {
  background: rgba(216, 255, 114, 0.85);
  box-shadow: 0 0 16px rgba(216, 255, 114, 0.24);
}

.chamber.is-ready {
  animation: ready-pulse 0.7s ease;
}

@keyframes beam-scan {
  from {
    transform: translateX(-10%) skewX(-18deg);
  }
  to {
    transform: translateX(360%) skewX(-18deg);
  }
}

@keyframes ready-pulse {
  0% {
    box-shadow: 0 0 0 rgba(216, 255, 114, 0);
  }
  45% {
    box-shadow: 0 0 52px rgba(216, 255, 114, 0.14);
  }
  100% {
    box-shadow: 0 0 0 rgba(216, 255, 114, 0);
  }
}

@media (max-width: 920px) {
  .topbar,
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .faction-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viz-grid {
    grid-template-columns: 1fr;
  }

  .generate-button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 14px, 100%);
    padding-top: 8px;
  }

  .panel {
    padding: 14px;
  }

  .faction-grid {
    grid-template-columns: 1fr;
  }

  .chamber {
    min-height: 290px;
    padding: 18px;
  }
}
