:root {
  --bg: #0e0e12;
  --bg-raised: #17171d;
  --bg-sunken: #0a0a0d;
  --line: #2a2a33;
  --line-soft: #1f1f27;
  --text: #f2f2f5;
  --text-dim: #a0a0ad;
  --text-faint: #6f6f7c;

  --cex-red: #e1121c;
  --cex-red-dim: #a70d15;

  --band-0: #3fbf6f;
  --band-1: #e9d24a;
  --band-2: #e8a33d;
  --band-3: #e05a4e;
  --band-4: #9c4a44;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0 0 .5rem;
  line-height: 1.2;
}

p {
  margin: 0 0 .75rem;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-raised);
}

.topbar-right {
  display: flex;
  gap: .4rem;
  justify-content: flex-end;
}

.wordmark {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0;
  white-space: nowrap;
}

.wordmark-cex {
  color: var(--cex-red);
}

.icon-btn {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--cex-red);
  border-color: var(--cex-red);
  color: #fff;
}

/* ----------------------------------------------------------------- modes */

.modes {
  display: flex;
  justify-content: center;
  gap: .25rem;
  padding: .9rem 1rem 0;
}

.mode-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  padding: .38rem 1.1rem;
  border-radius: 999px;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}

.mode-tab.is-active {
  background: var(--cex-red);
  border-color: var(--cex-red);
  color: #fff;
}

/* ------------------------------------------------------------------ card */

.stage {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 1.1rem 1rem 2rem;
}

.card {
  width: 100%;
  max-width: 27rem;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-media {
  position: relative;
  background: #fff;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  transition: filter .3s;
}

.image-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #eee 30%, #f7f7f7 50%, #eee 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}

.image-skeleton[hidden] {
  display: none;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.card-body {
  padding: 1rem 1.1rem 1.2rem;
}

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: 0 0 .5rem;
  min-height: 1.2rem;
}

.chip {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .12rem .55rem;
}

.product-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 .9rem;
}

.prompt-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .7rem;
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: .9rem;
}

.prompt-badge {
  flex: 0 0 auto;
  width: 3.1rem;
  height: 2.1rem;
  background: var(--cex-red);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.prompt-badge-inner {
  font-size: .72rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.prompt-copy {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .6rem;
  font-size: .86rem;
  color: var(--text-dim);
}

.guess-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

/* --------------------------------------------------------------- guesses */

.guesses {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.guess-row {
  display: grid;
  grid-template-columns: 1fr 6.4rem;
  gap: .45rem;
}

.guess-input {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--text);
}

.guess-input:focus {
  outline: 2px solid var(--cex-red);
  outline-offset: 1px;
}

.guess-input:disabled {
  opacity: 1;
  color: #14141a;
  font-weight: 700;
  border-color: transparent;
}

.guess-input.band-0 { background: var(--band-0); }
.guess-input.band-1 { background: var(--band-1); }
.guess-input.band-2 { background: var(--band-2); }
.guess-input.band-3 { background: var(--band-3); }
.guess-input.band-4 { background: var(--band-4); }

.guess-verdict {
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--text);
  cursor: pointer;
  padding: .4rem;
  white-space: nowrap;
}

.guess-verdict:disabled {
  cursor: default;
  opacity: .95;
}

.guess-verdict.is-result {
  background: transparent;
  border-color: var(--line-soft);
  color: var(--text-dim);
}

.guess-error {
  grid-column: 1 / -1;
  color: var(--band-3);
  font-size: .8rem;
  margin: 0;
}

/* ---------------------------------------------------------------- reveal */

.reveal {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .7rem .8rem;
  margin-bottom: .9rem;
  background: var(--bg-sunken);
}

.reveal-headline {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.reveal-headline.is-win { color: var(--band-0); }
.reveal-headline.is-loss { color: var(--band-3); }

.reveal-meta {
  font-size: .82rem;
  color: var(--text-dim);
  margin: .25rem 0 0;
}

.reveal-prices {
  display: flex;
  gap: 1rem;
  margin-top: .5rem;
  font-size: .8rem;
  color: var(--text-dim);
}

.reveal-prices strong {
  display: block;
  color: var(--text);
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- buttons */

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .9rem;
}

.btn {
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.btn:hover {
  border-color: var(--text-faint);
}

.btn-primary {
  background: var(--cex-red);
  border-color: var(--cex-red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--cex-red-dim);
  border-color: var(--cex-red-dim);
}

.btn-quiet {
  color: var(--text-dim);
  font-weight: 500;
}

.btn-link {
  border-color: transparent;
  color: var(--text-dim);
  text-decoration: none;
  padding-left: .3rem;
}

.toast {
  margin: .6rem 0 0;
  font-size: .82rem;
  color: var(--band-0);
}

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

.footer {
  padding: 1rem 1.2rem 2rem;
  text-align: center;
  color: var(--text-faint);
  font-size: .74rem;
  max-width: 40rem;
  margin: 0 auto;
}

.footer p {
  margin: 0 0 .4rem;
}

.disclaimer {
  line-height: 1.45;
}

/* -------------------------------------------------------------- overlays */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .68);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.2rem;
  overflow-y: auto;
  z-index: 40;
}

.overlay[hidden] {
  display: none;
}

.overlay-panel {
  position: relative;
  width: 100%;
  max-width: 27rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.3rem;
  box-shadow: var(--shadow);
}

.overlay-wide {
  max-width: 38rem;
}

.overlay-close {
  position: absolute;
  top: .55rem;
  right: .7rem;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.overlay h2 {
  font-size: 1.25rem;
}

.overlay h3 {
  font-size: .95rem;
  margin-top: 1.2rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.legend,
.scoring {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: .88rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .2rem 0;
}

.legend .swatch {
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 5px;
  flex: 0 0 auto;
}

.scoring li {
  display: flex;
  justify-content: space-between;
  padding: .16rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.muted {
  color: var(--text-dim);
  font-size: .85rem;
}

/* ----------------------------------------------------------------- stats */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-bottom: .5rem;
}

.stat {
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: .55rem .3rem;
  text-align: center;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: .66rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.distribution {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: 1rem;
}

.dist-row {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
}

.dist-bar {
  background: var(--cex-red);
  color: #fff;
  border-radius: 4px;
  padding: .1rem .4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 1.6rem;
  text-align: right;
}

.dist-bar.is-empty {
  background: var(--line);
  color: var(--text-faint);
}

/* -------------------------------------------------------------- settings */

.field {
  margin-bottom: 1rem;
}

.field > label,
.field-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  margin-bottom: .35rem;
}

.field-help {
  font-size: .76rem;
  color: var(--text-faint);
  margin: .25rem 0 0;
}

.field select,
.field input[type="number"],
.field input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: .9rem;
  padding: .45rem .6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--text);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  max-height: 12rem;
  overflow-y: auto;
  padding: .15rem;
}

.chip-toggle {
  font: inherit;
  font-size: .78rem;
  padding: .22rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--text-dim);
  cursor: pointer;
}

