:root {
  --ink: #0d0a07;
  --night: #15100b;
  --panel: #1c1610;
  --panel-2: #241b13;
  --line: #3a2c1e;
  --line-soft: #2a2017;
  --stone: #8a7556;
  --stone-light: #b89f78;
  --bone: #ece2cf;
  --gold: #d8a14b;
  --gold-2: #f2c873;
  --danger: #ffb19a;
  --success: #e4c07d;
  --maxw: 1180px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(120% 90% at 78% -10%, rgba(216, 161, 75, 0.1), transparent 55%),
    radial-gradient(90% 70% at 8% 110%, rgba(197, 83, 43, 0.1), transparent 55%),
    var(--night);
  color: var(--bone);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  width: min(100%, var(--maxw));
  margin: 0 auto;
  padding: 0 24px;
}

#app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
  background: linear-gradient(var(--night), rgba(21, 16, 11, 0.72));
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.crest {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, var(--gold-2), var(--gold) 55%, #9a6f2c);
  box-shadow: 0 0 0 1px rgba(242, 200, 115, 0.4) inset, 0 6px 18px rgba(216, 161, 75, 0.25);
}

.crest svg {
  width: 18px;
  height: 18px;
  display: block;
}

.name {
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 14px;
}

.name small {
  display: block;
  margin-top: 1px;
  color: var(--stone);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.32em;
}

.ghost-btn,
.act,
.build {
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}

.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--stone-light);
  padding: 10px 15px;
  font: 600 12px/1 'Space Grotesk', sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.ghost-btn:hover,
.ghost-btn:focus-visible {
  color: var(--bone);
  border-color: var(--gold);
  outline: none;
}

.stage {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 54px;
  align-items: center;
  padding: 56px 0 40px;
}

.controls {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
  color: var(--gold);
  font: 600 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent);
}

h1 {
  margin: 0 0 20px;
  color: var(--bone);
  font-family: 'Fraunces', serif;
  font-size: clamp(38px, 5.4vw, 62px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.015em;
}

h1 em {
  color: var(--gold-2);
  font-style: italic;
}

.lede {
  max-width: 42ch;
  margin: 0 0 30px;
  color: var(--stone-light);
  font-size: 16px;
}

.lede b {
  color: var(--bone);
  font-weight: 500;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 9px;
  color: var(--stone);
  font: 600 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-shell {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.input-shell:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 161, 75, 0.16);
}

.at {
  color: var(--stone);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
}

#handleInput {
  flex: 1;
  min-width: 0;
  padding: 15px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--bone);
  font: 500 15px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

#handleInput::placeholder {
  color: #6b5942;
}

#handleInput:disabled {
  opacity: 0.8;
}

.build {
  border: 0;
  border-radius: 12px;
  padding: 0 22px;
  cursor: pointer;
  color: #3a2807;
  background: linear-gradient(var(--gold-2), var(--gold));
  box-shadow: 0 8px 22px rgba(216, 161, 75, 0.28);
  font: 700 14px/1 'Space Grotesk', sans-serif;
  letter-spacing: 0.02em;
}

.build:hover,
.build:focus-visible,
.act.primary:hover,
.act.primary:focus-visible,
.act.line:hover,
.act.line:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.build[aria-busy='true'] {
  opacity: 0.9;
}

.status-line {
  min-height: 22px;
  margin-top: 10px;
  color: var(--stone-light);
  font-size: 13px;
}

.status-line[data-tone='loading'] {
  color: var(--gold-2);
}

.status-line[data-tone='error'] {
  color: var(--danger);
}

.status-line[data-tone='success'] {
  color: var(--success);
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.stats-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 92px;
  padding: 14px 15px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(28, 22, 16, 0.82);
}

