:root {
  --abyss: #05030d;
  --deep: #0d0822;
  --trench: #150c30;
  --glow: #3cffd0;
  --glow-dim: rgba(60, 255, 208, 0.22);
  --bile: #c8ff4d;
  --flesh: #b0438f;
  --flesh-dark: #5a1a5c;
  --text: #ddd4f7;
  --muted: #8f84b8;
  --danger: #ff5c8a;
  --radius-blob: 34px 64px 28px 72px / 56px 26px 66px 32px;
  --font-alien: "Major Mono Display", ui-monospace, monospace;
  --font-body: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

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

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(122, 43, 113, 0.35), transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(60, 255, 208, 0.10), transparent 60%),
    linear-gradient(180deg, var(--deep) 0%, var(--abyss) 70%);
  background-color: var(--abyss);
  background-attachment: fixed;
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.75) 100%);
  z-index: 1;
}

::selection { background: var(--bile); color: var(--abyss); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- ambient ---------- */

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bubbles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.bubble {
  position: absolute;
  bottom: -40px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  border: 1px solid rgba(60, 255, 208, 0.35);
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.25), transparent 60%);
  animation: rise var(--t) linear var(--delay) infinite;
  opacity: 0;
}

@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 0.8; }
  50% { transform: translate(18px, -55vh); }
  100% { transform: translate(-12px, -115vh); opacity: 0; }
}

/* ---------- top bar ---------- */

.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 24px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--glow);
  border-bottom: 1px dashed var(--glow-dim);
  background: rgba(5, 3, 13, 0.6);
}

.sigil { font-size: 16px; letter-spacing: 0.3em; text-shadow: 0 0 10px var(--glow); }

.topbar-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--bile);
}

.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bile);
  box-shadow: 0 0 10px var(--bile);
  animation: throb 1.9s ease-in-out infinite;
}

@keyframes throb {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.55); opacity: 0.5; }
}

/* ---------- layout ---------- */

.layout {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(280px, 5fr) 7fr;
  gap: 48px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 24px;
  align-items: start;
}

/* ---------- the keeper ---------- */

.keeper {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#octopus {
  width: 100%;
  max-width: 420px;
  height: auto;
  aspect-ratio: 400 / 440;
  overflow: visible;
  filter: drop-shadow(0 0 40px rgba(176, 67, 143, 0.35));
}

#head {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: breathe 5.5s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.015, 1.04); }
}

.wrinkle {
  fill: none;
  stroke: rgba(30, 5, 35, 0.45);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.spots circle {
  fill: var(--glow);
  animation: flicker 3.2s ease-in-out var(--d) infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 0.15; }
  40% { opacity: 0.95; }
  55% { opacity: 0.3; }
  70% { opacity: 0.85; }
}

