:root {
  --felt: #347552; --felt-edge: #18402b; --wood1: #2a140b; --wood2: #5b3019;
  --gold: #c9a24a; --gold-hi: #e0bf6c; --on-gold: #2a0a10;
  --ivory: #f1e6cf; --muted: #c4ab8c;
  --paper: #efe3c8; --paper2: #e6d6b4; --ink: #2e2219; --red-ink: #8e1b1b;
  --card: #faf4e4; --card-line: #d5c6a3; --red: #a3191f; --black: #1e1a1a;
  --cw: 70px; --ch: 98px;
  --serif: 'PT Serif', Georgia, serif;
  --title: 'Cormorant Garamond', 'PT Serif', Georgia, serif;
  --hand: 'Marck Script', 'PT Serif', cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #150508; color: var(--ivory); font-family: var(--serif); font-size: 16px; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }

/* ---------- салон ---------- */
#room { position: fixed; inset: 0; background: #1a0609 url(img/salon_tall.webp) center top / cover no-repeat; }
@media (min-aspect-ratio: 1/1) { #room { background-image: url(img/salon_wide.webp); background-position: center 30%; } }
#room::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 55%, rgba(20,4,8,.15), rgba(10,2,4,.65)); }
.glow { position: absolute; width: 38vmax; height: 38vmax; border-radius: 50%; background: radial-gradient(circle, rgba(255,190,110,.22), rgba(255,160,80,0) 60%); top: 4%; z-index: 1; animation: flicker 3.2s infinite alternate ease-in-out; mix-blend-mode: screen; }
.g1 { left: -12vmax; } .g2 { right: -12vmax; animation-delay: -1.4s; }
@keyframes flicker { 0% { opacity: .75; transform: scale(1); } 30% { opacity: .95; } 55% { opacity: .7; transform: scale(1.03); } 80% { opacity: 1; } 100% { opacity: .82; transform: scale(.99); } }

#app { position: absolute; inset: 0; display: flex; }
#main { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

/* ---------- верхняя строка ---------- */
#topbar { position: relative; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: max(6px, env(safe-area-inset-top)) 10px 6px; min-height: 52px; background: linear-gradient(rgba(24,5,9,.86), rgba(24,5,9,.55)); border-bottom: 1px solid rgba(201,162,74,.35); }
.brand { font-family: var(--title); font-weight: 700; font-size: 26px; color: var(--gold-hi); letter-spacing: .03em; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.brand small { font-family: var(--hand); font-weight: 400; font-size: 17px; color: var(--muted); margin-left: 4px; }
.brand .orn { font-size: 18px; color: var(--gold); }
.tools { display: flex; gap: 6px; align-items: center; }
.tb { min-height: 40px; padding: 0 12px; border-radius: 4px; border: 1.5px solid rgba(241,230,207,.55); background: rgba(30,6,10,.55); font-size: 15px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tb:hover { border-color: var(--gold-hi); color: var(--gold-hi); }
.tb svg { width: 18px; height: 18px; }
.tb.icon { width: 42px; padding: 0; justify-content: center; font-size: 18px; }
.tb.narrow { display: none; }
.menu { position: absolute; right: 56px; top: 50px; background: var(--paper); color: var(--ink); border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.6); padding: 6px; display: flex; flex-direction: column; min-width: 190px; border: 1px solid var(--gold); }
.menu[hidden] { display: none; }
.menu button { text-align: left; background: none; border: 0; padding: 12px 14px; min-height: 44px; font-size: 16px; border-radius: 3px; }
.menu button:hover { background: rgba(201,162,74,.3); }

/* ---------- стол ---------- */
#table { position: relative; flex: 1 1 auto; margin: 6px 8px max(8px, env(safe-area-inset-bottom)); border-radius: 26px; padding: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--wood2), var(--wood1) 40%, #4a2513 60%, var(--wood1));
  box-shadow: 0 18px 40px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,220,160,.12); }
.felt { position: absolute; inset: 10px; border-radius: 18px; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255,200,130,.16), rgba(255,200,130,0) 58%),
    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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 50%, var(--felt) 35%, var(--felt-edge) 100%);
  box-shadow: inset 0 0 0 1.5px rgba(201,162,74,.55), inset 0 0 0 5px rgba(0,0,0,.25), inset 0 0 0 6px rgba(201,162,74,.25), inset 0 0 60px rgba(0,0,0,.55); }
