/* ═══════════════════════════════════════════════════════════════
   QUICKDRAW DUEL — "Sunset Bounty" Theme
   
   Google Fonts required (add to <head>):
   <link href="https://fonts.googleapis.com/css2?family=Rye&family=Special+Elite&family=IM+Fell+English+SC&display=swap" rel="stylesheet">
   ═══════════════════════════════════════════════════════════════ */

/* ── Palette ─────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep:      #0e0b08;
  --bg-dust:      #1a1410;
  --bg-leather:   #2a1f16;

  /* Text */
  --parchment:    #d4c4a0;
  --parchment-dim: rgba(212, 196, 160, 0.55);
  --ink:          #1a1410;

  /* Accents */
  --gold:         #c9a84c;
  --gold-bright:  #e8c84a;
  --blood:        #8b2500;
  --blood-glow:   #c0392b;
  --sage:         #6b8f5e;
  --sage-glow:    #7fbf6b;
  --rust:         #a0522d;

  /* Surfaces */
  --panel:        rgba(26, 20, 16, 0.75);
  --panel-border: rgba(212, 196, 160, 0.12);
  --panel-glow:   rgba(201, 168, 76, 0.06);

  /* Grain */
  --grain-opacity: 0.035;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--parchment);
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 16px;
  line-height: 1.5;

  /* Layered western sky gradient */
  background:
    /* Vignette — dark edges */
    radial-gradient(ellipse 70% 60% at 50% 45%, transparent 40%, rgba(0,0,0,0.7) 100%),
    /* Warm dust glow from horizon */
    radial-gradient(ellipse 100% 50% at 50% 80%, rgba(160, 82, 45, 0.15) 0%, transparent 70%),
    /* Moon/sun spotlight */
    radial-gradient(circle 300px at 72% 18%, rgba(201, 168, 76, 0.08) 0%, transparent 100%),
    /* Base gradient */
    linear-gradient(175deg, #12100c 0%, #1a1410 35%, #231a12 65%, #0e0b08 100%);
  background-attachment: fixed;

  display: grid;
  place-items: center;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Film Grain Overlay (CSS-only) ───────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px;
  mix-blend-mode: overlay;
}

