:root {
  --bg: #120e0b;
  --ink: #f4efe6;
  --muted: #b5a794;
  --gold: #d7b46a;
  --gold-bright: #f0d395;
  --wood: #4a2a18;
  --teal: #2f8f86;
  --line: rgba(244, 239, 230, 0.12);
  --glass: rgba(28, 22, 18, 0.72);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
  --display: "Cormorant Garamond", Georgia, serif;
  --body: "Manrope", sans-serif;
  --radius: 16px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body);
  background: var(--bg);
  line-height: 1.45;
  font-size: 14px;
  overflow-x: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

/* ===== Atmosphere ===== */
.scene-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(215, 180, 106, 0.18), transparent 42%),
    radial-gradient(ellipse at 20% 80%, rgba(47, 143, 134, 0.12), transparent 40%),
    linear-gradient(180deg, #1a1410 0%, #0d0a08 100%);
}

.spot {
  position: absolute;
  width: 48vw;
  height: 48vw;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: floaty 16s ease-in-out infinite alternate;
}

.spot-l {
  top: -10vw;
  left: -8vw;
  background: #8b5a2b;
}

.spot-r {
  right: -10vw;
  bottom: 5vh;
  background: #1f6a63;
  animation-delay: -5s;
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
}

.curtain {
  position: absolute;
  top: 0;
  width: min(12vw, 140px);
  height: 100%;
  opacity: 0.4;
  background:
    repeating-linear-gradient(
      90deg,
      #4a1418 0 14px,
      #5c1a1f 14px 28px
    );
  filter: saturate(0.85);
}

.curtain-l {
  left: 0;
  box-shadow: inset -30px 0 40px rgba(0, 0, 0, 0.45);
}

.curtain-r {
  right: 0;
  box-shadow: inset 30px 0 40px rgba(0, 0, 0, 0.45);
}

@keyframes floaty {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(3vw, 2vh) scale(1.08); }
}

.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
}

/* ===== Header ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(0.9rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand-kicker {
  margin: 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.62rem;
  color: var(--gold);
}

.brand-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3.2vw, 2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff6e4 10%, var(--gold) 70%, #9a7435 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mode-tabs {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  gap: 0.15rem;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.25s ease;
  font-size: 0.9rem;
}

.tab.active {
  color: #1a1208;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(215, 180, 106, 0.28);
}

main {
  width: min(980px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 0.85rem 0 2rem;
}

.panel {
  display: none;
  animation: enter 0.55s ease both;
}

.panel.is-active {
  display: block;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.intro {
  text-align: center;
  max-width: 36rem;
  margin: 0 auto 0.55rem;
}

.intro h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.2rem, 2.4vw, 1.45rem);
  font-weight: 600;
}

.intro p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-height: 820px) {
  .intro p {
    display: none;
  }
}

/* ===== Theater / Doors ===== */
.theater {
  display: grid;
  gap: 0.65rem;
}

.proscenium {
  position: relative;
  padding: 0.65rem 0.7rem 0.5rem;
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(215, 180, 106, 0.2), transparent 52%),
    linear-gradient(180deg, rgba(48, 32, 22, 0.95), rgba(14, 10, 8, 0.98));
  border: 1px solid rgba(215, 180, 106, 0.22);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doors {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: clamp(1.75rem, 4.5vw, 3rem);
  height: min(38vh, 320px);
  perspective: 1600px;
}

.door {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  height: 100%;
  aspect-ratio: 3 / 3.4;
  width: auto;
  max-width: calc((100% - 6rem) / 3);
  transition: transform 0.3s ease;
}

.door:not(:disabled):hover {
  transform: translateY(-4px);
}

.door:disabled {
  cursor: default;
}

.door-well {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  perspective: 1200px;
}

.door-prize {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, #2a221c, #090807 72%);
  border: 1px solid rgba(215, 180, 106, 0.28);
  display: grid;
  place-items: center;
  padding: 0.35rem;
}

.prize-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.prize-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.12);
  transition: opacity 0.5s ease 0.25s, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.25s;
  filter: brightness(0.95) saturate(1.05);
}