.tentacle { fill: url(#limb); stroke: rgba(25, 4, 30, 0.6); stroke-width: 1; }
.tentacle.back { filter: brightness(0.72); }
.sucker { fill: #f0b3d8; stroke: #7a2b71; stroke-width: 1; opacity: 0.85; }

.sclera { fill: url(#sclera); }
.eye-rim { fill: none; stroke: #2a0930; stroke-width: 3; }
.iris-fill { fill: url(#iris); }
.iris-rage { fill: #ff2a55; opacity: 0; transition: opacity 0.3s; }
.glint { fill: rgba(255, 255, 255, 0.85); }

.pupil {
  fill: #07020b;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.lid {
  fill: url(#skin);
  transform-box: fill-box;
  transform-origin: 50% 0%;
  transform: scaleY(0);
  transition: transform 0.08s ease-in;
}

.lid.shut { transform: scaleY(1); }

#octopus.excited .pupil { transform: scale(1.1, 2.6); }
#octopus.angry .pupil { transform: scale(1.25, 0.35); }
#octopus.angry .iris-rage { opacity: 0.55; }
#octopus.suspicious .lid { transform: scaleY(0.42); }

.speech {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin-top: 8px;
  padding: 18px 22px;
  min-height: 7.5em;
  border: 1px solid var(--glow-dim);
  border-radius: var(--radius-blob);
  background: rgba(13, 8, 34, 0.85);
  box-shadow: 0 0 30px rgba(60, 255, 208, 0.08), inset 0 0 24px rgba(60, 255, 208, 0.05);
  color: var(--glow);
}

.speech::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 20px; height: 20px;
  background: inherit;
  border-left: 1px solid var(--glow-dim);
  border-top: 1px solid var(--glow-dim);
  transform: translateX(-50%) rotate(45deg);
}

#speech-text { margin: 0; }

#speech-text::after {
  content: "▮";
  margin-left: 2px;
  color: var(--bile);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

.speech.twitch { animation: twitch 0.35s linear; }

@keyframes twitch {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 1px) skewX(-2deg); }
  40% { transform: translate(3px, -1px) skewX(2deg); }
  60% { transform: translate(-2px, 0); }
  80% { transform: translate(1px, 1px); }
}

.keeper-name {
  margin: 18px 0 0;
  text-align: center;
  font-family: var(--font-alien);
  font-size: 22px;
  color: var(--bile);
  text-shadow: 0 0 14px rgba(200, 255, 77, 0.5);
}

.keeper-name small {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-shadow: none;
}

/* ---------- the receptacle ---------- */

.panel {
  padding: 40px 40px 32px;
  border: 1px solid var(--glow-dim);
  border-radius: var(--radius-blob);
  background: linear-gradient(160deg, rgba(21, 12, 48, 0.92), rgba(8, 4, 20, 0.92));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 0 60px rgba(122, 43, 113, 0.18);
  animation: morph 14s ease-in-out infinite;
}

@keyframes morph {
  0%, 100% { border-radius: 34px 64px 28px 72px / 56px 26px 66px 32px; }
  33% { border-radius: 60px 30px 70px 34px / 30px 62px 28px 58px; }
  66% { border-radius: 40px 72px 44px 26px / 64px 34px 52px 40px; }
}

h1 {
  margin: 0 0 8px;
  font-family: var(--font-alien);
  font-weight: 400;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.1;
  color: var(--glow);
  text-shadow: 0 0 18px rgba(60, 255, 208, 0.55), 3px 0 0 rgba(255, 92, 138, 0.35);
}

.lede { margin: 0 0 28px; color: var(--muted); max-width: 52ch; }

fieldset {
  margin: 0 0 22px;
  padding: 20px 0 4px;
  border: 0;
  border-top: 1px dashed var(--glow-dim);
}

legend {
  padding: 0 12px 0 0;
  font-family: var(--font-alien);
  font-size: 18px;
  color: var(--bile);
}

.step { font-family: var(--font-body); font-size: 13px; color: var(--glow); margin-right: 6px; }

.field { margin-bottom: 18px; }

label,
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.aside { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-style: italic; }

input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  font: inherit;
  color: var(--text);
  caret-color: var(--bile);
  background: rgba(5, 3, 13, 0.7);
  border: 1px solid rgba(143, 132, 184, 0.35);
  border-radius: 18px 6px 22px 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, border-radius 0.4s;
}

textarea { resize: vertical; min-height: 84px; }

::placeholder { color: rgba(143, 132, 184, 0.6); font-style: italic; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--glow);
  border-radius: 6px 22px 8px 18px;
  box-shadow: 0 0 0 3px rgba(60, 255, 208, 0.15), 0 0 24px rgba(60, 255, 208, 0.25);
}

[aria-invalid="true"] {
  border-color: var(--danger) !important;
  box-shadow: 0 0 18px rgba(255, 92, 138, 0.25);
}

select option { background: var(--deep); color: var(--text); }

.error {
  margin: 6px 0 0;
  min-height: 0;
  font-size: 13px;
  color: var(--danger);
}

.error:not(:empty)::before { content: "⟁ "; }

.alien-date {
  margin: 6px 0 0;
  font-size: 13px;
  font-style: italic;
  color: var(--glow);
  opacity: 0.85;
}

/* chips (hearts) */

.chips { display: flex; flex-wrap: wrap; gap: 10px; }

.chip { margin: 0; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; }

.chip input,
.slot input { position: absolute; opacity: 0; pointer-events: none; }

.chip span {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid rgba(143, 132, 184, 0.35);
  border-radius: 999px 999px 999px 6px;
  font-size: 13px;
  transition: all 0.2s;
}

.chip em { color: var(--muted); }
.chip:hover span { border-color: var(--glow); }
.chip input:checked + span { background: var(--flesh); border-color: var(--flesh); color: #fff; box-shadow: 0 0 18px rgba(176, 67, 143, 0.6); }
.chip input:checked + span em { color: rgba(255, 255, 255, 0.75); }
.chip input:focus-visible + span { outline: 2px solid var(--glow); outline-offset: 2px; }

/* slots */

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.slot { position: relative; margin: 0; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; }

.slot-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(143, 132, 184, 0.3);
  border-radius: 14px 4px 14px 4px;
  background: rgba(5, 3, 13, 0.55);
  transition: all 0.2s;
}

.slot-time { font-family: var(--font-alien); font-size: 20px; color: var(--text); }
.slot-name { font-size: 11px; color: var(--muted); line-height: 1.3; }

.slot:hover .slot-body { border-color: var(--glow); transform: translateY(-2px) rotate(-0.6deg); }

.slot input:checked + .slot-body {
  background: var(--glow);
  border-color: var(--glow);
  box-shadow: 0 0 22px rgba(60, 255, 208, 0.5);
}

.slot input:checked + .slot-body .slot-time,
.slot input:checked + .slot-body .slot-name { color: var(--abyss); }

.slot input:focus-visible + .slot-body { outline: 2px solid var(--bile); outline-offset: 2px; }

.slot input:disabled + .slot-body { opacity: 0.38; cursor: not-allowed; transform: none; border-style: dashed; }
.slot input:disabled + .slot-body .slot-time { text-decoration: line-through; text-decoration-color: var(--danger); }
.slot:has(input:disabled) { cursor: not-allowed; }

.slots-empty { grid-column: 1 / -1; margin: 0; padding: 14px 16px; font-size: 13px; font-style: italic; color: var(--muted); border: 1px dashed rgba(143, 132, 184, 0.3); border-radius: 14px; }

/* consent */

.consent {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  font-weight: 400;
}

.consent input {
  appearance: none;
  flex: none;
  width: 24px; height: 24px;
  margin: 0;
  border: 1px solid rgba(143, 132, 184, 0.5);
  border-radius: 50% 50% 50% 8px;
  background: rgba(5, 3, 13, 0.7);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: all 0.2s;
}

.consent input::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--abyss);
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.3, 1.8, 0.5, 1);
}

.consent input:checked { background: var(--bile); border-color: var(--bile); box-shadow: 0 0 14px rgba(200, 255, 77, 0.6); }
.consent input:checked::after { transform: scale(1); }
.consent input:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }

/* the button */

.offer {
  position: relative;
  display: block;
  width: 100%;
  padding: 18px 24px;
  border: 0;
  border-radius: 40px 12px 40px 12px;
  font-family: var(--font-alien);
  font-size: 22px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(120deg, var(--flesh-dark), var(--flesh) 50%, #e05bb5);
  background-size: 200% 100%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 40px rgba(176, 67, 143, 0.45);
  transition: background-position 0.5s, box-shadow 0.3s, border-radius 0.4s;
}

.offer:hover {
  background-position: 100% 0;
  border-radius: 12px 40px 12px 40px;
  box-shadow: 0 0 0 1px var(--bile), 0 10px 50px rgba(224, 91, 181, 0.7);
  animation: wobble 0.6s ease-in-out infinite;
}

.offer:focus-visible { outline: 2px solid var(--glow); outline-offset: 4px; }
.offer:active { transform: scale(0.98); }
.offer.small { font-size: 16px; padding: 14px 20px; }

@keyframes wobble {
  0%, 100% { transform: skewX(0deg); }
  25% { transform: skewX(-1.5deg) scaleY(1.02); }
  75% { transform: skewX(1.5deg) scaleY(0.98); }
}

.fineprint { margin: 12px 0 0; font-size: 11px; text-align: center; color: var(--muted); }

/* ---------- ledger ---------- */

.ledger {
  position: relative;
  z-index: 3;
  max-width: 1180px;
  margin: 24px auto 0;
  padding: 24px;
}

.ledger h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-family: var(--font-alien);
  font-weight: 400;
  font-size: 24px;
  color: var(--bile);
}

.count {
  display: inline-grid;
  place-content: center;
  min-width: 30px; height: 30px;
  padding: 0 8px;
  border-radius: 50% 50% 50% 6px;
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--flesh);
  color: #fff;
}

