:root {
  --gold-hi: #f0d78c;
  --gold: #d4af37;
  --gold-mid: #b8860b;
  --gold-lo: #8b6b23;
  --bronze: #6b4e16;
  --rust: #8b3a2a;
  --stone-0: #0c0a08;
  --stone-1: #1a1510;
  --stone-2: #2a2218;
  --cream: #f5e6c8;
  --danger: #c44b3a;
  --font-display: "Cinzel Decorative", "Cinzel", serif;
  --font-body: "Cinzel", Georgia, serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--stone-0);
  color: var(--cream);
  font-family: var(--font-body);
}

body {
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, #3a2e1f 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 50% 100%, #1a1008 0%, transparent 50%),
    linear-gradient(160deg, #1c1610 0%, #0a0806 45%, #14100c 100%);
}

/* Subtle stone grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  z-index: 0;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4vh 4vw 5vh;
  gap: clamp(2rem, 5vh, 4rem);
}

.brand {
  flex: 0 0 auto;
  margin-top: 1vh;
  margin-bottom: clamp(0.5rem, 2vh, 1.5rem);
}

.logo {
  display: block;
  height: clamp(110px, 22vh, 240px);
  width: auto;
  max-width: min(94vw, 720px);
  object-fit: contain;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.65));
}

.display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: min(96vw, 1400px);
  gap: clamp(2rem, 6vh, 4.5rem);
  padding-bottom: 2vh;
}

.timer {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(6.5rem, 24vw, 18rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--gold-hi);
  background: linear-gradient(180deg, #fff3c4 0%, var(--gold) 38%, var(--gold-mid) 72%, var(--bronze) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 28px rgba(212, 175, 55, 0.35));
  font-variant-numeric: tabular-nums;
  transition: filter 0.25s ease;
  margin: clamp(0.5rem, 2vh, 1.5rem) 0;
}

.timer[data-state="running"] {
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 36px rgba(240, 215, 140, 0.55));
}

.timer[data-state="paused"] {
  opacity: 0.85;
}

.timer[data-state="ended"] {
  background: linear-gradient(180deg, #ffd0c4 0%, var(--danger) 45%, #6b1e14 100%);
  -webkit-background-clip: text;
  background-clip: text;
  animation: pulse-end 0.9s ease-in-out infinite;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 40px rgba(196, 75, 58, 0.65));
}

@keyframes pulse-end {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

.team-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 6.5vw, 5.5rem);
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow:
    0 2px 0 var(--bronze),
    0 4px 18px rgba(0, 0, 0, 0.7);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.stats {
  display: flex;
  gap: clamp(2rem, 7vw, 5.5rem);
  margin-top: clamp(0.5rem, 2vh, 1.5rem);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: clamp(7rem, 18vw, 14rem);
  padding: clamp(0.75rem, 2vh, 1.5rem) clamp(1rem, 3vw, 2.5rem);
  border-radius: 0.85rem;
  background:
    linear-gradient(165deg, rgba(212, 175, 55, 0.18), rgba(20, 14, 8, 0.75)),
    var(--stone-2);
  border: 3px solid var(--gold-lo);
  box-shadow:
    inset 0 1px 0 rgba(240, 215, 140, 0.25),
    0 8px 24px rgba(0, 0, 0, 0.45);
}

.stat-label {
  font-size: clamp(0.85rem, 1.8vw, 1.35rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.9;
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.5vw, 4.5rem);
  font-weight: 700;
  color: var(--gold-hi);
  line-height: 1.1;
  margin-top: 0.15em;
}

/* —— Setup panel —— */
.setup {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  width: min(380px, 100vw);
  height: 100%;
  padding: 1.5rem 1.35rem 2rem;
  overflow-y: auto;
  background: linear-gradient(200deg, #2a2218 0%, #12100c 100%);
  border-left: 3px solid var(--gold-lo);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

body.mode-show .setup {
  transform: translateX(105%);
  opacity: 0;
  pointer-events: none;
}

body.mode-setup .stage {
  padding-right: min(400px, 100vw);
}

@media (max-width: 720px) {
  body.mode-setup .stage {
    padding-right: 4vw;
    padding-bottom: 45vh;
  }

  .setup {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 48vh;
    border-left: none;
    border-top: 3px solid var(--gold-lo);
  }

  body.mode-show .setup {
    transform: translateY(105%);
  }
}

.setup h2 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.setup label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(245, 230, 200, 0.75);
}

.setup input[type="text"],
.setup input[type="number"] {
  font-family: var(--font-body);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 0.65rem 0.75rem;
  border-radius: 0.4rem;
  border: 2px solid var(--gold-lo);
  background: var(--stone-0);
  color: var(--cream);
  outline: none;
}

.setup input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.25);
}

.field-hint {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: none;
  color: rgba(245, 230, 200, 0.45);
  line-height: 1.35;
}

.setup-preview {
  padding: 0.85rem 1rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.35);
  font-size: 0.95rem;
}

.setup-preview strong {
  color: var(--gold-hi);
  font-size: 1.25rem;
  margin-left: 0.25rem;
}

.preview-bonus {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--gold);
}

.setup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.btn {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.85rem 1rem;
  border-radius: 0.45rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s ease, filter 0.12s ease;
}

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

.btn-gold {
  color: var(--stone-0);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-mid));
  border-color: var(--bronze);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.btn-gold:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  color: var(--gold);
  background: transparent;
  border-color: var(--gold-lo);
}

.btn-ghost:hover {
  background: rgba(212, 175, 55, 0.1);
}