.chip-toggle.is-on {
  background: var(--cex-red);
  border-color: var(--cex-red);
  color: #fff;
}

.chip-toggle .n {
  opacity: .6;
  font-size: .72rem;
  margin-left: .25rem;
}

.switch-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: .3rem .8rem;
}

.switch {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  cursor: pointer;
}

.switch input {
  accent-color: var(--cex-red);
  width: 1rem;
  height: 1rem;
}

details.group {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  margin-bottom: .7rem;
  background: var(--bg-sunken);
}

details.group > summary {
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  list-style: none;
}

details.group > summary::-webkit-details-marker {
  display: none;
}

details.group > summary::before {
  content: "▸ ";
  color: var(--cex-red);
}

details.group[open] > summary::before {
  content: "▾ ";
}

details.group > div {
  padding-top: .7rem;
}

.settings-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  border-top: 1px solid var(--line-soft);
  padding-top: .8rem;
  margin-top: .4rem;
  position: sticky;
  bottom: -1.4rem;
  background: var(--bg-raised);
}

.settings-buttons {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.pool-count {
  font-size: .82rem;
  color: var(--text-dim);
}

.pool-count strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.pool-count.is-empty strong {
  color: var(--band-3);
}

/* --------------------------------------------------------------- rounds */

.rounds {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .8rem;
}

.rounds[hidden] {
  display: none;
}

.round-pip {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: .18rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--text-dim);
}

.round-pip.is-won {
  background: var(--band-0);
  border-color: var(--band-0);
  color: #10231a;
}

.round-pip.is-lost {
  background: var(--band-3);
  border-color: var(--band-3);
  color: #2a100d;
}

.round-pip.is-current {
  border-color: var(--cex-red);
  color: var(--text);
  background: transparent;
}

/* Rounds not yet unlocked stay deliberately quiet. */
.round-pip.is-locked {
  opacity: .4;
}

.btn-bonus {
  background: var(--band-0);
  border-color: var(--band-0);
  color: #10231a;
  font-weight: 700;
}

.btn-bonus:hover {
  background: #35a75f;
  border-color: #35a75f;
}

.btn-bonus:disabled {
  opacity: .6;
  cursor: default;
}

/* -------------------------------------------------------------- admin */

.admin-login {
  max-width: 20rem;
}

.admin-login input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: .95rem;
  padding: .5rem .65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--text);
}

.admin-login input[type="password"]:focus {
  outline: 2px solid var(--cex-red);
  outline-offset: 1px;
}

.form-error {
  color: var(--band-3);
  font-size: .84rem;
  margin: 0 0 .6rem;
}

.admin-note {
  margin: .7rem 0 0;
  font-size: .84rem;
  color: var(--band-0);
}

.admin-note.is-error {
  color: var(--band-3);
}

.btn-danger {
  border-color: var(--band-3);
  color: var(--band-3);
}

.btn-danger:hover {
  border-color: var(--band-3);
  background: rgba(224, 90, 78, .12);
}

/* Armed state for the second, confirming click. */
.btn-danger.is-armed {
  background: var(--band-3);
  border-color: var(--band-3);
  color: #14141a;
}

.btn-danger:disabled {
  opacity: .6;
  cursor: default;
}

@media (max-width: 420px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-footer {
    justify-content: flex-start;
  }
}