.prize-img.is-car {
  object-position: center 55%;
}

.prize-img.is-goat {
  object-position: center 35%;
}

.door.is-open .prize-img.visible {
  opacity: 1;
  transform: scale(1);
}

.prize-caption {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%) translateY(8px);
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(215, 180, 106, 0.35);
  color: var(--gold-bright);
  opacity: 0;
  transition: opacity 0.35s ease 0.45s, transform 0.35s ease 0.45s;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.door.is-open .prize-img.is-car.visible ~ .is-car-cap,
.door.is-open .prize-img.is-goat.visible ~ .is-goat-cap {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.prize-glow {
  position: absolute;
  inset: auto 8% 4%;
  height: 34%;
  background: radial-gradient(ellipse, rgba(215, 180, 106, 0.42), transparent 70%);
  opacity: 0;
  transition: opacity 0.5s ease 0.35s;
  pointer-events: none;
}

.door.is-open.is-win .prize-glow {
  opacity: 1;
  animation: win-pulse 1.8s ease-in-out infinite;
}

@keyframes win-pulse {
  0%, 100% { opacity: 0.55; transform: scaleX(1); }
  50% { opacity: 1; transform: scaleX(1.08); }
}

.door-leaf {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.35s cubic-bezier(0.45, 0.05, 0.2, 1);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.door-texture {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
}

.door-badge {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #2a1a0a;
  background: linear-gradient(180deg, #f3dfad, #c79a45);
  border: 1px solid rgba(255, 240, 200, 0.55);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.door.is-open .door-leaf {
  transform: rotateY(-102deg);
  box-shadow: 8px 10px 24px rgba(0, 0, 0, 0.35);
}

.door.is-selected:not(.is-open) .door-leaf {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(215, 180, 106, 0.18), 0 18px 40px rgba(0, 0, 0, 0.45);
}

.door.is-final:not(.is-open) .door-leaf {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(47, 143, 134, 0.2), 0 18px 40px rgba(0, 0, 0, 0.45);
}

.stage-floor {
  margin-top: 0.55rem;
  height: 18px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(215, 180, 106, 0.18), transparent),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 18px, transparent 18px 36px);
  transform: perspective(240px) rotateX(55deg);
  opacity: 0.55;
}

.host-panel {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.45rem 0.85rem;
  padding: 0.55rem 0.85rem;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(48, 34, 24, 0.92), rgba(22, 16, 12, 0.92));
  border: 1px solid rgba(215, 180, 106, 0.22);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.host-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}

.host-label {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.65rem;
}

.voice-toggle {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.voice-toggle.is-on {
  color: #1a1208;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border-color: transparent;
  font-weight: 600;
}

.host-line {
  margin: 0;
  max-width: 28rem;
  font-family: var(--display);
  font-size: clamp(0.98rem, 1.6vw, 1.15rem);
  line-height: 1.25;
  min-height: 0;
}

.host-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.host-actions[hidden],
.panel[hidden],
.result-banner[hidden],
.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: enter 0.28s ease both;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 5, 3, 0.72);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 1.35rem 1.4rem 1.45rem;
  border-radius: 18px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(56, 40, 28, 0.98), rgba(24, 16, 12, 0.98));
  border: 1px solid rgba(215, 180, 106, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-kicker {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.modal-title {
  margin: 0.55rem 0 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
}

.modal-desc {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1.15rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-gold {
  color: #1a1208;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  box-shadow: 0 12px 28px rgba(215, 180, 106, 0.28);
}

.btn-gold:hover {
  box-shadow: 0 14px 34px rgba(215, 180, 106, 0.4);
}

.btn-line {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.btn-line:hover {
  border-color: rgba(215, 180, 106, 0.5);
  background: rgba(215, 180, 106, 0.08);
}

.linkish {
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  padding: 0;
}

/* ===== Sheets / tables ===== */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.sheet {
  padding: 0.85rem 0.95rem 1rem;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.sheet-wide {
  margin-top: 0.75rem;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sheet-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
}

.sheet-desc {
  margin: 0.2rem 0 0.65rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.sheet-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-scroll {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.65rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.data-table thead th {
  background: rgba(215, 180, 106, 0.08);
  color: var(--gold);
  font-weight: 600;
  font-size: 0.88rem;
}

.data-table tbody th {
  text-align: left;
  font-weight: 700;
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.sum-row td {
  background: linear-gradient(90deg, rgba(215, 180, 106, 0.25), rgba(240, 211, 149, 0.55));
  color: #24180a;
  font-weight: 700;
  border-bottom: 0;
}

#p-total {
  font-size: 1.12rem;
}

.sim-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
  margin-bottom: 0.65rem;
}

.sim-row label,
.chest-controls label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.sim-row input,
.chest-controls input {
  width: min(140px, 100%);
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  outline: none;
}

.sim-row input:focus,
.chest-controls input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 180, 106, 0.18);
}

/* ===== Chests ===== */
.chests {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1rem, 2.5vw, 1.75rem);
}

.chest-card {
  padding: 0.7rem;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: enter 0.55s ease both;
}

.chest-card:nth-child(2) {
  animation-delay: 0.08s;
}

.chest-visual {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1 / 1.05;
  max-height: 360px;
  width: 100%;
  margin: 0 auto;
  background:
    radial-gradient(circle at 50% 30%, #3a2a1c, #120e0b 70%);
  box-shadow: inset 0 0 0 1px rgba(215, 180, 106, 0.15);
}

.chest-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  transition: transform 0.55s ease, filter 0.4s ease;
  filter: saturate(1.05) contrast(1.04);
}

.chest-card:hover .chest-img {
  transform: scale(1.045);
  filter: saturate(1.1) contrast(1.06) brightness(1.04);
}

.ball-cloud {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  width: 58%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  max-height: 38%;
  overflow: hidden;
  pointer-events: none;
  padding: 0.45rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.35));
}

.ball {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.28), 0 2px 4px rgba(0, 0, 0, 0.35);
  animation: ball-in 0.4s ease both;
}

