:root {
  color-scheme: light;
  --paper: #f5f6f1;
  --white: #fff;
  --ink: #172b25;
  --muted: #566760;
  --line: #dce4dc;
  --soft: #edf2ec;
  --green: #235445;
  --dark: #143d32;
  --lime: #e1f2ae;
  --danger: #a3312c;
  --radius: 20px;
  font-family: "Aptos", "Inter", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .53; }
a { color: inherit; }
:focus-visible { outline: 3px solid #519478; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.13; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.06rem; }
p { line-height: 1.55; }

.topbar { background: #fbfcf9; border-bottom: 1px solid var(--line); }
.topbar-inner, .shell { width: min(1080px, calc(100% - 64px)); margin: 0 auto; }
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; font-size: 1.28rem; font-weight: 790; letter-spacing: -.065em; }
.brand > span:last-child { color: #476c5d; }
.brand-mark { display: grid; place-items: center; color: var(--lime); background: var(--green); width: 37px; height: 37px; border-radius: 11px; margin-right: 9px; font-size: 1.5rem; line-height: 1; }
nav { display: flex; align-items: center; gap: 19px; }
.nav-link { color: var(--muted); font-size: .9rem; font-weight: 650; text-decoration: none; }
.nav-link:hover { text-decoration: underline; }
.shell { padding: 38px 0 64px; }
.library-heading { margin-bottom: 23px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid transparent; border-radius: 10px; padding: 8px 15px; font-size: .9rem; font-weight: 710; line-height: 1.25; text-align: center; text-decoration: none; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover:enabled { background: var(--dark); }
.button.secondary { color: var(--dark); border-color: #cfdcd2; background: #fcfdfb; }
.button.secondary:hover { background: var(--soft); }
.button.lime { color: var(--dark); background: var(--lime); min-height: 46px; padding-inline: 18px; }
.button.lime:hover { background: #eff8d3; }

.hero { position: relative; isolation: isolate; display: flex; align-items: center; overflow: hidden; min-height: 298px; border-radius: 24px; color: #fff; background: radial-gradient(ellipse at 95% 10%, #35624f, transparent 60%), var(--dark); }
.hero-copy { z-index: 1; padding: 38px 44px; width: min(65%, 680px); }
.hero-label { display: flex; align-items: center; gap: 7px; color: var(--lime); font-size: .8rem; font-weight: 740; letter-spacing: .12em; }
.hero h2 { margin: 10px 0; font-family: Georgia, serif; font-size: clamp(2.4rem, 5vw, 4.35rem); font-weight: 500; letter-spacing: -.065em; line-height: .98; }
.hero p { max-width: 410px; margin: 17px 0 23px; color: #dce9dd; }
.card-art { position: absolute; inset: 0 0 0 56%; overflow: hidden; pointer-events: none; }
.card-art::before, .card-art::after { content: ""; position: absolute; border: 1px solid #dff0cd25; width: 395px; height: 395px; border-radius: 50%; right: -21px; top: -39px; }
.card-art::after { width: 315px; height: 315px; right: 19px; top: 1px; }
.play-card { width: 127px; height: 179px; padding: 11px 13px; border: 1px solid #eaf4d4; border-radius: 13px; display: flex; flex-direction: column; justify-content: space-between; position: absolute; top: 58px; box-shadow: 0 12px 28px #0b271f55; font: 700 1.3rem Georgia, serif; }
.play-card span:last-child { align-self: flex-end; transform: rotate(180deg); }
.play-card strong { align-self: center; font-size: 4.7rem; font-weight: 500; line-height: .9; }
.card-back { z-index: 1; right: 36%; color: #8a534c; background: #f3dcd3; transform: rotate(-19deg); }
.card-front { z-index: 2; right: 21%; color: #235445; background: #edf4d7; transform: rotate(13deg); }

.saved-section { margin-top: 34px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.segments { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: 11px; background: #e9eee7; }
.segments button { border: 1px solid transparent; padding: 6px 9px; min-height: 36px; border-radius: 8px; white-space: nowrap; font-size: .875rem; font-weight: 670; background: transparent; color: var(--muted); }
.segments button[aria-pressed="true"] { background: white; color: var(--dark); border-color: #dce4dc; }
.segments button span { margin-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.empty { text-align: center; padding: 39px 20px; }
.empty-mark { color: var(--green); background: #e8f0e2; width: 46px; height: 46px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 15px; font-size: 1.6rem; }
.empty p, .interlude p { color: var(--muted); margin-top: 6px; }
.empty > .button { margin-top: 14px; }
.game-list { display: grid; gap: 9px; }
.saved-game { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; text-decoration: none; }
.saved-game:hover { border-color: #80a994; }
.game-names { display: flex; align-items: center; gap: 12px; min-width: 0; overflow-wrap: anywhere; }
.mini-spade { color: var(--green); background: var(--soft); border-radius: 10px; padding: 6px 10px; font-size: 1.2rem; }
.game-names p { margin-top: 5px; font-size: .875rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; align-self: flex-start; border-radius: 999px; padding: 5px 9px; color: #265641; background: #e7f3db; font-size: .875rem; font-weight: 680; }
.badge.neutral { color: #465f53; background: #edf2ec; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #318255; }

.game-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.game-heading p { margin-top: 6px; color: var(--muted); overflow-wrap: anywhere; }
.game-heading .badge { margin-top: 5px; }
.game-banner { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(80px, .37fr) minmax(105px, .45fr); gap: 17px; align-items: center; margin-bottom: 16px; padding: 18px 23px; min-height: 102px; border-radius: 18px; background: var(--dark); color: white; }
.banner-heading { display: flex; align-items: center; gap: 13px; }
.banner-suit { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: #ffffff18; color: var(--lime); font-size: 1.65rem; }
.banner-heading h2 span { font-size: .95rem; color: #c2d8c9; white-space: nowrap; }
.banner-heading p, .banner-detail > span { color: #c7dfce; font-size: .875rem; }
.banner-detail { display: grid; gap: 2px; min-width: 0; }
.banner-detail strong { overflow-wrap: anywhere; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 19px 21px 15px; gap: 10px; }
.panel-heading p, .history summary p { font-size: .9rem; margin-top: 4px; color: var(--muted); }
.entry-table { padding: 0 19px; }
.entry-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px; align-items: center; gap: 7px; min-height: 56px; border-bottom: 1px solid var(--line); }
.entry-row.with-tricks { grid-template-columns: minmax(0, 1fr) 42px 63px 43px; }
.entry-head { min-height: 34px; border-top: 1px solid var(--line); font-size: .875rem; font-weight: 680; color: var(--muted); }
.entry-head span:not(:first-child), .value-cell, .points-cell { text-align: center; font-variant-numeric: tabular-nums; }
.points-cell { font-weight: 720; color: var(--green); }
.player { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 630; }
.player > span:nth-child(2) { overflow-wrap: anywhere; }
.player-mark { flex: 0 0 27px; width: 27px; height: 27px; display: inline-grid; place-items: center; border-radius: 8px; background: #e6f0e5; color: #215a44; font-size: 1rem; line-height: 1; }
.suit-1 { background: #f6e6e4; color: #985149; }
.suit-2 { background: #e7ebe4; color: #515d4f; }
.suit-3 { background: #f5ecdd; color: #92682d; }
.dealer { font-size: .82rem; color: #55675d; background: var(--soft); border-radius: 7px; padding: 2px 5px; }
input, select { min-width: 0; width: 100%; min-height: 42px; border: 1px solid #cbd8ce; border-radius: 8px; padding: 8px 10px; background: #fcfdfb; }
input[type="number"] { appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, #3d6352 50%), linear-gradient(135deg, #3d6352 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.value-cell input { display: block; width: 52px; margin: 0 auto; min-height: 38px; text-align: center; font-weight: 670; }
.read-value { color: var(--muted); }
.round-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 19px 19px; }
.round-actions { display: flex; gap: 7px; flex-shrink: 0; }
.entry-total { font-size: .9rem; color: var(--muted); }
.entry-error, .form-error { font-size: .9rem; color: var(--danger); margin-top: 4px; }
.sync-status { font-size: .82rem; color: var(--green); }
.text-button { border: 0; background: none; text-decoration: underline; color: var(--green); }
.standings-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; background: #eff3e7; color: var(--green); font-size: 1.3rem; }
.rank-list { list-style: none; display: grid; margin: 0; padding: 0 20px 12px; }
.rank-list li { display: grid; grid-template-columns: 14px 27px 1fr auto; align-items: center; gap: 9px; min-height: 47px; border-top: 1px solid var(--line); }
.rank { font-size: .875rem; color: var(--muted); text-align: center; }
.rank-name { overflow-wrap: anywhere; }
.rank-list strong { font-size: 1.15rem; color: var(--green); font-variant-numeric: tabular-nums; }
.winner { margin: 0 20px 11px; background: #ecf5df; padding: 9px 11px; border-radius: 8px; color: var(--dark); overflow-wrap: anywhere; }
.winner strong { display: block; font-size: .875rem; }
.interlude { padding: 24px 18px; text-align: center; }
.interlude-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.interlude > a { margin-top: 14px; }

.history { margin-top: 16px; }
.history summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; padding: 17px 21px; }
.history summary::-webkit-details-marker { display: none; }
.chevron { width: 10px; height: 10px; border-right: 2px solid var(--green); border-bottom: 2px solid var(--green); margin: -4px 4px 0; transform: rotate(45deg); }
.history[open] .chevron { transform: rotate(225deg); margin-top: 4px; }
.history-scroll { overflow-x: auto; border-top: 1px solid var(--line); }
.history table { width: 100%; border-collapse: collapse; text-align: center; font-variant-numeric: tabular-nums; font-size: .875rem; }
.history th, .history td { padding: 9px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.history thead th { background: #f8faf6; color: var(--muted); }
.history thead th .player-mark { vertical-align: middle; }
.history tbody th { text-align: left; padding-left: 20px; }
.history tbody tr:last-child > * { border-bottom: 0; }
.history-points.hit { color: #205c3c; font-weight: 720; }
.round-edit { padding: 4px; border: 0; background: transparent; color: var(--green); text-decoration: underline; font-weight: 670; }
.round-edit span { color: var(--muted); font-weight: 450; }
.history-empty { color: var(--muted); margin: 0 21px 16px; }

dialog { width: min(480px, calc(100% - 24px)); max-height: calc(100% - 24px); margin: auto; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: white; box-shadow: 0 18px 80px #1a3a3350; }
dialog::backdrop { background: #10282090; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 13px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--soft); font-size: 1.5rem; line-height: 1; }
.stack { display: grid; gap: 13px; }
.stack label:not(.name-field) { display: grid; gap: 5px; min-width: 0; }
label, legend { font-size: .9rem; font-weight: 670; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { padding: 0; margin-bottom: 5px; }
.name-fields, .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.name-field { display: flex; align-items: center; gap: 6px; min-width: 0; }
.form-hint, .muted { color: var(--muted); font-size: .9rem; }
.share-label { display: block; margin: 11px 0 5px; }
.share-row { display: flex; gap: 7px; }
.share-row .button { flex-shrink: 0; }
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 69px 69px; align-items: center; gap: 7px; }
.edit-grid > strong { color: var(--muted); font-size: .875rem; text-align: center; }
.edit-grid input { text-align: center; }
.notice { position: fixed; z-index: 10; bottom: 18px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 10px 15px; border-radius: 10px; color: white; background: var(--dark); box-shadow: 0 5px 20px #133b3140; text-align: center; }
.loading { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 760px) {
  .topbar-inner, .shell { width: calc(100% - 34px); }
  .shell { padding-top: 25px; }
  .hero-copy { padding: 30px 24px; }
  .card-art { inset-inline-start: 57%; }
  .play-card { width: 101px; height: 141px; top: 76px; }
  .play-card strong { font-size: 3.65rem; }
  .game-layout { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .topbar-inner, .shell { width: calc(100% - 24px); }
  .topbar-inner { min-height: 59px; }
  .topbar .nav-link { display: none; }
  .brand-mark { width: 31px; height: 31px; font-size: 1.25rem; }
  .hero { min-height: 245px; border-radius: 17px; }
  .hero-copy { width: 83%; padding: 25px 17px; }
  .hero p { max-width: 230px; }
  .card-art { inset-inline-start: 72%; opacity: .75; }
  .card-back { right: 13%; top: 44px; }
  .card-front { right: -10%; top: 67px; }
  .card-art::before, .card-art::after { display: none; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .saved-section { margin-top: 27px; }
  .game-banner { grid-template-columns: 1fr 1fr; padding: 13px; gap: 11px; }
  .banner-heading { grid-column: span 2; }
  .banner-suit { width: 37px; height: 37px; }
  .round-footer { flex-direction: column; align-items: stretch; }
  .round-actions > .button { flex: 1; }
  .entry-table { padding-inline: 12px; }
  .panel-heading, .round-footer, .history summary { padding-inline: 13px; }
  .entry-row.with-tricks { grid-template-columns: minmax(0, 1fr) 30px 50px 29px; }
  .value-cell input { width: min(47px, 100%); padding-inline: 4px; }
  .dealer { font-size: .76rem; }
}
