:root {
  --bg: #F7F4ED;
  --surface: #FFFFFF;
  --ink: #071733;
  --muted: #6E685A;
  --line: #E7DFCF;
  --line-strong: #D3C9B5;
  --brand: #071733;
  --brand-deep: #040D1A;
  --brand-soft: #E8EAEF;
  --accent: #C9A961;
  --accent-deep: #9B7A3E;
  --accent-soft: #F3E9D2;
  --ok: #1F6B45;
  --ok-soft: #E5F2EA;
  --danger: #8C3428;
  --danger-soft: #F8E6E2;
  --shadow: 0 1px 2px rgba(7, 23, 51, .05), 0 12px 34px rgba(7, 23, 51, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}
a { color: inherit; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }
.puesto-wrap { max-width: 640px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-deep);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h1 { font-size: clamp(2rem, 5vw, 3.15rem); }
.sub { color: var(--muted); max-width: 62ch; margin: 12px 0 0; }
.stamp { color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 14px;
}
.card h2 { font-size: 1.45rem; }
.lead { color: var(--muted); margin: 8px 0 0; }
.steps { margin: 10px 0 0; padding-left: 1.25rem; }
.steps li + li { margin-top: 8px; }
.admin-foot { margin-top: 28px; }

.rules, .prizes { margin-top: 28px; }
.rules ul, .prizes > p { margin: 10px 0 0; padding-left: 18px; }
.prizes > p { padding-left: 0; }
.rules li + li { margin-top: 8px; }
.screen-rule { display: none; }

.header-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.header-row .btn { min-height: 44px; white-space: nowrap; }
.prizes h3 {
  font-size: 1.35rem;
  margin-top: 16px;
}
.prize-note { color: var(--accent-deep); font-weight: 600; margin: 6px 0 0; }
.prize-grid { display: grid; gap: 16px; margin-top: 8px; }
.podium { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.podium li {
  display: grid;
  grid-template-columns: 9.2rem 1fr;
  gap: 10px;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.podium li.is-first { background: var(--accent-soft); border-color: var(--accent); }
@media (max-width: 560px) {
  .podium li { grid-template-columns: 1fr; gap: 2px; }
}
.prize-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-deep);
}
.prize-who {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--muted);
}
.prize-who.open { color: var(--ink); }

.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-top: 28px; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); }

.narrow { display: grid; gap: 12px; }
.wide { display: none; }
@media (min-width: 900px) {
  .narrow { display: none; }
  .wide { display: block; overflow-x: auto; }
}