.stats-label {
  color: var(--stone);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.stats-chip strong {
  color: var(--bone);
  font-size: 15px;
}

.stats-chip span:last-child {
  color: var(--stone-light);
  font-size: 13px;
  line-height: 1.4;
}

.stats-meta {
  grid-column: 1 / -1;
  color: var(--stone);
  font-size: 12.5px;
  line-height: 1.5;
}

.poster-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.poster-frame {
  position: relative;
  width: 100%;
  max-width: 700px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    radial-gradient(60% 60% at 50% 46%, rgba(216, 161, 75, 0.14), transparent 62%),
    radial-gradient(120% 120% at 50% 120%, #120c07, #0b0805);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(242, 200, 115, 0.05) inset;
}

.svg-host,
.svg-host svg {
  display: block;
  width: 100%;
  height: 100%;
}

.svg-host .seat {
  cursor: pointer;
}

.svg-host .seat .seat-ring {
  transition: stroke 0.16s var(--ease), filter 0.16s var(--ease);
}

.svg-host .seat:hover .seat-ring,
.svg-host .seat:focus-visible .seat-ring {
  stroke: var(--gold-2);
  filter: drop-shadow(0 0 6px rgba(242, 200, 115, 0.42));
}

.poster-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  padding: 8px 10px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: var(--ink);
  color: var(--bone);
  font: 600 12px/1 'JetBrains Mono', monospace;
  transform: translate(-50%, calc(-100% - 12px));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  transition: opacity 0.16s var(--ease);
  white-space: nowrap;
}

.poster-tooltip b {
  color: var(--gold-2);
  font-weight: 700;
}

.poster-tooltip.on {
  opacity: 1;
}

.poster-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 11px;
  cursor: pointer;
  font: 600 13px/1 'Space Grotesk', sans-serif;
  letter-spacing: 0.02em;
}

.act.primary {
  border: 0;
  color: #3a2807;
  background: linear-gradient(var(--gold-2), var(--gold));
  box-shadow: 0 8px 20px rgba(216, 161, 75, 0.25);
}

.act.line {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--bone);
}

.act.line:hover,
.act.line:focus-visible {
  border-color: var(--gold);
}

.act:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
  transform: none;
}

.act:disabled:hover,
.act:disabled:focus-visible {
  transform: none;
  outline: none;
  border-color: var(--line);
}

.act.primary:disabled {
  background: linear-gradient(rgba(216, 161, 75, 0.5), rgba(216, 161, 75, 0.38));
  color: rgba(58, 40, 7, 0.74);
}

.act.line:disabled {
  background: rgba(28, 22, 16, 0.62);
  color: rgba(233, 224, 211, 0.58);
}

.caption {
  max-width: 46ch;
  margin: 0;
  color: var(--stone);
  font-size: 12px;
  text-align: center;
}

.page-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 0 24px 26px;
  color: var(--stone);
  font-size: 12px;
  text-align: center;
}

.centered-footer {
  text-align: center;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(7, 5, 3, 0.66);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

.scrim.on {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 70;
  width: min(560px, calc(100% - 32px));
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-50% + 18px));
  transition: opacity 0.24s var(--ease), transform 0.24s var(--ease);
}

.drawer.on {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 26px;
  border-bottom: 1px solid var(--line-soft);
}

.drawer header h2 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
}

.close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: none;
  color: var(--stone-light);
  cursor: pointer;
  font-size: 16px;
}

.close:hover,
.close:focus-visible {
  color: var(--bone);
  border-color: var(--gold);
  outline: none;
}

.body {
  overflow: auto;
  padding: 24px 26px;
  color: var(--stone-light);
  font-size: 14px;
}

.body p {
  margin: 0 0 16px;
}

.score {
  display: flex;
  gap: 13px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line-soft);
}

.pip {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--gold-2);
}

.score h3 {
  margin: 0 0 4px;
  color: var(--bone);
  font-size: 14px;
  font-weight: 600;
}

.score p {
  margin: 0;
  color: var(--stone);
  font-size: 13px;
}

.note {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--stone);
  font-size: 12.5px;
}

.note b {
  color: var(--stone-light);
}

@media (max-width: 920px) {
  .stage {
    grid-template-columns: 1fr;
    gap: 34px;
    padding: 34px 0 32px;
  }

  .controls {
    order: 1;
  }

  .poster-col {
    order: 2;
  }
}

@media (max-width: 680px) {
  .wrap {
    padding: 0 16px;
  }

  .topbar-inner {
    min-height: 68px;
  }

  .input-row,
  .stats-band {
    grid-template-columns: 1fr;
  }

  .input-row {
    display: grid;
  }

  .build {
    min-height: 50px;
  }

  .poster-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .act {
    width: 100%;
  }

  .page-footer {
    flex-direction: column;
    padding: 0 16px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition-duration: 0.001ms !important;
  }
}