#cards { position: absolute; inset: 0; z-index: 1; }

/* ---------- карты ---------- */
.card { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); transform-origin: 0 0; transition: transform 220ms ease-out, opacity 300ms; will-change: transform; perspective: 600px; }
.card .lift { width: 100%; height: 100%; transition: transform 140ms ease-out, filter 140ms; }
.card .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 300ms ease-in-out; transform: rotateY(180deg); }
.card.up .inner { transform: rotateY(0deg); }
.card .face, .card .back { position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.card .face { background: linear-gradient(160deg, #fffaf0, var(--card) 60%, #f3e9d2); border: 1px solid var(--card-line); color: var(--black); overflow: hidden; }
.card.red .face { color: var(--red); }
.card .back { transform: rotateY(180deg); background: var(--card); border: 1px solid var(--card-line); padding: 4px; }
.card .back::before { content: ''; position: absolute; inset: 4px; border-radius: 3px; border: 1px solid var(--gold);
  background:
    repeating-linear-gradient(45deg, rgba(201,162,74,.75) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, rgba(201,162,74,.75) 0 1px, transparent 1px 7px),
    radial-gradient(circle, #7d1d2d, #4e0f1b); }
.idx { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: .95; font-weight: 700; font-family: var(--serif); }
.idx b { font-size: calc(var(--cw) * .25); letter-spacing: -.04em; }
.idx i { font-style: normal; font-size: calc(var(--cw) * .22); }
.idx.tl { left: calc(var(--cw) * .05); top: calc(var(--cw) * .05); }
.idx.br { right: calc(var(--cw) * .05); bottom: calc(var(--cw) * .05); transform: rotate(180deg); }
.pip { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); font-size: calc(var(--cw) * .58); line-height: 1; }
.court { position: absolute; left: 24%; right: 24%; top: 22%; bottom: 22%; border: 1px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 700; font-size: calc(var(--cw) * .42); border-radius: 2px; }
.court small { position: absolute; bottom: 2px; font-size: calc(var(--cw) * .17); }
.card.playable { cursor: pointer; }
@media (hover: hover) { .card.playable:hover .lift { transform: translateY(-14px); } .card.playable:hover .face { box-shadow: 0 0 0 2px var(--gold), 0 6px 10px rgba(0,0,0,.45); } }
.card.sel .lift { transform: translateY(-14px); }
.card.sel .face { box-shadow: 0 0 0 2px var(--gold), 0 6px 10px rgba(0,0,0,.45); }
.card.dim .lift { filter: brightness(.55) saturate(.6); }
.card.dim { pointer-events: none; }
.card.dsel .lift { transform: translateY(12px) !important; filter: brightness(.6) sepia(.3); }
.card.dsel .face { box-shadow: 0 0 0 2px var(--gold), 0 2px 4px rgba(0,0,0,.4) !important; }
.card.gone { opacity: 0; }
.card.win .face { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 14px rgba(224,191,108,.6); }

/* ---------- плашки ---------- */
.plaque { position: absolute; z-index: 150; padding: 6px 10px 6px; border-radius: 6px; background: linear-gradient(#3a0f18, #26080e); border: 1px solid rgba(201,162,74,.7); box-shadow: 0 4px 10px rgba(0,0,0,.5), inset 0 0 0 3px rgba(0,0,0,.25), inset 0 0 0 4px rgba(201,162,74,.25); min-width: 120px; transition: box-shadow .2s; }
.plaque .nm { font-family: var(--title); font-weight: 700; font-size: 19px; color: var(--gold-hi); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plaque .sub { font-size: 13px; color: var(--muted); min-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plaque.turn { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 18px rgba(224,191,108,.5); }
.tally { font-family: var(--hand); color: var(--ivory); letter-spacing: 1px; font-size: 17px; min-height: 18px; white-space: nowrap; }
.tally s { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.bubble { position: absolute; top: calc(100% + 6px); background: var(--paper); color: var(--ink); font-family: var(--hand); font-size: 21px; line-height: 1; padding: 5px 12px 6px; border-radius: 12px 12px 12px 3px; box-shadow: 0 3px 6px rgba(0,0,0,.45); white-space: nowrap; opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s; pointer-events: none; }
#pl1 .bubble { left: 10px; }
#pl2 .bubble { right: 10px; border-radius: 12px 12px 3px 12px; }
.bubble.show { opacity: 1; transform: none; }
.bubble.red { color: var(--red-ink); }
.bubble.think { animation: blink 1s infinite; color: #6b5a48; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- ремарка ---------- */
#remark { position: absolute; z-index: 160; left: 14px; right: 14px; display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; min-height: 46px; background: linear-gradient(#f3e8cf, #e8d8b6); color: var(--ink); border-radius: 3px; box-shadow: 0 3px 8px rgba(0,0,0,.45); border-left: 3px solid var(--red-ink); }
#chip { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; padding-right: 8px; border-right: 1px solid rgba(46,34,25,.25); min-width: 44px; }
#chip b { font-family: var(--title); font-size: 18px; }
#chip .tally { color: var(--ink); font-size: 16px; min-height: 0; }
#chip .word { font-family: var(--hand); color: var(--red-ink); font-size: 17px; }
#remarkText { flex: 1 1 auto; font-size: 15px; line-height: 1.25; min-width: 0; }
#remarkText .s { font-weight: 700; }
#remarkText .r { color: var(--red); font-weight: 700; }
#remarkActions { display: flex; gap: 6px; }
.qbtn { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent; font-family: var(--title); font-weight: 700; font-size: 22px; color: var(--ink); }
.qbtn:hover { background: rgba(201,162,74,.35); }

.btn { min-height: 44px; padding: 0 16px; border-radius: 4px; font-weight: 700; font-size: 15px; border: 1.5px solid var(--gold); background: var(--gold); color: var(--on-gold); white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn:disabled { opacity: .4; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.ghost:hover:not(:disabled) { background: rgba(201,162,74,.25); }
.btn.big { min-height: 50px; font-size: 17px; padding: 0 22px; }

/* ---------- бумажная карточка в центре ---------- */
#panel { position: absolute; z-index: 170; left: 50%; transform: translateX(-50%); width: min(380px, calc(100% - 20px)); overflow: auto; overscroll-behavior: contain;
  background: var(--paper); color: var(--ink); border-radius: 3px; padding: 12px 14px 14px; box-shadow: 0 10px 28px rgba(0,0,0,.6);
  background-image: linear-gradient(rgba(150,110,60,.06), rgba(150,110,60,.12)); border: 1px solid #cdb88f; outline: 1px solid rgba(142,27,27,.35); outline-offset: -6px; }
#panel h3 { margin: 0 0 2px; font-family: var(--title); font-weight: 700; font-size: 23px; text-align: center; line-height: 1.1; }
#panel .lead { text-align: center; font-size: 15px; margin: 2px 0 8px; color: #5a4634; }
#panel .script { font-family: var(--hand); font-size: 20px; color: var(--ink); text-align: center; margin: 2px 0 6px; line-height: 1.15; }
#panel .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.grid { display: grid; grid-template-columns: 26px repeat(5, 1fr); gap: 2px; position: relative; }
.grid .hd { text-align: center; font-weight: 700; font-size: 17px; line-height: 26px; }
.grid .hd.r { color: var(--red); }
.grid .lv { font-family: var(--title); font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.cell { position: relative; height: 38px; border: 1px solid rgba(46,34,25,.22); background: rgba(255,255,255,.25); font-weight: 700; font-size: 16px; border-radius: 2px; padding: 0; color: var(--ink); }
.cell.r { color: var(--red); }
.cell.ok:hover, .cell.ok:focus-visible { background: var(--gold); color: var(--on-gold); outline: none; }
.cell.no { color: rgba(46,34,25,.35); cursor: default; }
.cell.no.r { color: rgba(163,25,31,.35); }
.cell.struck::after { content: ''; position: absolute; left: 14%; right: 14%; top: 50%; height: 1.6px; background: rgba(46,34,25,.75); transform: rotate(-8deg); }
.cell svg.oval { position: absolute; inset: -5px -3px; width: calc(100% + 6px); height: calc(100% + 10px); pointer-events: none; overflow: visible; }
.cell svg.oval path { fill: none; stroke: var(--red-ink); stroke-width: 2.2; stroke-linecap: round; }
.extra { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.extra .cell { height: 44px; font-size: 16px; }
.hist { font-family: var(--hand); font-size: 18px; text-align: center; color: #4b3a2b; margin-top: 6px; line-height: 1.2; }
.res { width: 100%; border-collapse: collapse; font-size: 15px; margin: 6px 0; }
.res td { padding: 3px 4px; border-bottom: 1px dotted rgba(46,34,25,.3); vertical-align: top; }
.res td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.res .red { color: var(--red-ink); }
.choice { display: flex; gap: 6px; justify-content: center; margin: 6px 0; flex-wrap: wrap; }
.choice button { min-height: 44px; min-width: 64px; border: 1.5px solid var(--ink); background: transparent; border-radius: 4px; font-weight: 700; }
.choice button.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.note { font-size: 14px; color: #5a4634; text-align: center; margin-top: 8px; line-height: 1.3; }

/* ---------- лист пули ---------- */
#sheet { position: relative; z-index: 40; flex: 0 0 36%; max-width: 520px; padding: 14px 16px 16px 6px; display: flex; flex-direction: column; }
#sheet .sheetHead { display: none; }
.paper { flex: 1 1 auto; overflow: auto; background: var(--paper); color: var(--ink); border-radius: 2px; padding: 14px 16px 18px; transform: rotate(-.6deg); box-shadow: 6px 10px 24px rgba(0,0,0,.65), 0 0 0 1px #cdb88f;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(150,100,40,.10), transparent 40%),
    radial-gradient(ellipse at 85% 90%, rgba(150,100,40,.16), transparent 45%),
    repeating-linear-gradient(0deg, rgba(120,140,170,.18) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, rgba(120,140,170,.18) 0 1px, transparent 1px 24px),
    linear-gradient(90deg, transparent 30px, rgba(142,27,27,.55) 30px 31.5px, transparent 31.5px); }
#pulkaSvg { width: 100%; height: auto; display: block; max-height: 62vh; }
#pulkaSvg .ln { stroke: var(--ink); stroke-width: 1.3; fill: none; stroke-linecap: round; }
#pulkaSvg .hw { font-family: var(--hand); fill: var(--ink); }
#pulkaSvg .hw.red { fill: var(--red-ink); }
#pulkaSvg .lbl { font-family: var(--serif); font-size: 7.5px; fill: rgba(46,34,25,.55); letter-spacing: .04em; }
#pulkaSvg .strike { stroke: var(--ink); stroke-width: 1.1; }
#pulkaSvg .strike.red { stroke: var(--red-ink); }
#scoreTable { margin-top: 10px; font-size: 15px; }
#scoreTable h4 { font-family: var(--title); font-size: 20px; margin: 8px 0 4px; }
#scoreTable table { width: 100%; border-collapse: collapse; }
#scoreTable th, #scoreTable td { padding: 4px 4px; text-align: right; border-bottom: 1px solid rgba(46,34,25,.25); }
#scoreTable th:first-child, #scoreTable td:first-child { text-align: left; }
#scoreTable th { font-weight: 400; font-size: 13px; color: #5a4634; }
#scoreTable .last { font-size: 14px; color: #4b3a2b; line-height: 1.35; }
#scoreTable .last .hwl { font-family: var(--hand); font-size: 18px; }

/* ---------- справка ---------- */
#scrim { position: fixed; inset: 0; background: rgba(8,2,4,.55); z-index: 200; }
#scrim[hidden], #help[hidden], #modal[hidden], #panel[hidden] { display: none !important; }
#help { position: fixed; z-index: 210; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--paper); color: var(--ink); display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.6);
  background-image: repeating-linear-gradient(0deg, rgba(120,140,170,.16) 0 1px, transparent 1px 24px), repeating-linear-gradient(90deg, rgba(120,140,170,.16) 0 1px, transparent 1px 24px); }
.sheetHead { color: var(--ink); display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px 18px; font-family: var(--title); font-weight: 700; font-size: 22px; border-bottom: 1px solid rgba(46,34,25,.3); background: rgba(239,227,200,.9); }
.xbtn { width: 44px; height: 44px; border: 0; background: none; font-size: 30px; line-height: 1; color: var(--ink); }
.helpBody { overflow: auto; padding: 6px 16px 30px 30px; font-size: 15px; line-height: 1.45; }
.helpBody details { position: relative; border-bottom: 1px dotted rgba(46,34,25,.35); padding: 4px 0; }
.helpBody summary { font-family: var(--title); font-weight: 700; font-size: 19px; cursor: pointer; padding: 8px 0; list-style-position: outside; }
.helpBody details.cur::before { content: ''; position: absolute; left: -16px; top: 6px; bottom: 6px; width: 3px; background: var(--red-ink); border-radius: 2px; transform: rotate(.8deg); }
.helpBody details.cur summary { color: var(--red-ink); }
.helpBody p { margin: 4px 0 8px; }
.helpBody table { border-collapse: collapse; font-size: 14px; margin: 4px 0 8px; }
.helpBody td, .helpBody th { border: 1px solid rgba(46,34,25,.3); padding: 3px 7px; text-align: center; }
.helpBody .r { color: var(--red); }

#modal { position: fixed; inset: 0; z-index: 260; background: rgba(8,2,4,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.mcard { background: var(--paper); color: var(--ink); padding: 18px 18px 16px; border-radius: 3px; max-width: 380px; width: 100%; box-shadow: 0 14px 40px rgba(0,0,0,.7); outline: 1px solid rgba(142,27,27,.35); outline-offset: -6px; text-align: center; }
.mcard h3 { font-family: var(--title); font-size: 24px; margin: 0 0 6px; }
.mcard p { margin: 6px 0 10px; font-size: 15px; }
.mcard .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

/* ---------- узкие экраны: пуля шторкой ---------- */
@media (max-width: 1023px), (max-height: 599px) {
  #sheet { position: fixed; left: 0; right: 0; bottom: 0; height: 85%; max-width: none; padding: 0; z-index: 220; transform: translateY(102%); transition: transform .3s ease-out; background: var(--paper); box-shadow: 0 -10px 30px rgba(0,0,0,.6); border-radius: 10px 10px 0 0; overflow: hidden; }
  #sheet.open { transform: none; }
  #sheet .sheetHead { color: var(--ink); display: flex; }
  #sheet .paper { transform: none; box-shadow: none; border-radius: 0; }
  #pulkaSvg { max-height: 58vh; max-width: 420px; margin: 0 auto; }
  #scoreTable { max-width: 460px; margin: 10px auto 0; }
}
@media (min-width: 1024px) and (min-height: 600px) { #btnSheet { display: none; } }
@media (max-width: 720px) {
  .tb.wide { display: none; }
  .tb.narrow { display: inline-flex; }
  .brand { font-size: 23px; }
  .brand small { display: none; }
  #table { margin: 4px 4px max(4px, env(safe-area-inset-bottom)); border-radius: 18px; }
  .felt { inset: 6px; border-radius: 13px; }
  .plaque { min-width: 0; padding: 4px 8px; }
  .plaque .nm { font-size: 17px; }
  #remark { left: 8px; right: 8px; padding-left: 8px; }
  #remarkText { font-size: 15px; }
  .bubble { font-size: 20px; }
}
@media (max-width: 380px) { .brand .orn { display: none; } .tb { padding: 0 9px; } }

@media (prefers-reduced-motion: reduce) {
  .card, .card .inner, .card .lift, #sheet, .bubble { transition: none !important; }
  .glow, .bubble.think { animation: none !important; }
}
#pulkaSvg .wr { opacity: 0; animation: write 120ms ease-out forwards; }
@keyframes write { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #pulkaSvg .wr { animation: none; opacity: 1; } }

@media (min-width: 700px) {
  #pl1 .bubble { left: calc(100% + 10px); top: 8px; }
  #pl2 .bubble { right: calc(100% + 10px); left: auto; top: 8px; }
}
@media (max-height: 520px) { .cell { height: 30px; } .extra .cell { height: 40px; } #panel h3 { font-size: 20px; } #panel { padding: 8px 12px 10px; } }
@media (max-height: 520px) and (min-aspect-ratio: 4/3) {
  #sheet .paper { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
  #pulkaSvg { max-height: calc(85vh - 90px); }
  #scoreTable { margin-top: 0; }
}

/* ---------- стол по концепту: круглый ломберный стол сверху ---------- */
#table { background: #10251a url(img/table3_tall.webp) center 40% / cover no-repeat; border-radius: 14px; box-shadow: 0 18px 40px rgba(0,0,0,.75), 0 0 0 1px rgba(255,220,160,.10); }
@media (min-aspect-ratio: 1/1) { #table { background-image: url(img/table3_wide.webp); background-position: center 45%; } }
@media (min-width: 1024px) and (min-height: 600px) { #table { margin: 10px 14px 14px; } }
.felt { inset: 0; border-radius: 0; box-shadow: inset 0 0 80px rgba(0,0,0,.45); background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.25)); }

/* ---------- карты по концепту ---------- */
.card .face { background: linear-gradient(165deg, #fffdf6, #f8f1e1 70%, #efe4cc); border: 1px solid #cfc3a6; box-shadow: 0 2px 5px rgba(0,0,0,.45); }
.card.red .face { color: #b3261e; }
.idx { z-index: 2; }
.idx b { font-size: calc(var(--cw) * .27); }
.idx i { font-size: calc(var(--cw) * .23); margin-top: 1px; }
.idx.tl { left: calc(var(--cw) * .045); top: calc(var(--cw) * .05); }
.pips { position: absolute; inset: 0; }
.pips i { position: absolute; font-style: normal; font-size: calc(var(--cw) * .25); line-height: 1; transform: translate(-50%, -50%); }
.pips i.dn { transform: translate(-50%, -50%) rotate(180deg); }
.ace { position: absolute; left: 22%; right: 22%; top: 20%; bottom: 20%; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.ace::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1px solid currentColor; opacity: .35; box-shadow: inset 0 0 0 3px #fbf7ec, inset 0 0 0 4px currentColor; }
.ace span { font-size: calc(var(--cw) * .56); line-height: 1; }
.court { left: 21%; right: 21%; top: 7%; bottom: 7%; border: 0; outline: 0; border-radius: 2px; background: #fbf7ec var(--ca) center / 100% 100% no-repeat; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.card .back { background: #f6f1e6; border: 1px solid #cfc3a6; }
.card .back::before { inset: 3px; border: 1px solid #1f2d5c;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.55) 0 1.2px, transparent 1.6px) 0 0 / 8px 8px,
    repeating-linear-gradient(45deg, rgba(232,236,248,.55) 0 1px, transparent 1px 5.6px),
    repeating-linear-gradient(-45deg, rgba(232,236,248,.55) 0 1px, transparent 1px 5.6px),
    linear-gradient(#2e3f78, #22305f); }
.idx.tl { background: #fcf8ee; padding: 0 1px 2px; border-radius: 2px; box-shadow: 0 0 2px 1px #fcf8ee; }
.pips i { font-size: calc(var(--cw) * .22); }
.felt { background: radial-gradient(ellipse at 45% 42%, rgba(255,214,150,.12), rgba(255,214,150,0) 55%), radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.25)); }

/* компактная карточка торговли: рука игрока остаётся видна */
#panel { width: min(340px, calc(100% - 20px)); padding: 10px 12px 12px; }
#panel h3 { font-size: 21px; }
.cell { height: 34px; font-size: 15px; }
.grid .hd { line-height: 22px; }
.extra .cell { height: 40px; }
.hist { font-size: 17px; margin: 2px 0 6px; }
#table.short #panel { width: min(560px, calc(100% - 16px)); padding: 6px 10px 8px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); grid-template-areas: "grid head" "grid foot"; column-gap: 12px; align-content: start; }
#table.short #panel .phead { grid-area: head; align-self: end; }
#table.short #panel .pgrid { grid-area: grid; }
#table.short #panel .pfoot { grid-area: foot; }
#table.short #panel .extra { grid-template-columns: 1fr; gap: 4px; margin-top: 4px; }
#table.short #panel .lead { font-size: 14px; }
#table.short .cell { height: 27px; font-size: 14px; }
#table.short .grid .hd { line-height: 18px; font-size: 15px; }
#table.short .extra .cell { height: 34px; }
#table.short #panel h3 { font-size: 19px; }
#table.short #panel:not([hidden]) ~ #remark { visibility: hidden; }

/* компактные плашки: рука игрока не перекрывается */
#remark { left: 50%; right: auto; transform: translateX(-50%); width: min(620px, calc(100% - 16px)); min-height: 36px; padding: 3px 4px 3px 8px; gap: 6px; }
#chip { min-width: 34px; padding-right: 6px; }
#chip b { font-size: 15px; }
#chip .tally { font-size: 13px; }
#chip .word { font-size: 15px; }
#remarkText { font-size: 15px; line-height: 1.2; }
.qbtn { width: 32px; height: 32px; font-size: 18px; }
.plaque { min-width: 0; padding: 3px 8px 4px; }
.plaque .nm { font-size: 16px; }
.plaque .sub { font-size: 12px; min-height: 14px; }
.bubble { font-size: 18px; padding: 3px 10px 4px; }
#panel { width: min(310px, calc(100% - 24px)); padding: 8px 10px 10px; }
#panel h3 { font-size: 19px; }
#panel .lead { margin: 2px 0 4px; }
.cell { height: 30px; font-size: 14px; }
.grid .hd { line-height: 20px; font-size: 15px; }
.grid .lv { font-size: 16px; }
.extra { margin-top: 6px; }
.extra .cell { height: 38px; }
@media (pointer: coarse) { .qbtn { width: 40px; height: 40px; } }
/* phone: larger card indices; oval name plates */
#table.phone .idx b { font-size: calc(var(--cw) * .31); }
#table.phone .idx i { font-size: calc(var(--cw) * .26); }
.plaque { border-radius: 999px; padding: 5px 18px 6px; text-align: center; }
.plaque .nm, .plaque .sub { text-align: center; }
@media (max-width: 720px) { .plaque { padding: 4px 15px 5px; } }

/* ---------- колоды: a классика, b строгая, c модерн, d четыре цвета ---------- */
.court .cl, .pip1 { display: none; }
.pip1 { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); font-size: calc(var(--cw) * .62); line-height: 1; }
/* A: атласные портреты, красно-синяя сетка */
[data-deck="a"] .card .back::before { border: 1px solid #8a2a22;
  background:
    repeating-linear-gradient(60deg, rgba(251,247,236,.9) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-60deg, rgba(251,247,236,.9) 0 1px, transparent 1px 6px),
    linear-gradient(#b23a2e, #8f2a22); }
/* B: строгая */
[data-deck="b"] .court { background-image: none !important; left: 22%; right: 22%; top: 21%; bottom: 21%; border: 1px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px; box-shadow: none; background: transparent; display: flex; align-items: center; justify-content: center; }
[data-deck="b"] .court .cl { display: block; font-family: var(--serif); font-weight: 700; font-size: calc(var(--cw) * .5); line-height: 1; }
[data-deck="b"] .pips { display: none; }
[data-deck="b"] .pip1 { display: block; }
[data-deck="b"] .ace::before { display: none; }
[data-deck="b"] .ace span { font-size: calc(var(--cw) * .66); }
[data-deck="b"] .card .back::before { border: 1px solid #262a4a; background: url(img/backs/b.webp) center / cover; }
/* C: модерн */
[data-deck="c"] .card .face::after { content: ''; position: absolute; inset: calc(var(--cw) * .06) calc(var(--cw) * .06); border: 1px solid #b8913f; border-radius: 3px; box-shadow: inset 0 0 0 2px #fbf7ec, inset 0 0 0 3px rgba(184,145,63,.55); pointer-events: none; z-index: 1; }
[data-deck="c"] .card .face { background: linear-gradient(160deg, #fbf4e4, #f5ecd8 60%, #efe3c9); }
[data-deck="c"] .idx.tl { background: #f9f1e0; box-shadow: 0 0 2px 1px #f9f1e0; }
[data-deck="c"] .court { background-image: var(--cb); background-color: #f6eedc; box-shadow: 0 0 0 1px #b8913f, 0 0 0 2px #f6eedc, 0 0 0 3px rgba(184,145,63,.5); }
[data-deck="c"] .ace::before { display: none; }
[data-deck="c"] .ace span { font-size: calc(var(--cw) * .6); }
[data-deck="c"] .card .back::before { border: 1px solid #b8913f; background: url(img/backs/c.webp) center / cover; }
/* D: четыре цвета */
[data-deck="d"] .card .face { background: #fdfdfb; }
[data-deck="d"] .card.s0 .face { color: #1c1c22; }
[data-deck="d"] .card.s1 .face { color: #1f6b3a; }
[data-deck="d"] .card.s2 .face { color: #1d4fa3; }
[data-deck="d"] .card.s3 .face { color: #c0261e; }
[data-deck="d"] .court { background-image: none !important; background: currentColor; box-shadow: none; left: 24%; right: 24%; top: 22%; bottom: 22%; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
[data-deck="d"] .court .cl { display: block; color: #fdfdfb; font-family: var(--serif); font-weight: 700; font-size: calc(var(--cw) * .48); line-height: 1; }
[data-deck="d"] .ace::before { display: none; }
[data-deck="d"] .card .back::before { border: 0; background: url(img/backs/d.webp) center / cover; }

/* выбор колоды */
.mcard.wide { max-width: 560px; }
.decks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.deckOpt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 8px; border: 1.5px solid rgba(46,34,25,.3); border-radius: 4px; background: rgba(255,255,255,.25); color: var(--ink); }
.deckOpt.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); background: rgba(201,162,74,.18); }
.deckOpt:hover { background: rgba(201,162,74,.22); }
.deckOpt b { font-size: 16px; }
.deckOpt small { font-size: 13px; color: #5a4634; line-height: 1.2; }
.deckOpt .pv { --cw: 46px; --ch: 64.4px; display: flex; justify-content: center; height: 70px; margin-bottom: 4px; pointer-events: none; }
.deckOpt .pv .card { position: relative; flex: 0 0 auto; margin-left: -12px; transform: none; }
.deckOpt .pv .card:first-child { margin-left: 0; }
@media (max-width: 420px) { .deckOpt .pv { --cw: 38px; --ch: 53.2px; height: 58px; } .deckOpt .pv .card { margin-left: -10px; } }
.card .back::before { content: ''; }

/* компактнее торговля на телефоне: рука видна */
#table.phone #panel { width: min(300px, calc(100% - 28px)); }
#table.phone .cell { height: 28px; }
#table.phone .extra .cell { height: 36px; }

/* открытые карты на телефоне: реплика садится на плашку, а не на карты */
#table.phone .plaque.open .bubble { top: auto; bottom: -9px; left: 50%; right: auto; transform: translateX(-50%); font-size: 17px; padding: 2px 9px 3px; border-radius: 10px; }
#table.phone .plaque.open .bubble.show { transform: translateX(-50%); }
#table.phone .plaque.open .sub { visibility: visible; }

/* компактнее верх и плашки, ремарка внизу стола */
#topbar { min-height: 40px; padding: max(3px, env(safe-area-inset-top)) 8px 3px; }
.brand { font-size: 21px; }
.brand small { font-size: 15px; }
.brand .orn { font-size: 15px; }
.tb { min-height: 34px; padding: 0 10px; font-size: 14px; }
.tb.icon { width: 36px; font-size: 16px; }
.tb svg { width: 16px; height: 16px; }
.menu { top: 40px; }
@media (min-width: 1024px) and (min-height: 600px) { #table { margin: 6px 12px 10px; } }
.plaque { padding: 2px 13px 3px; }
.plaque .nm { font-size: 14px; line-height: 1.05; }
.plaque .sub { font-size: 11px; min-height: 12px; line-height: 1.1; }
.plaque .tally { font-size: 14px; min-height: 13px; line-height: 1; }
@media (max-width: 720px) { .plaque { padding: 2px 11px 3px; } .brand { font-size: 20px; } }
#remark { min-height: 34px; padding: 2px 4px 2px 8px; }
#chip { flex-direction: row; align-items: baseline; gap: 6px; }
#table.short #panel:not([hidden]) ~ #remark { visibility: visible; }
@media (pointer: coarse), (max-width: 720px) { .tb { font-size: 15px; min-height: 38px; } }
@media (max-width: 380px) { .tb { padding: 0 8px; } }
/* низкий экран: торговля в две колонки, на всю ширину */
#table.phone.short #panel { width: min(560px, calc(100% - 16px)); }
#table.phone.short .cell { height: 26px; }
#table.phone.short .extra .cell { height: 34px; }
#table.phone.short .cell { height: 23px; font-size: 13px; }
#table.phone.short .grid .hd { line-height: 16px; }
#table.phone.short #panel { padding: 4px 10px 6px; }

/* ---------- v3: карты по концепту пользователя, стол без канделябров ---------- */
#table { background-image: url(img/table3_tall.webp); background-position: center 42%; }
@media (min-aspect-ratio: 1/1) { #table { background-image: url(img/table3_wide.webp); background-position: center 50%; } }
[data-deck="c"] .card .face { background: #fbf6ea url(img/cardframe.webp) center / 100% 100% no-repeat; border: 1px solid #d8d0bc; }
[data-deck="c"] .card .face::after { display: none; }
[data-deck="c"] .idx.tl, [data-deck="c"] .idx.br { background: #fbf6ea; box-shadow: 0 0 3px 2px #fbf6ea; border-radius: 3px; padding: 0 1px 2px; }
[data-deck="c"] .court { left: 15%; right: 15%; top: 7.5%; bottom: 7.5%; background: transparent var(--cb) center / 100% 100% no-repeat; box-shadow: none; }
[data-deck="c"] .pips i { font-size: calc(var(--cw) * .24); }
.idx b.t { letter-spacing: -.09em; display: inline-block; transform: scaleX(.82); margin: 0 -.12em 0 -.1em; }