.ledger-note { margin: 4px 0 18px; font-size: 12px; color: var(--muted); }

.ledger-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.encounter {
  position: relative;
  padding: 16px 18px;
  border: 1px solid var(--glow-dim);
  border-radius: 22px 6px 22px 6px;
  background: rgba(13, 8, 34, 0.85);
  animation: emerge 0.6s ease-out;
}

@keyframes emerge {
  from { opacity: 0; transform: translateY(12px) scale(0.97); filter: blur(4px); }
}

.encounter-id { font-size: 11px; letter-spacing: 0.14em; color: var(--glow); }
.encounter-when { margin-top: 4px; font-weight: 700; }
.encounter-alien { font-size: 12px; font-style: italic; color: var(--muted); }
.encounter-what { margin-top: 8px; font-size: 13px; }

.wriggle {
  margin-top: 12px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--danger);
  background: transparent;
  border: 1px dashed rgba(255, 92, 138, 0.5);
  border-radius: 999px 999px 999px 4px;
  cursor: pointer;
}

.wriggle:hover { background: rgba(255, 92, 138, 0.12); }
.wriggle:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }

.ledger-empty {
  grid-column: 1 / -1;
  padding: 22px;
  text-align: center;
  font-style: italic;
  color: var(--muted);
  border: 1px dashed rgba(143, 132, 184, 0.3);
  border-radius: 22px;
}

