:root {
  --bg: #1b0813;
  --surface: #24101b;
  --border: #3e2832;
  --text: #ffdfdd;
  --muted: #9b8084;
  --primary: #cc1a97;
  --secondary: #6ea900;
  --accent: #f59994;
  --ink: #1b0813;
  --primary-hover: oklch(64% 0.23 335);
  --surface-raised: oklch(21% 0.035 346);
  --focus: oklch(78% 0.12 22);
  --tile-line: color-mix(in srgb, var(--accent) 15%, transparent);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 20%, rgba(204, 26, 151, .10), transparent 36rem),
    linear-gradient(90deg, rgba(245, 153, 148, .025) 1px, transparent 1px),
    linear-gradient(rgba(245, 153, 148, .025) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 42px 42px, 42px 42px, auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
[hidden] { display: none !important; }

.console {
  width: min(780px, calc(100% - 24px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.console-head, .console-foot {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .14em;
}

.wordmark { color: var(--text); text-decoration: none; font-family: Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: .11em; }
.wordmark-mark { color: var(--secondary); margin-right: 8px; letter-spacing: -.2em; }

.motion-control {
  min-height: 36px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .06em;
}
.motion-control:hover { border-color: var(--accent); }
.motion-glyph { color: var(--secondary); margin-right: 5px; }

.chamber {
  position: relative;
  min-height: 700px;
  margin: 16px 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 47%, rgba(245,153,148,.045) 48%, transparent 51%) 0 0 / 90px 90px,
    linear-gradient(45deg, transparent 47%, rgba(245,153,148,.035) 48%, transparent 51%) 0 0 / 120px 120px,
    linear-gradient(90deg, var(--tile-line) 1px, transparent 1px) 0 0 / 96px 100%,
    linear-gradient(var(--tile-line) 1px, transparent 1px) 0 0 / 100% 96px,
    var(--surface);
  box-shadow: inset 0 0 0 8px var(--bg), inset 0 0 0 9px var(--border);
}

.chamber::before, .chamber::after {
  content: '';
  position: absolute;
  left: 16px; right: 16px;
  height: 10px;
  opacity: .72;
  background: repeating-linear-gradient(90deg, var(--accent) 0 14px, transparent 14px 22px, var(--primary) 22px 30px, transparent 30px 38px);
  clip-path: polygon(0 0, 45% 0, 45% 50%, 55% 50%, 55% 0, 100% 0, 100% 100%, 52% 100%, 52% 50%, 48% 50%, 48% 100%, 0 100%);
}
.chamber::before { top: 16px; }
.chamber::after { bottom: 16px; transform: rotate(180deg); }

.corner { position: absolute; width: 24px; height: 24px; border-color: var(--accent); opacity: .55; }
.corner-a { top: 34px; left: 28px; border-top: 2px solid; border-left: 2px solid; }
.corner-b { right: 28px; bottom: 34px; border-right: 2px solid; border-bottom: 2px solid; }

.idle-state { width: min(520px, calc(100% - 48px)); text-align: center; }
.idle-arch {
  width: 190px;
  height: 275px;
  margin: 0 auto 28px;
  display: grid;
  place-items: end center;
  border: 1px solid var(--border);
  border-radius: 95px 95px 4px 4px;
  background: radial-gradient(circle at 50% 36%, rgba(204,26,151,.09), transparent 42%), var(--bg);
  box-shadow: 0 0 0 7px var(--surface), 0 0 0 8px var(--border);
}
.idle-stalk { width: 150px; height: 225px; opacity: .25; fill: none; stroke: var(--secondary); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.idle-stalk path:last-child { fill: color-mix(in srgb, var(--secondary) 20%, transparent); }

.eyebrow, .plate-kicker, .loading-kicker { margin: 0 0 10px; color: var(--accent); font-size: 11px; letter-spacing: .2em; }
h1, .plate-head h2 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-weight: 500; letter-spacing: .08em; }
h1 { font-size: clamp(38px, 9vw, 64px); }
.invitation { margin: 14px 0 26px; color: var(--muted); font-family: Georgia, 'Times New Roman', serif; font-style: italic; }

.load-button, .another-button {
  min-height: 52px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .08em;
}
.load-button { padding: 0 24px; color: var(--ink); background: var(--accent); border: 1px solid var(--accent); box-shadow: 5px 5px 0 var(--primary); }
.load-button:hover { transform: translate(1px, 1px); box-shadow: 4px 4px 0 var(--primary); }
.load-button:disabled { cursor: wait; opacity: .7; }
.load-button span { color: var(--primary); margin-right: 7px; }
.script-fallback { display: none; color: var(--accent); font-size: 12px; }
.no-js .script-fallback { display: block; }
.no-js .load-button { display: none; }

.loading-state { text-align: center; }
.loading-vessel {
  position: relative;
  width: 112px; height: 180px;
  margin: 0 auto 32px;
  display: grid; place-items: center;
  overflow: hidden;
  border: 2px solid var(--accent);
  border-radius: 56px 56px 5px 5px;
  color: var(--text);
  font: 34px Georgia, serif;
}
.loading-fill { position: absolute; inset: 100% 0 0; background: color-mix(in srgb, var(--secondary) 50%, var(--surface)); animation: vessel-fill 1.35s steps(3, end) forwards; }
.loading-vessel span { position: relative; z-index: 1; }
.loading-copy { min-height: 22px; margin: 0; font-family: Georgia, serif; font-size: 20px; }
.progress-steps { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.progress-steps i { width: 28px; height: 4px; background: var(--border); }
.progress-steps i.done { background: var(--secondary); }

.result-state { width: min(680px, calc(100% - 42px)); padding: 46px 0 36px; }
.routine-plate {
  width: 100%;
  min-height: 610px;
  padding: 30px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(245,153,148,.05) 25%, transparent 25%) 0 0 / 22px 22px,
    var(--bg);
  box-shadow: 0 0 0 7px var(--surface), 0 0 0 8px var(--border), 0 18px 50px rgba(0,0,0,.3);
}
.plate-head { position: relative; text-align: center; padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.plate-head h2 { font-size: clamp(32px, 6vw, 48px); }
.plate-kicker { margin-bottom: 6px; }
.routine-id { margin: 6px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .12em; }

.stage { position: relative; height: 300px; display: grid; place-items: center; overflow: hidden; }
.stage::before { content: ''; position: absolute; width: 270px; height: 260px; bottom: 14px; border: 1px solid var(--border); border-bottom: 0; border-radius: 140px 140px 0 0; background: radial-gradient(circle at center, rgba(204,26,151,.08), transparent 65%); }
.halo { position: absolute; width: 145px; height: 145px; top: 37px; border: 1px solid var(--primary); border-radius: 50%; opacity: .45; box-shadow: 0 0 26px rgba(204,26,151,.15); }
.celery-figure { position: relative; z-index: 1; width: clamp(205px, 42vw, 260px); height: 280px; margin-top: 8px; overflow: visible; }
.figure-shadow { fill: rgba(0,0,0,.35); }
.rib, .leaf { fill: var(--secondary); stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.rib-center { fill: color-mix(in srgb, var(--secondary) 78%, var(--accent)); }
.rib-line { fill: none; stroke: var(--bg); stroke-width: 2; opacity: .55; }
.arm, .leg { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; transform-box: fill-box; transform-origin: center; transition: transform .42s cubic-bezier(.2,.8,.2,1); }
.arm circle { fill: var(--accent); stroke: none; }
.figure-body { transform-box: fill-box; transform-origin: center bottom; transition: transform .42s cubic-bezier(.2,.8,.2,1); }
.leaf { transform-box: fill-box; transform-origin: bottom center; }
.face { fill: var(--bg); stroke: var(--bg); stroke-width: 2; stroke-linecap: round; }
.face path { fill: none; }
.current-move { position: absolute; z-index: 2; bottom: 8px; margin: 0; padding: 4px 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); font-size: 11px; letter-spacing: .14em; }

.pose-wave .arm-left { transform: rotate(48deg) translate(9px, -20px); }
.pose-wave .arm-right { transform: rotate(-48deg) translate(-4px, -27px); }
.pose-pivot .figure-body { transform: rotate(-7deg) translateX(-4px); }
.pose-pivot .leg-left { transform: rotate(34deg) translate(4px, -3px); }
.pose-pivot .leg-right { transform: rotate(-28deg) translate(-7px, -4px); }
.pose-ascend .figure-body { transform: translateY(-12px) scale(1.02); }
.pose-ascend .arm-left { transform: rotate(82deg) translate(19px, -34px); }
.pose-ascend .arm-right { transform: rotate(-73deg) translate(-12px, -35px); }
.pose-crisp .figure-body { transform: scaleX(.92) rotate(5deg); }
.pose-crisp .arm-left { transform: rotate(-31deg) translate(-8px, 10px); }
.pose-crisp .arm-right { transform: rotate(33deg) translate(8px, 8px); }
.pose-benediction .arm-right { transform: rotate(-92deg) translate(-29px, -25px); }
.pose-benediction .figure-body { transform: rotate(3deg); }

.move-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin: 2px 0 16px; padding: 0; list-style: none; }
.move-strip li { min-width: 0; min-height: 62px; padding: 9px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--border); color: var(--muted); font-size: 10px; line-height: 1.3; letter-spacing: .06em; overflow-wrap: anywhere; }
.move-strip li::before { content: attr(data-number); color: var(--accent); font-family: Georgia, serif; font-size: 13px; }
.move-strip li.active { border-color: var(--secondary); color: var(--text); background: color-mix(in srgb, var(--secondary) 12%, transparent); }
.plate-meta { display: flex; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.plate-meta b { color: var(--text); font-weight: 600; }

.another-button { display: block; margin: 28px auto 0; padding: 0 19px; color: var(--text); border: 1px solid var(--border); background: var(--surface-raised); }
.another-button:hover { border-color: var(--accent); }
.another-button span { color: var(--secondary); font-size: 18px; }
.live-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.console-foot { padding: 0 4px; }

@keyframes vessel-fill { to { inset: 0; } }

@media (max-width: 520px) {
  .console { padding-top: 12px; }
  .chamber { min-height: 660px; margin: 10px 0; }
  .console-head { min-height: 48px; }
  .motion-control { min-height: 40px; max-width: 145px; }
  .result-state { width: calc(100% - 30px); padding-top: 39px; }
  .routine-plate { min-height: 586px; padding: 22px 16px 18px; }
  .stage { height: 286px; }
  .stage::before { width: 238px; }
  .move-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .move-strip li { min-height: 52px; }
  .plate-meta { flex-wrap: wrap; justify-content: center; }
  .plate-meta span { flex: 1 1 28%; text-align: center; white-space: nowrap; }
  .console-foot { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