/* Scanline effect — subtle CRT/film feel */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ── Game Container ──────────────────────────────────────────── */
.game {
  width: min(720px, 94vw);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

/* ── Tap Starter Overlay ─────────────────────────────────────── */
.tap-starter {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(14, 11, 8, 0.97);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.tap-starter.hidden {
  display: none;
}

.tap-starter-content {
  text-align: center;
  padding: 40px;
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.tap-starter-text {
  font-family: 'Special Elite', monospace;
  font-size: clamp(18px, 3.5vw, 28px);
  color: var(--parchment);
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

/* ── Story Overlay ───────────────────────────────────────────── */
.story-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(14, 11, 8, 0.95);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 600ms ease;
}

.story-overlay.hidden {
  display: none;
}

.story-content {
  max-width: 560px;
  padding: 40px;
  border: 3px solid var(--panel-border);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 
    0 0 0 1px rgba(201, 168, 76, 0.1),
    0 30px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.story-text {
  font-family: 'Special Elite', monospace;
  font-size: clamp(15px, 2.5vw, 19px);
  line-height: 1.7;
  color: var(--parchment);
  margin: 0 0 30px 0;
  letter-spacing: 0.02em;
}

.story-controls {
  font-family: 'Special Elite', monospace;
  font-size: clamp(13px, 2vw, 16px);
  color: var(--parchment-dim);
  margin: 0 0 30px 0;
  letter-spacing: 0.02em;
}

.story-controls strong {
  color: var(--gold-bright);
  font-weight: normal;
}

/* ── Opponent Intro Screen ───────────────────────────────────── */
.opponent-intro {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(14, 11, 8, 0.95);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 600ms ease;
}

.opponent-intro.hidden {
  display: none;
}

.opponent-intro-content {
  max-width: 500px;
  padding: 40px;
  border: 3px solid var(--panel-border);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 
    0 0 0 1px rgba(201, 168, 76, 0.1),
    0 30px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.opponent-portrait-container {
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
  border: 2px solid var(--gold);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.opponent-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.opponent-name {
  font-family: 'Rye', 'Georgia', serif;
  font-size: clamp(24px, 4vw, 32px);
  color: var(--gold);
  margin: 0 0 20px 0;
  letter-spacing: 0.05em;
}

.opponent-dialogue {
  font-family: 'Special Elite', monospace;
  font-size: clamp(14px, 2.5vw, 18px);
  line-height: 1.6;
  color: var(--parchment);
  margin: 0 0 30px 0;
  font-style: italic;
}

/* ── Victory Screen ──────────────────────────────────────────── */
.victory-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(14, 11, 8, 0.95);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 600ms ease;
}

.victory-screen.hidden {
  display: none;
}

.victory-content {
  max-width: 450px;
  padding: 40px;
  border: 3px solid var(--sage);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 
    0 0 0 1px rgba(107, 143, 94, 0.2),
    0 30px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.victory-title {
  font-family: 'Rye', 'Georgia', serif;
  font-size: clamp(28px, 5vw, 40px);
  color: var(--sage-glow);
  margin: 0 0 20px 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.victory-opponent-portrait-container {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  border: 2px solid var(--sage);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.victory-opponent-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.3);
}

.victory-dialogue {
  font-family: 'Special Elite', monospace;
  font-size: clamp(14px, 2.5vw, 17px);
  line-height: 1.6;
  color: var(--parchment-dim);
  margin: 0 0 25px 0;
  font-style: italic;
}

.victory-stats {
  margin: 0 0 30px 0;
  padding: 20px;
  border: 1px solid rgba(212, 196, 160, 0.1);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}

.victory-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.victory-stat-label {
  font-family: 'Special Elite', monospace;
  font-size: 14px;
  color: var(--parchment-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.victory-stat-value {
  font-family: 'IM Fell English SC', 'Georgia', serif;
  font-size: 24px;
  color: var(--sage-glow);
  font-weight: 400;
}

/* ── Loss Screen ─────────────────────────────────────────────── */
.loss-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(14, 11, 8, 0.95);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 600ms ease;
}

.loss-screen.hidden {
  display: none;
}

.loss-content {
  max-width: 450px;
  padding: 40px;
  border: 3px solid var(--rust);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 
    0 0 0 1px rgba(255, 90, 95, 0.2),
    0 30px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.loss-title {
  font-family: 'Rye', 'Georgia', serif;
  font-size: clamp(28px, 5vw, 40px);
  color: var(--rust-glow);
  margin: 0 0 20px 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.loss-opponent-portrait-container {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  border: 2px solid var(--rust);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.loss-opponent-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loss-dialogue {
  font-family: 'Special Elite', monospace;
  font-size: clamp(14px, 2.5vw, 17px);
  line-height: 1.6;
  color: var(--parchment-dim);
  margin: 0 0 20px 0;
  font-style: italic;
}

.loss-message {
  font-family: 'Special Elite', monospace;
  font-size: clamp(12px, 2vw, 15px);
  color: var(--parchment-dim);
  margin: 0 0 30px 0;
}

/* ── Ending Screen ───────────────────────────────────────────── */
.ending-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(1200px 700px at 50% 20%, rgba(201, 168, 76, 0.08), transparent 60%),
              linear-gradient(135deg, rgba(11, 19, 32, 0.98), rgba(29, 15, 7, 0.98));
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 800ms ease;
  overflow-y: auto;
}

.ending-screen.hidden {
  display: none;
}

.ending-content {
  max-width: 600px;
  padding: 50px 40px;
  text-align: center;
}

.ending-title {
  font-family: 'Rye', 'Georgia', serif;
  font-size: clamp(36px, 6vw, 56px);
  color: var(--gold);
  margin: 0 0 10px 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 4px 12px rgba(201, 168, 76, 0.4);
}

.ending-subtitle {
  font-family: 'IM Fell English SC', 'Georgia', serif;
  font-size: clamp(20px, 3.5vw, 28px);
  color: var(--parchment);
  margin: 0 0 40px 0;
  letter-spacing: 0.05em;
  font-weight: 400;
}

.ending-image-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 30px;
  border: 3px solid var(--gold);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 8px 30px rgba(201, 168, 76, 0.3);
}

.ending-image {
  width: 100%;
  height: auto;
  display: block;
}

.ending-text {
  font-family: 'Special Elite', monospace;
  font-size: clamp(15px, 2.5vw, 18px);
  line-height: 1.8;
  color: var(--parchment);
  margin: 0 0 40px 0;
  letter-spacing: 0.02em;
}

.ending-stats {
  margin: 0 0 40px 0;
  padding: 30px 25px;
  border: 2px solid rgba(201, 168, 76, 0.3);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
}

.ending-stats-title {
  font-family: 'Rye', 'Georgia', serif;
  font-size: clamp(18px, 3vw, 24px);
  color: var(--gold);
  margin: 0 0 20px 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ending-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.ending-stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.ending-stat-label {
  font-family: 'Special Elite', monospace;
  font-size: clamp(11px, 1.8vw, 13px);
  color: var(--parchment-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ending-stat-value {
  font-family: 'IM Fell English SC', 'Georgia', serif;
  font-size: clamp(22px, 4vw, 32px);
  color: var(--gold-bright);
  font-weight: 400;
}

@media (max-width: 500px) {
  .ending-stats-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* ── HUD / Header ────────────────────────────────────────────── */
.hud {
  text-align: center;
  position: relative;
}

.title {
  margin: 0;
  font-family: 'Rye', 'Georgia', serif;
  font-size: clamp(26px, 4.5vw, 42px);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow:
    0 0 30px rgba(201, 168, 76, 0.3),
    0 2px 0 rgba(0, 0, 0, 0.6),
    0 4px 8px rgba(0, 0, 0, 0.4);
  /* Slight western "arch" feel */
  text-transform: uppercase;
}

/* Decorative divider under title */
.title::after {
  content: '⟡ ✦ ⟡';
  display: block;
  font-size: 0.35em;
  letter-spacing: 0.5em;
  color: var(--parchment-dim);
  margin-top: 6px;
  text-shadow: none;
}

.tagline {
  margin: 8px 0 0 0;
  color: var(--parchment-dim);
  font-family: 'Special Elite', monospace;
  font-size: clamp(13px, 2vw, 16px);
  letter-spacing: 0.03em;
}

.tagline strong {
  color: var(--gold-bright);
  font-family: 'Rye', serif;
  letter-spacing: 0.08em;
}

/* ── Difficulty Selector ─────────────────────────────────────── */
.difficulty-selector {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.difficulty-label {
  font-family: 'Special Elite', monospace;
  font-size: 13px;
  color: var(--parchment-dim);
  letter-spacing: 0.05em;
}

.difficulty-btn {
  padding: 6px 14px;
  border: 1px solid rgba(212, 196, 160, 0.25);
  border-radius: 3px;
  background: transparent;
  color: var(--parchment-dim);
  font-family: 'Special Elite', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms ease;
  letter-spacing: 0.05em;
}

.difficulty-btn:hover {
  border-color: rgba(201, 168, 76, 0.4);
  color: var(--parchment);
}

.difficulty-btn.active {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* Hide difficulty selector when not idle */
.game[data-state="waiting"] .difficulty-selector,
.game[data-state="draw"] .difficulty-selector,
.game[data-state="result"] .difficulty-selector {
  display: none;
}

/* ── Stage — The Showdown Arena ──────────────────────────────── */
.dust-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.game[data-state="waiting"] .dust-particles,
.game[data-state="draw"] .dust-particles {
  opacity: 1;
}

.dust {
  position: absolute;
  background: rgba(212, 196, 160, 0.3);
  border-radius: 50%;
  pointer-events: none;
  animation: float-dust linear infinite;
}

.dust:nth-child(1) {
  width: 3px;
  height: 3px;
  left: 10%;
  top: -10%;
  animation-duration: 15s;
  animation-delay: 0s;
}

.dust:nth-child(2) {
  width: 2px;
  height: 2px;
  left: 30%;
  top: -10%;
  animation-duration: 12s;
  animation-delay: 2s;
}

.dust:nth-child(3) {
  width: 4px;
  height: 4px;
  left: 60%;
  top: -10%;
  animation-duration: 18s;
  animation-delay: 4s;
}

.dust:nth-child(4) {
  width: 2px;
  height: 2px;
  left: 80%;
  top: -10%;
  animation-duration: 14s;
  animation-delay: 1s;
}

.dust:nth-child(5) {
  width: 3px;
  height: 3px;
  left: 45%;
  top: -10%;
  animation-duration: 16s;
  animation-delay: 3s;
}

@keyframes float-dust {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.3;
  }
  90% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(110vh) translateX(20px);
    opacity: 0;
  }
}

.duel-opponent-info {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 280px;
  background: rgba(0, 0, 0, 0.75);
  padding: 10px 14px;
  border-radius: 6px;
  border: 2px solid rgba(201, 168, 76, 0.4);
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.duel-opponent-info[hidden] {
  display: none;
}

.duel-opponent-portrait {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border-radius: 3px;
  border: 1px solid var(--gold);
  object-fit: cover;
}

.duel-opponent-name {
  font-family: 'Rye', 'Georgia', serif;
  font-size: clamp(12px, 2vw, 14px);
  color: var(--gold);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muzzle-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(255, 200, 0, 0.4) 30%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 100;
  animation: flash 100ms ease-out;
}

@keyframes flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.tumbleweed {
  position: absolute;
  bottom: 30%;
  left: -10%;
  font-size: clamp(30px, 5vw, 50px);
  opacity: 0.4;
  animation: tumbleweed-roll 8s linear infinite;
  pointer-events: none;
  filter: sepia(0.3);
}

@keyframes tumbleweed-roll {
  from {
    left: -10%;
    transform: rotate(0deg);
  }
  to {
    left: 110%;
    transform: rotate(720deg);
  }
}

.stage {
  min-height: 46vh;
  border-radius: 4px;
  position: relative;
  overflow: hidden;

  /* Wanted-poster / aged-paper border */
  border: 3px solid var(--panel-border);
  border-image: linear-gradient(
    180deg,
    rgba(201, 168, 76, 0.25) 0%,
    rgba(160, 82, 45, 0.15) 50%,
    rgba(201, 168, 76, 0.25) 100%
  ) 1;

  background:
    /* Inner vignette for depth */
    radial-gradient(ellipse 80% 70% at 50% 50%, transparent 30%, rgba(0,0,0,0.4) 100%),
    /* Dust/heat haze from below */
    radial-gradient(ellipse 100% 40% at 50% 100%, rgba(160, 82, 45, 0.08) 0%, transparent 70%),
    /* Base panel */
    var(--panel);
  
  /* Town background will be added via data-state */
  transition: background 0.6s ease;

  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px 20px;

  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;

  /* Heavy cinematic shadow */
  box-shadow:
    0 0 0 1px rgba(201, 168, 76, 0.05),
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(212, 196, 160, 0.04);

  cursor: crosshair;
}

/* Worn corner marks — wanted-poster detail */
.stage::before,
.stage::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: rgba(201, 168, 76, 0.2);
  border-style: solid;
  pointer-events: none;
}

.stage::before {
  top: 10px;
  left: 10px;
  border-width: 2px 0 0 2px;
}

.stage::after {
  bottom: 10px;
  right: 10px;
  border-width: 0 2px 2px 0;
}

/* ── Signal Text — The Big Word ──────────────────────────────── */
.clock-container {
  margin-bottom: 20px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  backdrop-filter: blur(3px);
}

.clock-face {
  width: clamp(140px, 20vw, 200px);
  height: clamp(140px, 20vw, 200px);
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.9)) 
          drop-shadow(0 4px 16px rgba(0, 0, 0, 0.8));
}

.signal {
  font-family: 'Rye', 'Georgia', serif;
  font-weight: 400;
  font-size: clamp(48px, 10vw, 108px);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--parchment);
  text-shadow:
    0 3px 0 rgba(0, 0, 0, 0.5),
    0 6px 20px rgba(0, 0, 0, 0.3);
  transition: transform 140ms ease, color 140ms ease, opacity 140ms ease,
              text-shadow 140ms ease;
}

.hint {
  margin-top: 14px;
  color: var(--parchment-dim);
  font-family: 'Special Elite', monospace;
  font-size: clamp(14px, 2.2vw, 18px);
  letter-spacing: 0.04em;
  font-style: italic;
}

/* ── Buttons — Saloon-Sign / Wanted-Poster Style ─────────────── */
.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn {
  width: 100%;
  max-width: 340px;
  padding: 14px 20px;
  border: 0;
  border-radius: 3px;
  font-family: 'Rye', 'Georgia', serif;
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 150ms ease;
  position: relative;

  /* Gold wanted-poster look */
  background:
    linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 60%, #b8942f 100%);
  color: var(--ink);
  box-shadow:
    0 2px 0 #8a6e1e,
    0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn:hover {
  background:
    linear-gradient(180deg, #f0d45c 0%, var(--gold-bright) 60%, var(--gold) 100%);
  box-shadow:
    0 2px 0 #8a6e1e,
    0 6px 20px rgba(201, 168, 76, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 #8a6e1e,
    0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Secondary — weathered wood */
.btn.secondary {
  background:
    linear-gradient(180deg, rgba(42, 31, 22, 0.9) 0%, rgba(26, 20, 16, 0.95) 100%);
  color: var(--parchment);
  border: 2px solid rgba(212, 196, 160, 0.2);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(212, 196, 160, 0.05);
}

.btn.secondary:hover {
  border-color: rgba(201, 168, 76, 0.35);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(201, 168, 76, 0.08),
    inset 0 1px 0 rgba(212, 196, 160, 0.08);
  transform: translateY(-1px);
}

.btn.secondary:active {
  transform: translateY(1px);
}

/* ── Result Panel — Bounty Notice ────────────────────────────── */
.result {
  width: 100%;
  max-width: 420px;
  border-radius: 3px;
  padding: 16px 18px;
  position: relative;

  background:
    radial-gradient(ellipse at 50% 0%, rgba(201, 168, 76, 0.04) 0%, transparent 60%),
    var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(212, 196, 160, 0.04);
}

.resultRow {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  gap: 12px;
  border-bottom: 1px solid rgba(212, 196, 160, 0.06);
}

.resultRow:last-of-type {
  border-bottom: none;
  margin-bottom: 12px;
}

.resultLabel {
  color: var(--parchment-dim);
  font-family: 'Special Elite', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 14px;
}

.resultValue {
  font-family: 'IM Fell English SC', 'Georgia', serif;
  font-weight: 400;
  font-size: 17px;
  color: var(--parchment);
}

/* ── Stats Section ───────────────────────────────────────────── */
.stats-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(212, 196, 160, 0.2) 20%,
    rgba(212, 196, 160, 0.2) 80%,
    transparent
  );
  margin: 16px 0 12px 0;
}

.stats-section {
  padding: 8px 0;
}

.stats-title {
  text-align: center;
  font-family: 'Rye', 'Georgia', serif;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 12px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.stats-difficulty-badge {
  font-family: 'Special Elite', monospace;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(201, 168, 76, 0.2);
  border: 1px solid rgba(201, 168, 76, 0.4);
  color: var(--parchment);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.stat-label {
  font-family: 'Special Elite', monospace;
  font-size: 11px;
  color: var(--parchment-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-family: 'IM Fell English SC', 'Georgia', serif;
  font-size: 20px;
  color: var(--parchment);
  font-weight: 400;
}

.stat-value.new-record {
  color: var(--gold-bright);
  animation: recordPulse 500ms ease 1;
}

@keyframes recordPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  text-align: center;
  color: rgba(212, 196, 160, 0.3);
  font-size: 12px;
  letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════════════════════════
   STATE-DRIVEN VISUALS
   ═══════════════════════════════════════════════════════════════ */

/* ── Idle ─────────────────────────────────────────────────────── */
.game[data-state="idle"] .signal {
  opacity: 0.85;
}

/* ── Waiting — Tension builds ────────────────────────────────── */
.game[data-state="waiting"] .stage {
  animation: tension-pulse 3s ease-in-out infinite;
  background-image: 
    url('images/town-background.png'),
    radial-gradient(ellipse 80% 70% at 50% 50%, transparent 30%, rgba(0,0,0,0.5) 100%),
    radial-gradient(ellipse 100% 40% at 50% 100%, rgba(160, 82, 45, 0.08) 0%, transparent 70%);
  background-size: cover, auto, auto;
  background-position: center, center, center;
  background-blend-mode: normal, normal, normal;
}

.game[data-state="draw"] .stage {
  background-image: 
    url('images/town-background.png'),
    radial-gradient(ellipse 80% 70% at 50% 50%, transparent 30%, rgba(0,0,0,0.5) 100%),
    radial-gradient(ellipse 100% 40% at 50% 100%, rgba(160, 82, 45, 0.08) 0%, transparent 70%);
  background-size: cover, auto, auto;
  background-position: center, center, center;
  background-blend-mode: normal, normal, normal;
}

.game[data-state="waiting"] .signal {
  color: var(--parchment-dim);
  animation: suspense-drift 2s ease-in-out infinite;
}

@keyframes tension-pulse {
  0%, 100% { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(212, 196, 160, 0.04); }
  50%      { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(0, 0, 0, 0.1); }
}

@keyframes suspense-drift {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.3; }
}

/* ── Draw! — Explosive reveal ────────────────────────────────── */
.game[data-state="draw"] .signal {
  color: var(--gold-bright);
  text-shadow:
    0 0 40px rgba(232, 200, 74, 0.6),
    0 0 80px rgba(201, 168, 76, 0.3),
    0 3px 0 rgba(0, 0, 0, 0.5);
  transform: scale(1.08);
  animation: draw-flash 200ms ease-out 1;
}

.game[data-state="draw"] .stage {
  border-image: linear-gradient(
    180deg,
    rgba(232, 200, 74, 0.5) 0%,
    rgba(201, 168, 76, 0.3) 50%,
    rgba(232, 200, 74, 0.5) 100%
  ) 1;
  box-shadow:
    0 0 0 1px rgba(201, 168, 76, 0.15),
    0 0 60px rgba(201, 168, 76, 0.1),
    0 20px 60px rgba(0, 0, 0, 0.5);
}

.game[data-state="draw"] .hint {
  color: var(--gold);
}

@keyframes draw-flash {
  0%  { transform: scale(0.92); opacity: 0.5; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1.08); opacity: 1; }
}

/* ── Result: Win ─────────────────────────────────────────────── */
.game[data-state="result"][data-outcome="win"] .signal {
  color: var(--sage-glow);
  text-shadow:
    0 0 30px rgba(127, 191, 107, 0.3),
    0 3px 0 rgba(0, 0, 0, 0.5);
}

.game[data-state="result"][data-outcome="win"] .stage {
  border-image: linear-gradient(
    180deg,
    rgba(107, 143, 94, 0.25) 0%,
    rgba(107, 143, 94, 0.1) 50%,
    rgba(107, 143, 94, 0.25) 100%
  ) 1;
}

/* ── Result: Too Early ───────────────────────────────────────── */
.game[data-state="result"][data-outcome="early"] .signal {
  color: var(--blood-glow);
  text-shadow:
    0 0 30px rgba(192, 57, 43, 0.4),
    0 3px 0 rgba(0, 0, 0, 0.5);
  animation: shame-shake 400ms ease 1;
}

.game[data-state="result"][data-outcome="early"] .stage {
  border-image: linear-gradient(
    180deg,
    rgba(139, 37, 0, 0.3) 0%,
    rgba(139, 37, 0, 0.15) 50%,
    rgba(139, 37, 0, 0.3) 100%
  ) 1;
}

@keyframes shame-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(3px); }
}