/* ---------- confirmation ---------- */

dialog {
  max-width: min(520px, calc(100vw - 32px));
  width: 100%;
  padding: 0;
  border: 0;
  overflow: visible;
  background: transparent;
  color: var(--text);
}

dialog::backdrop {
  background: rgba(5, 3, 13, 0.78);
  backdrop-filter: blur(6px) hue-rotate(40deg);
}

dialog[open] .ticket { animation: absorb 0.7s cubic-bezier(0.2, 1.4, 0.4, 1); }

@keyframes absorb {
  from { opacity: 0; transform: scale(0.6) rotate(-4deg); filter: blur(10px); }
}

.ticket {
  padding: 32px 28px 24px;
  border: 1px solid var(--glow);
  border-radius: var(--radius-blob);
  background: linear-gradient(170deg, var(--trench), var(--abyss));
  box-shadow: 0 0 60px rgba(60, 255, 208, 0.25);
  text-align: center;
}

.ticket-kicker { margin: 0; font-size: 11px; letter-spacing: 0.2em; color: var(--glow); }

.ticket h2 {
  margin: 8px 0 0;
  font-family: var(--font-alien);
  font-weight: 400;
  font-size: 40px;
  color: var(--bile);
  text-shadow: 0 0 20px rgba(200, 255, 77, 0.6);
}

.ticket-sub { margin: 0 0 20px; color: var(--muted); }

.ticket-details {
  margin: 0 0 20px;
  padding: 16px 0;
  border-top: 2px dashed var(--glow-dim);
  border-bottom: 2px dashed var(--glow-dim);
  text-align: left;
}

.ticket-details div { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; padding: 4px 0; }
.ticket-details dt { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
.ticket-details dd { margin: 0; overflow-wrap: anywhere; }
#t-id { color: var(--glow); font-weight: 700; }

.ticket-warning { margin: 0 0 18px; font-style: italic; color: var(--danger); }

/* ---------- footer ---------- */

.footer {
  position: relative;
  z-index: 3;
  padding: 32px 24px 48px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.footer p { margin: 4px 0; }
.footer-glyphs { color: rgba(60, 255, 208, 0.4); letter-spacing: 0.2em; }

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 20px; padding: 24px 16px 16px; }
  .keeper { position: static; }
  #octopus { max-width: 260px; }
  .panel { padding: 28px 20px 24px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar-status { margin-left: 0; }
  .ledger { padding: 16px; }
  .ticket-details div { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .bubbles { display: none; }
}

.offer:disabled { cursor: progress; opacity: 0.7; animation: none; }
