:root {
  --cream: #f6efe2;
  --paper: #fffdf8;
  --cranberry: #7a1f2b;
  --cranberry-dark: #5e1620;
  --pumpkin: #d9752b;
  --pumpkin-dark: #b85f1d;
  --gold: #f2c48d;
  --brown: #3b2a20;
  --muted: #8a7a6a;
  --line: #e6d8bf;
  --sand: #efe3cc;
  --error: #a3261f;
  --radius: 14px;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--cream);
  color: var(--brown);
  font: 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cranberry); }
[hidden] { display: none !important; }

/* Hero */
.hero {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(242, 196, 141, .18), transparent 60%),
    var(--cranberry);
  color: var(--cream);
  text-align: center;
  padding: 56px 16px 48px;
}
.hero-inner { max-width: 640px; margin: 0 auto; }
.kicker { letter-spacing: .28em; text-transform: uppercase; font-size: 12px; color: var(--gold); margin: 0; font-weight: 600; }
.hero h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(40px, 11vw, 72px);
  line-height: .98;
  margin: 14px 0 18px;
  letter-spacing: -.01em;
}
.rule { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 0 auto 20px; max-width: 280px; }
.rule span { flex: 1; height: 1px; background: rgba(242, 196, 141, .55); }
.details { display: grid; gap: 14px; margin: 0 0 26px; }
.details dt { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.details dd { margin: 2px 0 0; font-size: 17px; }
.details a { color: var(--cream); text-decoration-color: rgba(242, 196, 141, .6); text-underline-offset: 3px; }
#event-time:empty { display: none; }
#event-time { white-space: pre-line; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@media (min-width: 640px) {
  .details { grid-template-columns: 1fr 1fr; text-align: left; max-width: 520px; margin-left: auto; margin-right: auto; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 16px/1 var(--body);
  padding: 14px 22px;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: 48px;
  transition: background-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, .step:focus-visible { outline: 3px solid var(--pumpkin); outline-offset: 2px; }
.btn-primary { background: var(--pumpkin); color: #fff; }
.btn-primary:hover { background: var(--pumpkin-dark); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-gold { background: var(--gold); color: var(--cranberry); }
.btn-ghost { border-color: rgba(242, 196, 141, .6); color: var(--cream); }
.btn-outline { border-color: var(--line); background: var(--paper); color: var(--brown); }
.btn-small { min-height: 40px; padding: 10px 16px; font-size: 15px; }

/* Layout */
main { max-width: 960px; margin: 0 auto; padding: 8px 16px 24px; }
.section { padding: 32px 0 8px; }
.section h2 {
  font-family: var(--display); font-weight: 700; font-size: 30px;
  color: var(--cranberry); margin: 0 0 6px;
}
.lede { margin: 0 0 16px; color: var(--muted); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.muted { color: var(--muted); }

.banner {
  margin-top: 20px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: #fbe7e2; border: 1px solid #efc2b8; color: var(--error); border-radius: var(--radius); padding: 12px 14px;
}

/* Game */
.game-layout { display: grid; gap: 16px; }
.game-frame { padding: 10px; background: var(--sand); border-color: #d9c6a3; }
#game-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 600 / 180;
  border-radius: 10px; background: var(--cream);
  touch-action: pan-y; cursor: pointer; user-select: none; -webkit-user-select: none;
}
#game-canvas.playing { touch-action: none; }
.scores-card h3 { font-family: var(--display); font-size: 20px; margin: 0 0 8px; color: var(--cranberry); }
.scores { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
.scores li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.scores li:last-child { border-bottom: 0; }
.scores .rank { color: var(--muted); width: 1.6em; display: inline-block; }
.scores .who { font-weight: 700; letter-spacing: .12em; }
.scores li.top .who { color: var(--cranberry); }
.scores li.mine { background: #fff4e3; border-radius: 6px; padding-left: 4px; padding-right: 4px; }

/* Initials entry */
.initials { padding: 14px 4px 4px; text-align: center; }
.initials h3 { font-family: var(--display); margin: 0 0 2px; color: var(--cranberry); font-size: 20px; }
.initials .final { margin: 0 0 12px; color: var(--muted); }
.slots { display: flex; gap: 10px; justify-content: center; margin-bottom: 12px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot button.arrow {
  width: 52px; height: 36px; border-radius: 10px; border: 1px solid #d9c6a3; background: var(--paper);
  color: var(--cranberry); font-size: 16px; cursor: pointer;
}
.slot .letter {
  width: 52px; height: 60px; display: grid; place-items: center;
  font: 900 34px/1 var(--display); color: var(--brown);
  background: var(--paper); border: 2px solid #d9c6a3; border-radius: 10px;
}
.slot.active .letter { border-color: var(--pumpkin); box-shadow: 0 0 0 3px rgba(217, 117, 43, .25); }
.initials-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.initials .status { min-height: 1.4em; margin: 8px 0 0; color: var(--muted); }
.initials .status.err { color: var(--error); }

/* RSVP */
.tally { font-family: var(--display); font-size: 20px; margin: 0 0 14px; }
.tally b { color: var(--cranberry); }
.mine { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; background: #fff7ea; }
.mine-line { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.form { display: grid; gap: 6px; max-width: 520px; }
.form label { font-weight: 600; margin-top: 8px; }
.form input {
  font: 17px var(--body); padding: 12px 14px; border-radius: 10px; border: 1px solid #d9c6a3; background: #fff; color: var(--brown); width: 100%;
}
.stepper { display: flex; gap: 8px; align-items: center; }
.stepper input { width: 84px; text-align: center; font-weight: 700; font-size: 20px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid #d9c6a3; background: var(--sand);
  font-size: 22px; color: var(--cranberry); cursor: pointer;
}
.hint { margin: 0; font-size: 14px; color: var(--muted); }
.field-error { margin: 0; color: var(--error); font-size: 14px; min-height: 0; }
.field-error:empty { display: none; }
.form .btn-primary { margin-top: 12px; justify-self: start; }
.form-status:empty { display: none; }
.form-status { margin: 0; color: var(--muted); }
.form-status.err { color: var(--error); }

/* Dish */
.dish-card { display: grid; gap: 14px; justify-items: start; max-width: 620px; }
.dish-card p { margin: 0; }

/* Footer */
.footer { text-align: center; padding: 32px 16px 48px; color: var(--brown); font-size: 15px; border-top: 1px solid var(--line); margin-top: 32px; }
.footer p { margin: 4px 0; }

/* Loading skeleton */
.skeleton { color: transparent !important; background: linear-gradient(90deg, var(--sand), #f7eedf, var(--sand)); background-size: 200% 100%; border-radius: 6px; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Computer screens: one centered column; the game gets the full width, scores sit below it. */
@media (min-width: 720px) {
  main { max-width: 880px; }
  .section h2, .lede, .tally { text-align: center; }
  .form, .mine, .dish-card { margin-left: auto; margin-right: auto; }
  .mine { max-width: 520px; }
  .dish-card { justify-items: center; text-align: center; }
  .scores-card h3 { text-align: center; }
  .scores {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 340px);
    grid-template-rows: repeat(5, auto); column-gap: 40px; justify-content: center;
  }
  .scores li:nth-child(5) { border-bottom: 0; }
  .scores li.muted { grid-column: 1 / -1; text-align: center; justify-content: center; }
}
