@font-face { font-family: 'Jost'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/jost-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Jost'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/jost-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --orange: #f26b21;
  --orange-l: #ff8c42;
  --gold: #ffc266;
  --red: #ff6b5e;
  --green: #7bd88f;
  --paper: #fbf7ee;
  --ink: #111;
  --text: #f4f1ea;
  --muted: rgba(244, 241, 234, .62);
  --line: rgba(244, 241, 234, .14);
  --glass: rgba(18, 17, 16, .72);
  --cw: 72px;
  --ch: 108px;
  --top: calc(52px + env(safe-area-inset-top));
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Jost', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: #0e0d0c;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button, [role=button], a[href], summary, label[for], select, .tile, .card.legal, .card.pick, .seg button { cursor: pointer; }
button:disabled, [aria-disabled=true] { cursor: not-allowed; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; }

/* ---------- tables ---------- */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: var(--felt);
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
.table-night { --felt: radial-gradient(120% 80% at 50% 38%, #2b2825 0%, #191715 55%, #0d0c0b 100%); }
.table-green { --felt: radial-gradient(120% 80% at 50% 38%, #2f7354 0%, #1b4b36 55%, #0e2a1e 100%); }
.table-bordo { --felt: radial-gradient(120% 80% at 50% 38%, #74263c 0%, #431425 55%, #230a12 100%); }
.table-blue  { --felt: radial-gradient(120% 80% at 50% 38%, #2b5a7c 0%, #183a55 55%, #0c1f30 100%); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(24px + var(--safe-b));
  max-width: 560px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 6px 2px 4px; }
.brand svg { width: 40px; height: 40px; }
.brand h1 { font-size: 40px; font-weight: 500; letter-spacing: .5px; margin: 0; line-height: 1; }
.tag { color: var(--muted); margin: 6px 2px 22px; font-size: 15px; line-height: 1.4; }
.resume {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  background: var(--orange); color: #fff; border-radius: 16px; padding: 16px 18px; margin-bottom: 14px; text-align: left;
}
.resume b { font-size: 18px; font-weight: 600; display: block; }
.resume span { opacity: .85; font-size: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative; text-align: left; min-height: 116px; padding: 14px 14px 12px; border-radius: 16px;
  background: rgba(255, 255, 255, .055); border: 1px solid var(--line); overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
}
.tile:active { transform: scale(.98); }
.tile.wide { grid-column: 1 / -1; min-height: 96px; }
.tile .g { font-size: 21px; font-weight: 600; }
.tile .f { font-size: 15px; color: var(--orange-l); font-weight: 500; }
.tile .d { font-size: 13px; color: var(--muted); margin-top: 6px; padding-right: 58px; line-height: 1.3; }
.tile .mini { position: absolute; right: -6px; bottom: -10px; display: flex; opacity: .9; pointer-events: none; }
.tile .mini svg { width: 34px; height: 51px; margin-left: -14px; border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.tile .mini svg:nth-child(1) { transform: rotate(-14deg) translateY(4px); }
.tile .mini svg:nth-child(3) { transform: rotate(14deg) translateY(4px); }
.links { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.links button { flex: 1; padding: 13px 10px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid var(--line); font-size: 15px; }
.foot { margin-top: 18px; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; gap: 10px; }
.foot .ok::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: 1px; }
.foot .wait::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-right: 6px; vertical-align: 1px; }

.head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.head h2 { margin: 0; font-size: 24px; font-weight: 500; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text); }
.iconbtn:active { background: rgba(255,255,255,.1); }
.iconbtn svg { width: 24px; height: 24px; }
.iconbtn:disabled { opacity: .35; }

.field { padding: 14px 0; border-bottom: 1px solid var(--line); }
.field > label, .field > .lbl { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { padding: 9px 14px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid var(--line); font-size: 15px; }
.seg button[aria-pressed=true] { background: var(--orange); border-color: var(--orange); color: #fff; }
.note { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 8px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.rules p { line-height: 1.55; font-size: 15.5px; color: rgba(244,241,234,.9); margin: 0 0 12px; }
.rules b { color: var(--text); font-weight: 600; }
table.stats { width: 100%; border-collapse: collapse; font-size: 15px; }
table.stats th, table.stats td { padding: 10px 6px; text-align: right; border-bottom: 1px solid var(--line); }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats th { color: var(--muted); font-weight: 500; font-size: 13px; }

/* ---------- game ---------- */
.game { position: fixed; inset: 0; }
.topbar {
  position: absolute; left: 0; right: 0; top: 0; height: var(--top); padding: env(safe-area-inset-top) 4px 0;
  display: flex; align-items: center; gap: 2px; z-index: 500;
  background: linear-gradient(rgba(0,0,0,.45), rgba(0,0,0,0));
}
.score { flex: 1; display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 15px; min-width: 0; }
.score .side { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 44px; }
.score .side small { font-size: 11.5px; color: var(--muted); white-space: nowrap; max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
.score .side b { font-size: 21px; font-weight: 600; }
.score .side.me b { color: var(--orange-l); }
.score .sep { color: var(--muted); font-size: 12px; text-align: center; line-height: 1.15; }
.score .sep .suit-ic { display: block; margin: 0 auto 2px; }
.board { position: absolute; left: 0; right: 0; top: var(--top); bottom: 0; }

.card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch);
  transform-origin: 50% 50%;
  transition: transform .38s cubic-bezier(.2,.8,.2,1), opacity .32s ease, filter .2s;
  will-change: transform; border-radius: 7px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
}
.card svg { display: block; width: 100%; height: 100%; }
.card .back { display: none; position: absolute; inset: 0; }
.card.down .front { display: none; }
.card.down .back { display: block; }
.card.dim { filter: brightness(.5) saturate(.5) drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.card.pick::after, .card.hint::after {
  content: ''; position: absolute; inset: -3px; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--orange-l);
}
.card.hint::after { box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(255,194,102,.9); animation: glow 1.1s ease-in-out infinite alternate; }
@keyframes glow { from { opacity: .55; } to { opacity: 1; } }
.card.instant { transition: none; }

.seat {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center;
  gap: 3px; z-index: 300; pointer-events: none; text-align: center;
}
.seat .av {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 16px;
  background: #2b2926; border: 2px solid rgba(255,255,255,.18); color: var(--text); position: relative;
}
.seat.mate .av { border-color: var(--orange); }
.seat.turn .av { box-shadow: 0 0 0 3px var(--orange-l); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 0 2px rgba(255,140,66,.5); } to { box-shadow: 0 0 0 5px rgba(255,140,66,.95); } }
.seat .nm { font-size: 13px; font-weight: 500; text-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: nowrap; }
.seat .sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.seat .dealer { position: absolute; right: -8px; top: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); color: var(--ink); font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.bubble {
  position: absolute; z-index: 420; transform: translate(-50%, -50%); pointer-events: none;
  background: var(--paper); color: var(--ink); font-weight: 600; font-size: 14px; padding: 6px 11px; border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); white-space: nowrap; animation: pop .22s ease-out;
}
.bubble.orange { background: var(--orange); color: #fff; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.count {
  position: absolute; z-index: 290; transform: translate(-50%, -50%); font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.45); border-radius: 999px; padding: 2px 8px; pointer-events: none; white-space: nowrap;
}
.chip {
  position: absolute; z-index: 290; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.5); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 9px; font-size: 13.5px; white-space: nowrap; pointer-events: none;
}

.status {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 400; font-size: 14.5px; color: var(--text);
  text-shadow: 0 1px 3px rgba(0,0,0,.7); white-space: nowrap; pointer-events: none; transition: opacity .2s;
}
.panel {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 450; display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; width: max-content; max-width: calc(100% - 20px);
}
.btn {
  min-height: 44px; padding: 0 18px; border-radius: 999px; font-weight: 600; font-size: 16px;
  background: rgba(20,19,18,.82); border: 1px solid rgba(255,255,255,.2); color: var(--text);
  box-shadow: 0 3px 10px rgba(0,0,0,.35); display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn:disabled { opacity: .4; }
.btn.hint { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255,194,102,.9); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 15px; }
.bids { display: grid; grid-template-columns: repeat(4, 64px); gap: 8px; }
.bids .btn { padding: 0; }
.bids .wide2 { grid-column: span 2; }
.bids .full { grid-column: 1 / -1; }
.dock .panel, .dock .btn { pointer-events: auto; }
.suits4 { display: grid; grid-template-columns: repeat(4, 72px); gap: 8px; }
.suits4 .btn { flex-direction: column; height: 76px; border-radius: 16px; gap: 2px; font-size: 13px; font-weight: 500; padding: 0; }

.modal { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 520px; background: #1b1a18; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(18px + var(--safe-b)); animation: up .25s cubic-bezier(.2,.8,.2,1); max-height: 92vh; overflow-y: auto;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.sheet .subt { color: var(--muted); margin-bottom: 14px; font-size: 14.5px; }
.sheet .row { display: flex; gap: 10px; margin-top: 16px; }
.sheet .row .btn { flex: 1; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.sheet td, .sheet th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.sheet td:first-child, .sheet th:first-child { text-align: left; color: var(--muted); }
.sheet th { font-weight: 600; }
.sheet tr.tot td { font-weight: 700; color: var(--text); border-bottom: 0; font-size: 17px; }
.sheet .big { font-size: 44px; font-weight: 600; text-align: center; margin: 8px 0 2px; letter-spacing: 1px; }
.sheet .menu-list button { display: flex; width: 100%; padding: 15px 6px; font-size: 17px; border-bottom: 1px solid var(--line); gap: 12px; align-items: center; }
.sheet .menu-list button:last-child { border-bottom: 0; }
.trickview { display: flex; justify-content: center; gap: 10px; margin: 10px 0 6px; }
.trickview .tv { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.trickview svg { width: 64px; height: 96px; display: block; }
.trickview .win { color: var(--orange-l); font-weight: 600; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); z-index: 950;
  background: var(--paper); color: var(--ink); padding: 10px 14px; border-radius: 12px; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 12px; animation: up .25s;
}
.toast button { color: var(--orange); font-weight: 600; }
