:root {
  color-scheme: dark;
  --ink: #f2eedf;
  --muted: #a7b5aa;
  --felt: #0f3d31;
  --felt-deep: #071f1a;
  --panel: rgba(8, 31, 25, .86);
  --line: rgba(240, 224, 174, .16);
  --gold: #d4ae61;
  --red: #cb5b52;
  --green: #6fc49b;
  --shadow: 0 24px 80px rgba(0,0,0,.35);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--felt-deep); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(84, 145, 107, .22), transparent 36rem),
    radial-gradient(circle at 90% 35%, rgba(176, 135, 63, .10), transparent 34rem),
    linear-gradient(145deg, #09271f, #061812 74%);
}
button, input, select { font: inherit; }
button { color: inherit; }
.grain { position: fixed; inset: 0; opacity: .06; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E"); }
.shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 26px 0 max(40px, env(safe-area-inset-bottom)); position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); font-family: Georgia, serif; font-size: 23px; background: rgba(0,0,0,.2); }
.brand h1 { margin: 0; font: 600 22px/1.1 Georgia, serif; letter-spacing: .04em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.button, button {
  border: 1px solid var(--line); background: rgba(255,255,255,.045); border-radius: 12px; padding: 10px 15px; cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
button:hover { background: rgba(255,255,255,.09); border-color: rgba(212,174,97,.45); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .38; cursor: not-allowed; }
.primary { background: var(--gold); color: #182319; border-color: transparent; font-weight: 750; }
.primary:hover { background: #e3c173; }
.danger { color: #ffaaa4; }
.link-button { border: 0; background: none; padding: 6px; color: var(--muted); }
.hero { display: grid; grid-template-columns: 1.25fr .75fr; gap: 22px; align-items: stretch; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.hero-copy { padding: clamp(30px, 6vw, 72px); min-height: 460px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative; }
.hero-copy::after { content: "♠"; position: absolute; right: -18px; bottom: -100px; font: 330px/1 Georgia, serif; color: rgba(212,174,97,.055); transform: rotate(-8deg); }
.eyebrow { color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.hero h2 { margin: 14px 0 18px; max-width: 700px; font: 500 clamp(42px, 7vw, 82px)/.92 Georgia, serif; letter-spacing: -.035em; }
.hero-copy > p { color: var(--muted); max-width: 620px; font-size: 17px; line-height: 1.65; margin: 0; }
.login { padding: 28px; display: flex; flex-direction: column; justify-content: center; }
.login h3, .section-title { font: 500 28px/1.15 Georgia, serif; margin: 0 0 8px; }
.login p, .subtle { color: var(--muted); line-height: 1.55; }
.field { display: grid; gap: 7px; margin: 15px 0; }
.field label { color: var(--muted); font-size: 13px; }
input, select { width: 100%; border: 1px solid var(--line); background: rgba(0,0,0,.2); color: var(--ink); border-radius: 11px; padding: 12px 13px; outline: none; }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,174,97,.1); }
.login .primary { margin-top: 13px; width: 100%; padding: 13px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-12 { grid-column: span 12; }
.section { padding: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.game-list { display: grid; gap: 10px; }
.game-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.game-row h3 { margin: 0 0 5px; font: 500 19px Georgia, serif; }
.game-row p { margin: 0; color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }
.rules-mini { display: grid; gap: 15px; margin-top: 22px; }
.rule { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.rule i { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: rgba(212,174,97,.1); color: var(--gold); font: normal 15px Georgia, serif; }
.rule strong { display:block; margin-bottom: 3px; }
.rule span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.table-shell { position: relative; min-height: 650px; padding: 18px; overflow: hidden; }
.felt-table { position: absolute; inset: 86px 6% 110px; border: 1px solid rgba(231,210,154,.26); border-radius: 48%; background: radial-gradient(circle at center, #155440 0, #0c3b2e 72%); box-shadow: inset 0 0 80px rgba(0,0,0,.28), 0 30px 80px rgba(0,0,0,.24); }
.table-center { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); text-align: center; width: min(80%, 440px); }
.phase { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .15em; }
.contract { font: 500 23px Georgia, serif; margin: 8px 0; }
.trick { position:relative; width:220px; height:184px; margin:12px auto 0; }
.trick-play { position:absolute; width:96px; display:flex; flex-direction:column; align-items:center; gap:4px; }
.trick-seat-0 { left:62px; top:84px; }
.trick-seat-1 { left:0; top:0; }
.trick-seat-2 { right:0; top:0; }
.trick-owner { max-width:96px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; font-weight:700; color:var(--ink); }
.trick .mini-card { width:46px; height:65px; font-size:15px; }
.seat { position: absolute; z-index: 4; width: 210px; text-align: center; }
.seat-0 { bottom: 18px; left: 50%; transform: translateX(-50%); }
.seat-1 { top: 18px; left: 24px; }
.seat-2 { top: 18px; right: 24px; }
.avatar { width: 43px; height: 43px; margin: 0 auto 7px; display:grid; place-items:center; border-radius: 50%; background:#1d5a46; border:2px solid rgba(255,255,255,.15); font: 600 18px Georgia,serif; }
.seat.active .avatar { border-color: var(--gold); box-shadow: 0 0 0 5px rgba(212,174,97,.12); }
.seat-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.seat-role { font-size:12px; color:var(--gold); margin-top:4px; }
.scoreline { color: var(--muted); font-size: 11px; margin-top: 5px; display:flex; justify-content:center; align-items:center; gap:5px; flex-wrap:wrap; }
.scoreline span { white-space:nowrap; }
.scoreline strong { white-space:nowrap; color:#d7fff0; background:rgba(111,196,155,.18); border:1px solid rgba(111,196,155,.4); border-radius:999px; padding:2px 6px; font-size:11px; }
.cards { position: absolute; left: 50%; bottom: 17px; transform: translateX(-50%); display:flex; justify-content:center; width:min(94%, 760px); padding-top: 18px; }
.card { width: clamp(48px, 7.2vw, 72px); height: clamp(72px, 10.5vw, 104px); margin-left: clamp(-17px, -1.5vw, -7px); padding: 6px; border-radius: 9px; background: #f7f3e9; color:#18231d; border: 1px solid rgba(0,0,0,.22); box-shadow: 0 8px 18px rgba(0,0,0,.28); font: 700 clamp(14px, 2vw, 20px) Georgia, serif; text-align:left; position:relative; }
.card:first-child { margin-left: 0; }
.card.red { color:#b73537; }
.card.playable { transform: translateY(-9px); border-color: var(--gold); }
.card.selected { transform: translateY(-20px); box-shadow: 0 0 0 3px var(--gold), 0 15px 25px rgba(0,0,0,.34); }
.card-symbol { position:absolute; left:50%; top:50%; transform:translate(-50%,-46%); font-size: clamp(25px, 4vw, 42px); }
.mini-card { width: 55px; height: 80px; position: relative; padding: 5px; border-radius: 8px; background:#f6f1e6; color:#17221d; font: 700 16px Georgia,serif; text-align:left; box-shadow:0 8px 20px rgba(0,0,0,.25); }
.mini-card.red { color:#b73537; }
.mini-card .card-symbol { font-size:28px; }
.trick.last-trick { opacity:1; }
.last-trick-label { color:var(--green); font-size:10px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; }
.seat-open-hand { display:flex; justify-content:center; margin:8px auto 0; padding:5px 7px; width:max-content; max-width:220px; border:1px solid rgba(111,196,155,.32); border-radius:10px; background:rgba(3,20,15,.78); box-shadow:0 10px 30px rgba(0,0,0,.28); }
.seat-open-hand .mini-card { flex:0 0 31px; width:31px; height:45px; margin-right:-11px; font-size:9px; box-shadow:0 4px 10px rgba(0,0,0,.25); }
.seat-open-hand .mini-card:last-child { margin-right:0; }
.seat-open-hand .card-symbol { font-size:16px; }
.actions { position: absolute; left: 50%; bottom: 126px; transform: translateX(-50%); width: min(92%, 620px); display:flex; flex-wrap:wrap; gap:8px; justify-content:center; z-index: 3; }
.actions select { width: auto; min-width: 190px; }
.game-layout { display:grid; grid-template-columns:minmax(0, 1fr) 300px; gap:18px; }
.side-panel { padding:20px; }
.scoreboard { display:grid; gap:10px; }
.paper-score { margin:0 0 22px; padding:24px; color:#243957; background:repeating-linear-gradient(0deg,transparent 0,transparent 27px,#96b6c521 28px),#faf5e8; border:1px solid #d6cbb6; border-radius:5px; box-shadow:0 8px 25px #0003; }
.paper-heading { display:flex; justify-content:space-between; gap:12px; align-items:center; border-bottom:1px solid #24395744; padding-bottom:14px; }
.paper-heading span { font-size:11px; letter-spacing:.17em; }
.paper-heading h2 { margin:4px 0 0; font:italic 28px Georgia,serif; }
.paper-caption { text-align:right; font-size:13px; line-height:1.6; }
.paper-content { max-width:680px; margin:auto; }
.paper-diagram { width:100%; max-height:610px; }
.paper-drawing { min-width:0; }
.paper-scroll { overflow-x:auto; }
.paper-zoom { color:#243957; border-color:#24395744; margin-top:12px; font-size:13px; background:transparent; }
.paper-drawing.zoomed .paper-diagram { min-width:680px; max-height:none; }
.paper-balances small { display:block; font-size:13px; margin-top:5px; }
.paper-diagram path { fill:none; stroke:#243957; stroke-width:2; stroke-linejoin:round; }
.paper-sector text { fill:#243957; text-anchor:middle; font:19px Georgia,serif; }
.paper-sector .paper-name { font-size:23px; font-weight:bold; }
.paper-sector .paper-number { font-style:italic; font-weight:bold; }
.paper-sector .paper-whist { font-size:17px; }
.paper-sector .paper-total { font-size:20px; font-weight:bold; }
.paper-sector .score-positive { fill:#167044; }
.paper-sector .score-negative { fill:#b52f35; }
.score-positive, .results b.score-positive { color:#83ddb0; }
.score-negative, .results b.score-negative { color:#ff9799; }
.score-neutral, .results b.score-neutral { color:var(--muted); }
.stats-scroll { overflow-x:auto; }
.detail-table { width:100%; border-collapse:collapse; font-size:13px; }
.detail-table th,.detail-table td { padding:12px 10px; border-bottom:1px solid var(--line); text-align:left; white-space:nowrap; }
.detail-table thead { color:var(--muted); }
.detail-table td:last-child { font-weight:800; }
.deal-stat { padding:14px 0; border-top:1px solid var(--line); }
.deal-stat summary { cursor:pointer; line-height:1.6; font-size:14px; }
.deal-stat summary span { color:var(--muted); }
.stat-card { min-width:0; }
.four-seats .seat-1,.four-seats .seat-2 { top:105px; }
.four-seats .seat-3 { top:10px; }
.four-seats .seat-3 .avatar { display:none; }
.four-seats.table-shell { min-height:800px; }
.four-seats .table-center { top:48%; }
.four-seats .talon-corner { top:12px; }
.paper-details { min-width:0; }
.paper-details h3 { font:italic 23px Georgia,serif; margin:0 0 8px; }
.paper-details p { font-size:14px; line-height:1.55; }
.paper-matrix-wrap { overflow-x:auto; }
.paper-matrix { width:100%; border-collapse:collapse; font-size:14px; }
.paper-matrix th,.paper-matrix td { padding:10px 7px; border:1px solid #24395744; text-align:center; max-width:100px; overflow-wrap:anywhere; }
.paper-matrix th { font-weight:600; }
.paper-balances { margin-top:20px; }
.paper-balances > div { display:flex; justify-content:space-between; gap:12px; padding:9px 0; border-bottom:1px solid #24395722; }
.paper-balances strong { white-space:nowrap; }
.paper-details summary { cursor:pointer; font-weight:600; }
.last-score { margin-top:16px; font-size:13px; line-height:1.5; }
.last-score p { margin:8px 0; }
@media(max-width:900px) { .paper-content { grid-template-columns:1fr; gap:6px; } .paper-score { padding:14px; } .paper-diagram { max-height:500px; } }
.score-player { border-bottom:1px solid var(--line); padding: 0 0 11px; }
.score-player:last-child { border:0; }
.score-player strong { display:block; margin-bottom:5px; }
.score-cells { display:grid; grid-template-columns:repeat(3,1fr); gap:5px; color:var(--muted); font-size:11px; }
.score-cells b { display:block; color:var(--ink); font-size:16px; margin-top:2px; }
.auction-log, .history-list { display:grid; gap:7px; max-height:230px; overflow:auto; }
.log-row { display:flex; justify-content:space-between; gap:10px; color:var(--muted); font-size:12px; }
.side-title { color:var(--gold); text-transform:uppercase; letter-spacing:.13em; font-size:10px; margin:22px 0 10px; }
.copy-row { display:flex; gap:7px; }
.copy-row input { min-width:0; font-size:12px; }
.calculator { display:grid; gap:16px; }
.calc-player { display:grid; grid-template-columns:1.4fr repeat(3, .7fr); gap:9px; align-items:end; padding:14px; border:1px solid var(--line); border-radius:14px; }
.calc-player .field { margin:0; }
.whist-grid { grid-column:1/-1; display:grid; grid-template-columns:1fr 1fr; gap:9px; }
.result-row { display:grid; grid-template-columns:1fr repeat(3,.8fr); gap:8px; padding:12px 4px; border-bottom:1px solid var(--line); }
.result-row.total { font-weight:800; color:var(--gold); }
.note { border-left:2px solid var(--gold); padding:12px 14px; background:rgba(212,174,97,.06); color:var(--muted); font-size:13px; line-height:1.55; }
.toast { position:fixed; left:50%; bottom:24px; transform:translate(-50%, 20px); opacity:0; pointer-events:none; padding:11px 15px; border-radius:11px; background:#ece5d2; color:#16251d; box-shadow:var(--shadow); transition:.2s; z-index:10; max-width:calc(100% - 30px); }
.toast.show { opacity:1; transform:translate(-50%, 0); }
.toast.error { background:#ffb6ae; color:#35120f; }
.compact-form { display:grid; gap:10px; }
.compact-form .field { margin:5px 0; }
.form-pair { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.check { display:flex; align-items:center; gap:9px; color:var(--muted); font-size:13px; padding:7px 0; }
.check input { width:auto; accent-color:var(--gold); }
.wide { width:100%; margin-top:10px; }
.settings-summary { color:var(--muted); font-size:12px; line-height:1.5; margin:12px 0; }
.table-shell { min-height:720px; }
.seat-0 { bottom:138px; z-index:4; }
.seat-3 { top:18px; left:50%; transform:translateX(-50%); }
.seat.sitting-out { opacity:.55; }
.hand-zone { position:absolute; left:2%; right:2%; bottom:12px; z-index:5; text-align:center; }
.your-label { min-height:20px; margin-bottom:4px; color:var(--ink); font-size:12px; font-weight:750; text-shadow:0 2px 8px #000; }
.hand-zone .cards { position:static; transform:none; width:100%; padding-top:10px; }
.actions { bottom:238px; }
.talon-corner { position:absolute; left:18px; top:110px; z-index:3; padding:6px; border:1px solid var(--line); border-radius:12px; background:rgba(4,22,17,.72); }
.talon-corner > span { display:block; margin-bottom:4px; color:var(--gold); font-size:9px; text-transform:uppercase; letter-spacing:.14em; }
.talon-corner > div { display:flex; gap:4px; }
.talon-corner .mini-card { width:30px; height:44px; font-size:11px; }
.talon-corner .card-symbol { font-size:19px; }
.open-hands { display:grid; gap:10px; }
.open-hand b { display:block; margin-bottom:5px; font-size:12px; }
.open-hand > div { display:flex; overflow-x:auto; padding-bottom:5px; }
.open-hand .mini-card { flex:0 0 34px; width:34px; height:49px; margin-right:-8px; font-size:10px; }
.open-hand .card-symbol { font-size:17px; }
.stats-grid { display:grid; gap:14px; }
.manual-entry { margin-bottom:14px; }
.manual-entry h3 { margin:9px 0 0; font:500 22px Georgia,serif; }
.manual-players { display:grid; gap:12px; }
.manual-player { padding:14px; border:1px solid var(--line); border-radius:14px; }
.manual-player h4 { margin:0 0 10px; }
.manual-number-grid { display:grid; grid-template-columns:1.5fr repeat(8, minmax(65px,1fr)); gap:8px; align-items:end; }
.manual-number-grid .field,.manual-whists .field { margin:0; }
.manual-whists { display:flex; flex-wrap:wrap; gap:8px; align-items:end; margin-top:10px; }
.manual-whists > .subtle { width:100%; }
.manual-whists label { font-size:11px; }
.stat-card { padding:18px; border:1px solid var(--line); border-radius:16px; background:rgba(255,255,255,.025); }
.stat-card h3 { margin:9px 0 0; font:500 22px Georgia,serif; }
.stat-card .section-head { margin-bottom:12px; }
.stat-table { display:grid; gap:6px; }
.stat-table > div { display:grid; grid-template-columns:minmax(130px,1.4fr) repeat(4,1fr); gap:8px; padding:9px 0; border-bottom:1px solid var(--line); font-size:12px; }
.stat-table span { color:var(--muted); }
.results { display:flex; gap:9px; flex-wrap:wrap; margin-top:12px; }
.results span { padding:7px 10px; border-radius:999px; background:rgba(212,174,97,.08); font-size:12px; }
.results b { color:var(--gold); }
.event-list { max-height:260px; overflow:auto; margin-top:14px; border-top:1px solid var(--line); padding-top:8px; }
.event-list div { display:flex; justify-content:space-between; gap:10px; padding:6px 0; color:var(--muted); font-size:11px; }
.small-field { width:150px; }
.admin-user-form { display:grid; grid-template-columns:1fr 1fr 1fr 1fr auto; gap:8px; margin:18px 0 22px; }
.user-list { display:grid; gap:8px; }
.user-row { display:grid; grid-template-columns:minmax(150px,1fr) minmax(130px,.8fr) auto auto; align-items:center; gap:8px; padding:11px; border:1px solid var(--line); border-radius:12px; }
.user-row small { display:block; color:var(--muted); margin-top:3px; }
@media (max-width: 900px) {
  .hero { grid-template-columns:1fr; } .hero-copy { min-height:360px; } .grid { display:block; } .grid > * { margin-bottom:18px; }
  .game-layout { grid-template-columns:1fr; } .side-panel { order:2; }
  .admin-user-form { grid-template-columns:1fr 1fr; }
  .admin-user-form button { grid-column:1/-1; }
  .manual-number-grid { grid-template-columns:repeat(3,1fr); }
  .manual-number-grid .field:first-child { grid-column:1/-1; }
}
@media (max-width: 640px) {
  .shell { width:min(100% - 16px, 1180px); padding-top:14px; } .topbar { align-items:flex-start; margin-bottom:16px; }
  .brand p { display:none; } .nav button { padding:8px 10px; font-size:12px; }
  .hero-copy { padding:30px 24px; min-height:360px; } .hero h2 { font-size:46px; }
  .login, .section { padding:20px; } .section-head { align-items:flex-start; }
  .game-row { grid-template-columns:1fr; } .game-row button { width:100%; }
  .table-shell { min-height:720px; padding:10px; border-radius:16px; }
  .felt-table { inset:106px 2% 120px; border-radius:42%; }
  .seat { width:125px; } .seat-1 { left:2px; } .seat-2 { right:2px; } .seat-3 { width:120px; } .seat-0 { bottom:142px; }
  .scoreline { font-size:12px; gap:3px; } .scoreline strong { font-size:12px; padding:2px 6px; } .table-center { top:44%; }
  .four-seats .table-center { top:48%; }
  .seat-open-hand { max-width:124px; padding:4px; }
  .seat-open-hand .mini-card { flex-basis:23px; width:23px; height:36px; margin-right:-10px; font-size:8px; }
  .seat-open-hand .card-symbol { font-size:13px; }
  .actions { bottom:238px; } .actions select { width:100%; min-width:0; }
  .card { margin-left:-14px; width:clamp(38px,12vw,48px); flex-shrink:0; } .calc-player { grid-template-columns:1fr 1fr; } .calc-player .field:first-child { grid-column:1/-1; }
  .whist-grid { grid-template-columns:1fr; } .result-row { grid-template-columns:1.2fr repeat(3,.7fr); font-size:12px; }
  .talon-corner { top:110px; left:8px; }
  .stat-table > div { grid-template-columns:1fr 1fr; }
  .stat-table strong { grid-column:1/-1; }
  .admin-user-form, .user-row, .form-pair { grid-template-columns:1fr; }
  .admin-user-form button { grid-column:auto; }
}
