:root {
  color-scheme: light;
  --paper: #f6f2e9;
  --white: #fffefa;
  --ink: #292141;
  --muted: #635d70;
  --line: #e4ded5;
  --yellow: #ffda70;
  --yellow-light: #fff3cd;
  --purple: #593d82;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #744bad; outline-offset: 3px; }
.top { border-bottom: 1px solid var(--line); background: var(--white); }
.top-inner {
  width: min(1060px, calc(100% - 40px)); min-height: 70px; margin: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 11px; font-size: 1rem; font-weight: 800; letter-spacing: -.02em; }
.brand-icon {
  display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 12px; background: var(--ink); color: var(--yellow);
}
.wrap { width: min(1060px, calc(100% - 40px)); margin: 0 auto; padding: clamp(28px, 6vw, 70px) 0 64px; }
#setup { max-width: 610px; margin: 0 auto; }
.intro { margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; font-size: .76rem; font-weight: 800; letter-spacing: .13em; color: var(--purple); }
h1, h2, p { margin-top: 0; }
h1 {
  font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.25rem, 7vw, 4.3rem);
  letter-spacing: -.055em; line-height: 1.04; margin-bottom: 12px;
}
.accent { color: var(--purple); }
.intro > p:last-child { color: var(--muted); margin-bottom: 0; line-height: 1.5; }
.steps { display: flex; gap: 10px; list-style: none; padding: 0; margin: 0 0 16px; }
.steps li {
  display: flex; gap: 8px; align-items: center; padding: 8px 13px 8px 9px;
  font-size: .875rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 99px;
}
.steps li span { display: grid; place-items: center; min-width: 24px; height: 24px; border-radius: 50%; background: #eae4de; }
.steps li[aria-current] { background: var(--yellow-light); border-color: #e3c365; color: var(--ink); }
.steps li[aria-current] span { background: var(--yellow); }
.card {
  border: 1px solid var(--line); background: var(--white); border-radius: 20px;
  padding: clamp(17px, 4vw, 30px); box-shadow: 0 4px 0 #e8e0d3;
}
h2 { margin-bottom: 8px; font-size: clamp(1.25rem, 4vw, 1.62rem); letter-spacing: -.035em; line-height: 1.2; }
.muted { color: var(--muted); font-size: .925rem; line-height: 1.5; margin-bottom: 20px; }
label { display: block; margin-bottom: 6px; font-weight: 700; font-size: .9rem; }
input {
  border: 1px solid #c9c0ce; border-radius: 10px; color: var(--ink); background: white;
  width: 100%; min-width: 0; padding: 11px 12px; min-height: 46px;
}
input::placeholder { color: #716a7b; }
.input-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.button, .quiet { border: 1px solid transparent; border-radius: 10px; min-height: 46px; padding: 9px 14px; font-weight: 750; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary { background: var(--yellow); color: var(--ink); border-color: #e4bd53; }
.primary:hover { background: #ffd152; }
.primary:disabled { background: #ece8e1; border-color: var(--line); color: #716a7b; }
.secondary { background: var(--ink); color: white; }
.secondary:hover { background: var(--purple); }
.quiet { color: var(--purple); background: transparent; }
.quiet:hover { background: #eee8f4; }
.player-list-header { margin-top: 24px; display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.badge { display: grid; place-items: center; min-width: 25px; height: 25px; padding: 0 6px; border-radius: 20px; background: #efe8f5; color: var(--purple); }
.players-list { list-style: none; margin: 9px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.players-list li {
  display: flex; gap: 3px; align-items: center; max-width: 100%; border-radius: 10px;
  background: var(--paper); padding-left: 11px; font-weight: 650;
}
.players-list li span { min-width: 0; overflow-wrap: anywhere; }
.remove { background: transparent; color: var(--ink); border: 0; border-radius: 9px; min-width: 40px; min-height: 40px; font-size: 1.25rem; }
.remove:hover { background: #eee4f2; }
.empty { color: var(--muted); font-size: .875rem; margin: 8px 0 0; }
.setup-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.target-field { position: relative; max-width: 220px; }
.target-field input { padding-right: 50px; }
.target-field span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.game-intro { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 18px; }
.game-intro h1 { margin: 0; }
.goal { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid #e3c365; border-radius: 12px; background: var(--yellow-light); }
.goal span { font-size: .875rem; color: var(--muted); font-weight: 650; }
.goal strong, .score, .gap { font-variant-numeric: tabular-nums; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ranking { list-style: none; padding: 0; margin: 0; }
.ranking-head, .ranking li {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(50px, auto) minmax(100px, 30%);
  align-items: center; column-gap: 8px; padding: 8px;
}
.ranking-head { margin-top: 15px; color: var(--muted); font-size: .75rem; font-weight: 750; }
.ranking li { min-height: 51px; border-top: 1px solid var(--line); }
.ranking li.leader { background: var(--yellow-light); border-radius: 9px; border-top-color: transparent; }
.ranking-head > :not(:first-child), .score, .gap { text-align: right; }
.ranked-player { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ranked-player strong { overflow-wrap: anywhere; }
.rank { display: grid; place-items: center; flex-shrink: 0; min-width: 28px; height: 27px; padding: 0 4px; border-radius: 7px; background: #eee8f4; font-weight: 800; font-size: .72rem; }
.leader .rank { background: var(--yellow); }
.score, .gap { overflow-wrap: anywhere; }
.gap { color: var(--muted); font-size: .84rem; }
.gap.reached { color: #27573e; font-weight: 750; }
.winner { margin: 13px 0 0; padding: 11px 12px; background: var(--yellow-light); border-radius: 9px; font-weight: 750; overflow-wrap: anywhere; }
.footnote { color: var(--muted); font-size: .82rem; margin: 14px 0 0; }
.round-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(48px, 88px) auto auto; align-items: center; gap: 8px; margin-bottom: 8px; }
.round-field label { margin: 0; overflow-wrap: anywhere; }
.round-field input { text-align: right; }
.zero-score {
  min-height: 46px; min-width: 48px; padding: 6px 8px; border: 1px solid #d6c9e3;
  border-radius: 10px; background: #f0eaf5; color: var(--purple); font-weight: 750; white-space: nowrap;
}
.zero-score:hover { background: #e7dbf1; }
.round-submit { width: 100%; margin-top: 8px; }
.undo { display: block; margin: 8px auto 0; }
.error { color: #9a253a; font-size: .9rem; margin: 8px 0; }
dialog { color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 24px; max-width: min(440px, calc(100% - 32px)); }
dialog::backdrop { background: #2921418c; }
@media (min-width: 761px) { #standings { position: sticky; top: 16px; } }
@media (max-width: 760px) { .game-grid { grid-template-columns: 1fr; } }
@media (max-width: 390px) {
  .top-inner, .wrap { width: calc(100% - 24px); }
  .top .quiet { font-size: .8rem; padding: 6px; }
  .brand { font-size: .88rem; gap: 6px; }
  .ranking-head, .ranking li { grid-template-columns: minmax(0, 1fr) minmax(36px, auto) minmax(74px, 28%); gap: 5px; padding-inline: 5px; }
  .ranked-player { gap: 5px; }
}

.round-card-detail { grid-column: 1 / -1; color: var(--muted); overflow-wrap: anywhere; }
#cards-dialog { width: min(480px, calc(100% - 24px)); max-width: none; padding: clamp(14px, 5vw, 24px); }
#cards-title { overflow-wrap: anywhere; }
.card-picker { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.card-picker legend { padding: 0; margin-bottom: 6px; font-weight: 750; font-size: .9rem; }
.number-cards, .penalty-cards { display: grid; gap: 5px; }
.number-cards { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.penalty-cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card-choice {
  min-width: 0; min-height: 42px; border: 1px solid #c9c0ce; border-radius: 8px;
  background: white; color: var(--ink); font-weight: 750; padding: 4px 2px;
}
.card-choice:not(:disabled):hover { background: var(--yellow-light); }
.card-choice[aria-pressed="true"], .card-choice[aria-pressed="true"]:hover {
  background: var(--ink); border-color: var(--ink); color: white;
}
.card-choice:disabled { opacity: .45; }
.wide-choice { grid-column: 1 / -1; }
.card-calculation {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--yellow-light); border-radius: 9px; padding: 10px 12px; font-size: .9rem;
}
.card-calculation strong { flex-shrink: 0; font-size: 1.08rem; }
@media (max-width: 370px) {
  .round-field { gap: 5px; }
  .round-field input, .round-field button { padding-inline: 5px; }
}

.round-flip { margin: 0 0 12px; }
.flip-choice {
  margin: 0 0 14px; padding: 8px 12px 12px; min-width: 0; border-radius: 10px;
  border: 1px solid #e3c365; background: var(--yellow-light);
}
.flip-choice legend { padding: 0 5px; font-weight: 850; }
.flip-choice p { margin-bottom: 4px; font-size: .9rem; }
.flip-option { display: flex; align-items: center; gap: 8px; min-height: 38px; margin: 0; cursor: pointer; }
.flip-option input { width: 18px; min-height: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--purple); }
#flip-target-field { margin-top: 7px; }
#flip-target {
  width: 100%; min-height: 44px; border: 1px solid #c9c0ce; border-radius: 8px;
  color: var(--ink); background: white; padding: 6px 8px; font: inherit;
}