.prow, .hrow {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.rank {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--brand-soft);
  font-family: Fraunces, Georgia, serif;
  font-size: 1.25rem;
}
.rank.podium { background: var(--accent-soft); color: var(--accent-deep); }
.rank.top { background: var(--brand); color: white; }
.who-name { font-size: 1.2rem; }
.meta { color: var(--muted); margin: 4px 0 0; font-size: 0.92rem; }
.pts { text-align: right; }
.pts b {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1;
}
.pts span { color: var(--muted); font-size: 0.75rem; }
.breakdown { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.breakdown span {
  background: var(--bg);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-family: Inter, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: 3px;
}
.badge.quiet { background: var(--brand-soft); color: var(--brand); }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 14px; overflow: hidden; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.top td:first-child { color: var(--accent-deep); font-weight: 700; }
.empty {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
}

.alert {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 12px;
}
.undo-bar {
  position: sticky;
  top: 8px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 12px;
  margin-top: 14px;
}
.undo-bar p { margin: 0; font-weight: 600; }
.result h2 { font-size: 2.4rem; margin-top: 6px; }
.result h2.long { font-size: 1.65rem; }
.kicker-ok { color: var(--ok); font-weight: 700; margin: 0; }
.kicker-keep { color: var(--accent-deep); font-weight: 700; margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip, .outcome, .kind, .btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 12px;
  min-height: 52px;
  padding: 10px 14px;
}
.chip-person {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 68px;
}
.chip-mark { font-size: 0.85rem; font-weight: 700; color: var(--accent-deep); }
.chip.on .chip-mark { color: var(--accent); }
.record-box {
  display: block;
  margin-top: 12px;
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 12px 14px;
}
.record-kicker {
  display: block;
  margin: 0;
  font-weight: 700;
  color: var(--accent-deep);
  font-size: 0.92rem;
}
.record-score {
  display: block;
  margin-top: 2px;
  font-family: Fraunces, Georgia, serif;
  font-size: 2.6rem;
  line-height: 1;
}
.record-score:empty { display: none; }

.chip.on, .kind[aria-pressed="true"], .outcome.on {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn-ghost { background: transparent; }
.btn-danger { background: white; color: var(--danger); border-color: var(--danger); }
.btn[disabled], .btn:disabled { opacity: 0.45; cursor: default; }
.btn-block { width: 100%; margin-top: 12px; }
.row-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-top: 12px; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  width: 100%;
  margin-top: 6px;
  min-height: 52px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: white;
}
textarea { min-height: 76px; resize: vertical; display: block; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline label { flex: 1 1 12rem; }
.kinds { display: flex; gap: 8px; margin-top: 10px; }
.kind { flex: 1; }

fieldset { border: 0; padding: 0; margin: 14px 0 0; }
legend { font-weight: 700; margin-bottom: 8px; }
.outcomes { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.outcome { display: flex; flex-direction: column; align-items: flex-start; min-height: 64px; }
.outcome .op { font-family: Fraunces, Georgia, serif; font-size: 1.35rem; }

.linkish, .text-link {
  border: 0;
  background: transparent;
  color: var(--accent-deep);
  padding: 0;
  min-height: 0;
  font-weight: 700;
  text-decoration: underline;
}
.paper { color: var(--muted); font-size: 0.9rem; margin-top: 22px; }
.who { margin-top: 8px; }

.confirm-bar {
  padding: 16px 0 calc(8px + env(safe-area-inset-bottom));
}

.login { max-width: 440px; margin: 8vh auto; }
.links { list-style: none; padding: 0; margin: 12px 0 0; }
.links li { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.links a {
  display: block;
  padding: 14px 0 0;
  text-decoration: none;
  font-weight: 600;
}
.links small { display: block; font-weight: 500; color: var(--muted); word-break: break-all; }
.links .btn { margin-top: 8px; }

.figure {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 1;
  margin: 10px 0 0;
}
.math { color: var(--muted); margin: 8px 0 0; }
.notice {
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 12px;
}
.attempt { padding: 16px 0; border-top: 1px solid var(--line); }
.attempt h3 { font-size: 1.2rem; }
.card h3 { font-size: 1.35rem; margin-top: 28px; }
.asked-note {
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0 0;
  overflow-wrap: anywhere;
}
.admin-inline { margin-top: 8px; }
.attempt form .btn, .card form .btn { margin-top: 12px; }

@media (min-width: 800px) {
  .prize-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}

body.is-screen { background: var(--bg); }
body.is-screen .wrap { max-width: 1280px; padding-top: 18px; }
body.is-screen .sub,
body.is-screen .rules h2,
body.is-screen .rules ul { display: none; }
body.is-screen .screen-rule { display: block; margin: 8px 0 0; padding: 0; color: var(--muted); }
body.is-screen .toolbar, body.is-screen .header-row .btn {
  min-height: 40px;
  font-size: 0.9rem;
}
body.is-screen .header-row { align-items: flex-start; }
body.is-screen h1 { font-size: clamp(2.2rem, 4vw, 3.2rem); }
body.is-screen .prize-who { font-size: clamp(1.7rem, 3vw, 2.5rem); }
body.is-screen .narrow { display: none; }
body.is-screen .wide { display: block; overflow-x: auto; }
body.is-screen th, body.is-screen td { font-size: 1.12rem; padding: 14px 12px; }
body.is-screen .rules { margin-top: 18px; }
body.is-screen .admin-foot { display: none; }

#scan-video {
  width: 100%;
  min-height: 220px;
  max-height: 52vh;
  object-fit: cover;
  margin-top: 12px;
  border-radius: 12px;
  background: #1c1915;
}
.scan-status { margin: 10px 0 0; font-weight: 650; }
.scan-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  cursor: pointer;
}
.scan-photo input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.wallet-box {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: white;
  font-weight: 650;
}
.pay-actions { display: flex; flex-direction: column; gap: 8px; }
.ledger { margin: 16px 0 0; padding-left: 1.1rem; }
.ledger li { margin: 10px 0; }
.accept { margin-top: 18px; font-weight: 700; }
.sign-line {
  margin-top: 36px;
  max-width: 320px;
  padding-top: 8px;
  border-top: 1px solid var(--ink);
}
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.ticket {
  break-inside: avoid;
  page-break-inside: avoid;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  background: white;
}
.ticket h2 { margin: 4px 0 8px; }
.ticket-code {
  margin: 8px 0 0;
  font-size: 1.6rem;
  letter-spacing: 0.18em;
  font-weight: 700;
}
body.show-pass { background: #fff; }
body.show-pass .wrap { max-width: 440px; margin: 0 auto; text-align: center; padding-top: 28px; }
.show-qr, .ticket-qr { display: flex; justify-content: center; }
.show-qr svg, .ticket-qr svg { display: block; height: auto; max-width: 100%; }
.show-qr svg { width: min(78vw, 320px); }
.ticket-qr svg { width: 180px; }
.show-code {
  margin: 12px 0 0;
  font-size: 2rem;
  letter-spacing: 0.28em;
  font-weight: 700;
}
@media print {
  .no-print, .btn { display: none !important; }
  body { background: white; }
}