.ball-cloud.is-few {
  bottom: 22%;
  width: auto;
  min-width: 72px;
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(215, 180, 106, 0.28);
  backdrop-filter: blur(4px);
}

.ball-cloud.is-few .ball {
  width: 22px;
  height: 22px;
}

.ball.white {
  background: radial-gradient(circle at 30% 30%, #fff, #d7dbe2);
}

.ball.black {
  background: radial-gradient(circle at 30% 30%, #555, #111);
}

@keyframes ball-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.5);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chest-tag {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(215, 180, 106, 0.35);
  color: var(--gold-bright);
  font-size: 0.82rem;
  backdrop-filter: blur(6px);
}

.chest-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.chest-controls input {
  width: 100%;
}

.chest-auto {
  margin-top: 0.65rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.chest-auto p {
  margin: 0.15rem 0;
}

.chest-counts strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
}

.chip-btn {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: 0.2s ease;
}

.chip-btn:hover {
  border-color: rgba(215, 180, 106, 0.5);
  background: rgba(215, 180, 106, 0.1);
}

.box-pill {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
}

.box-pill-a {
  background: #8a5a2b;
}

.box-pill-b {
  background: #2f5f78;
}

.result-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(47, 143, 134, 0.4);
  background: rgba(47, 143, 134, 0.12);
  animation: enter 0.4s ease both;
}

.result-banner em {
  margin-left: 0.35rem;
  font-style: normal;
  color: var(--gold-bright);
  font-weight: 700;
}

.site-footer {
  text-align: center;
  padding: 0.85rem;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 960px) {
  .data-grid,
  .chests {
    grid-template-columns: 1fr;
  }

  .curtain {
    display: none;
  }
}

@media (max-width: 720px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .doors {
    height: min(34vh, 280px);
  }

  .chest-visual {
    max-height: 300px;
  }

  .host-panel {
    flex-direction: column;
    gap: 0.35rem;
  }

  .door-badge {
    min-width: 1.45rem;
    height: 1.45rem;
    font-size: 0.9rem;
    top: 14%;
  }
}
