:root {
  color-scheme: dark;
  --paper: #09070d;
  --panel: #15101d;
  --panel-strong: #1f142c;
  --ink: #f7edf6;
  --muted: #b8a6c5;
  --red: #e53946;
  --red-dark: #9f1f2c;
  --purple: #7c3cff;
  --purple-soft: #2b1843;
  --line: #6f2bd4;
  --gold: #f0b44d;
  --shadow: 0 20px 46px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #0a0a0c;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  background: transparent;
}

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
}

.page-head {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 4px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.page-head .eyebrow {
  font-size: 1.05rem;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(320px, 1fr) minmax(250px, 310px);
  gap: 18px;
  align-items: start;
}

.stage,
.controls,
.results {
  border: 1px solid rgba(124, 60, 255, 0.42);
  border-radius: 14px;
  background: rgba(15, 10, 21, 0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  box-shadow: var(--shadow);
}

.stage {
  position: sticky;
  top: 22px;
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 20px;
  overflow: hidden;
}

.stage-copy {
  display: grid;
  gap: 2px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.65rem, 4vw, 3.25rem);
  background: linear-gradient(120deg, #b98aff 0%, #7c3cff 55%, #d4a4ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(2px 3px 0 #000000);
}

h2 {
  font-size: 1.25rem;
}

.card-title {
  width: min(280px, 100%);
  margin: 0 auto;
  padding: 9px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #c9932f, var(--gold));
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #1a1026;
  font-weight: 850;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-align: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}

.card-view {
  position: relative;
  width: min(280px, 100%);
  margin: 0 auto;
  display: grid;
  place-items: center;
}

.card-view img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 34px rgba(0, 0, 0, 0.58);
  transform: translateY(0) rotate(0deg);
  transition: transform 170ms ease, filter 170ms ease;
}

.card-view.is-spinning img {
  filter: saturate(1.18);
  transform: translateY(-4px) rotate(-1deg);
}

.card-glow {
  position: absolute;
  inset: 10% 0;
  background: linear-gradient(135deg, rgba(124, 60, 255, 0.42), rgba(185, 138, 255, 0.22), rgba(5, 3, 8, 0.35));
  filter: blur(24px);
}

.controls,
.results {
  padding: 16px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tool-button,
.category-button {
  min-height: 44px;
  border: 1px solid rgba(185, 138, 255, 0.35);
  border-radius: 10px;
  color: #f3eaff;
  background: linear-gradient(135deg, #3b1470 0%, #6428d9 60%, #7c3cff 100%);
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tool-button:hover,
.category-button:hover {
  background: linear-gradient(135deg, #4a1d8f 0%, #7433f2 60%, #9257ff 100%);
}

.tool-button {
  flex: 1;
  padding: 10px 12px;
  font-weight: 800;
}

.tool-button.ghost {
  color: var(--ink);
  background: var(--panel-strong);
  border: 2px solid rgba(124, 60, 255, 0.65);
  box-shadow: none;
}

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

.category-button {
  position: relative;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  overflow: hidden;
  text-align: left;
  font-weight: 850;
}

.category-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.34) 50%, transparent 100%);
  transform: translateX(-110%);
}

.category-button.is-spinning::after {
  animation: shine 0.5s linear infinite;
}

.category-button span {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.category-button .badge {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #1a1026;
  background: var(--gold);
  font-weight: 800;
  font-size: 0.84rem;
}

.results {
  position: sticky;
  top: 22px;
  min-height: calc(100vh - 44px);
}

.results ol {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.result-item {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 70px;
  padding: 8px;
  border: 1px solid rgba(185, 138, 255, 0.45);
  border-radius: 10px;
  background: rgba(31, 20, 44, 0.85);
}

.result-item img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--paper);
}

.result-text {
  min-width: 0;
}

.result-category {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-choice {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 850;
}

@keyframes shine {
  to {
    transform: translateX(110%);
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: minmax(280px, 340px) minmax(320px, 1fr);
  }

  .results {
    grid-column: 1 / -1;
    position: static;
    min-height: 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 18px, 460px);
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px 0 18px;
  }

  .stage {
    position: static;
    min-height: 0;
    padding: 16px;
  }

  h1 {
    font-size: 3.15rem;
  }

  .card-view {
    width: min(220px, 72vw);
  }

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