/* Токены платформы (--bg, --surface, --ink, --accent и др.) приходят из shared/theme.css; общий вид стартового экрана — из shared/start.css.
   Здесь стол «Дурака»: зелёное сукно, колода с козырем, пары карт на столе, веер карт соперников и рука игрока; окна и экраны онлайна (как у «Шашек»). */
:root {
  --felt: oklch(0.52 0.09 155); --feltEdge: oklch(0.4 0.08 155); --feltInk: oklch(0.97 0.02 150);
  --cardBg: oklch(0.99 0.004 90); --cardEdge: oklch(0.82 0.01 90); --cardInk: oklch(0.22 0.02 260); --cardRed: oklch(0.55 0.21 25);
  --backA: oklch(0.5 0.15 25); --backB: oklch(0.42 0.13 25); --ok: oklch(0.72 0.17 145); --trumpGlow: oklch(0.8 0.15 85);
  --scrim: oklch(0.2 0.02 260 / .45); --focus: oklch(0.55 0.18 260); --danger: oklch(0.55 0.2 27); --warn: oklch(0.62 0.17 55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --felt: oklch(0.38 0.07 155); --feltEdge: oklch(0.3 0.06 155); --cardBg: oklch(0.93 0.006 90); --focus: oklch(0.78 0.14 260); }
}
:root[data-theme="dark"] { --felt: oklch(0.38 0.07 155); --feltEdge: oklch(0.3 0.06 155); --cardBg: oklch(0.93 0.006 90); --focus: oklch(0.78 0.14 260); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
button { font-family: inherit; transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .15s ease, opacity .2s ease; }
button:not(:disabled):active { transform: scale(.97); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.noscript { margin: 0; padding: 12px 16px; background: var(--accent-soft); color: var(--ink); text-align: center; }
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.page { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 24px; width: 100%; max-width: 560px; margin: 0 auto; }
.muted { color: var(--muted); }

/* Кнопки */
.btn { min-height: 46px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1.15; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { background: var(--line); color: var(--muted); border-color: var(--line); cursor: not-allowed; }
.btn.full { width: 100%; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; }

/* Окна */
.scrim { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 20px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.modal h2 { margin: 0; font-size: 20px; }
.modal p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.4; }
.modal ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; }
.modal.over { text-align: center; }
.modal.over.win h2 { color: var(--accent); }
.modal.over.lose h2 { color: var(--ink-r); }


/* Онлайн: вход, список столов, комната ожидания (вид как у «Ятзи») */
@keyframes pop-in { from { transform: scale(.82); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.name-input { padding: 8px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-size: 17px; min-height: 48px; font-family: inherit; }
.mode-btn.o-mode { width: 100%; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; min-width: 0; }
.name-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.o-page { display: flex; flex-direction: column; gap: 14px; max-width: 560px; width: 100%; margin: 0 auto; padding: 12px 16px 24px; }
.o-box { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.o-box h3 { margin: 0; font-size: 16px; }
.o-center { text-align: center; align-items: center; }
.o-p { margin: 0; font-size: 16px; }
.o-err { color: var(--danger, #c0392b); font-weight: 700; font-size: 14px; margin: 0; }
.o-hint { font-size: 14px; color: var(--muted); text-align: center; }
.o-dashed { border: 2px dashed var(--line); border-radius: 20px; padding: 16px; text-align: center; color: var(--muted); font-size: 15px; }
.o-msg { border-radius: 20px; padding: 16px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.o-msg.bad { border: 1.5px solid var(--danger, #c0392b); }
.o-msg span { color: var(--muted); font-size: 14px; }
.o-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.o-row .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.o-row .who small { color: var(--muted); font-size: 14px; }
.o-row.skel .av, .o-row.skel .ln { background: var(--line); display: block; }
.o-row.skel .ln { height: 12px; width: 50%; border-radius: 6px; flex: 1; max-width: 50%; }
.av { width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: var(--accent-soft); color: var(--ink); }
.o-you { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px 0 6px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 700; white-space: nowrap; }
.o-you .av { width: 32px; height: 32px; }
.o-code-row { display: flex; gap: 8px; }
.o-code { flex: 1; min-width: 0; text-align: center; font-size: 24px; letter-spacing: .3em; text-transform: uppercase; }
.o-mode b { display: block; }
.o-mode small { display: block; margin-top: 2px; color: var(--muted); font-weight: 400; font-size: 14px; }
.o-bigcode { font-size: 46px; font-weight: 700; letter-spacing: 10px; padding-left: 10px; }
.o-mode-tag { font-size: 14px; color: var(--muted); }
.o-seats { display: flex; flex-direction: column; gap: 8px; }
.o-seat { display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-height: 56px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.o-seat.empty { background: transparent; border: 2px dashed var(--line); color: var(--muted); animation: none; }
.o-seat .nm { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-seat .tg { font-size: 14px; color: var(--muted); }
.o-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; font-size: 15px; font-weight: 700; background: var(--accent-soft); border: 1.5px solid var(--accent); }
.o-banner.bad { border-color: var(--danger, #c0392b); }
.o-banner span { flex: 1; min-width: 0; }
.o-ask { display: flex; align-items: baseline; gap: 10px; }
.o-ask b { font-size: 56px; line-height: 1; }
.o-ask span { color: var(--muted); }
.modal .reward { color: var(--ink); font-weight: 700; font-size: 16px; }

.modal .reward { color: var(--ink); font-weight: 700; font-size: 16px; }
.modal .reward.lost { color: var(--danger); }
.modal.over.draw h2 { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Варианты — в одну строку: короткие кнопки */
.modes.seg { flex-direction: row; }
.modes.seg .mode-btn { flex: 1 1 0; min-width: 0; text-align: center; padding-left: 6px; padding-right: 6px; }
.modes.duo { flex-direction: row; }
.modes.duo .mode-btn { flex: 1 1 0; min-width: 0; }
.o-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.o-seg button { flex: 1 1 0; min-height: 40px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer; }
.o-seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.o-field { display: flex; flex-direction: column; gap: 6px; }

/* Логотип: веер из трёх карт */
.logo-dk { display: flex; align-items: flex-end; height: 56px; }
.logo-dk .pcard { --w: 34px; margin-right: -14px; }
.logo-dk .pcard:nth-child(1) { transform: rotate(-12deg) translateY(4px); }
.logo-dk .pcard:nth-child(3) { transform: rotate(12deg) translateY(4px); }

/* Карта: размер задаёт --w, высота 1.4 ширины */
.pcard {
  --w: 54px; position: relative; display: inline-flex; width: var(--w); height: calc(var(--w) * 1.4); flex: none; border-radius: calc(var(--w) * .12);
  background: var(--cardBg); border: 1px solid var(--cardEdge); color: var(--cardInk); box-shadow: 0 1px 2px oklch(0.2 0.02 260 / .25);
  user-select: none; -webkit-user-select: none;
}
.pcard.red { color: var(--cardRed); }
.pcard b { position: absolute; left: calc(var(--w) * .08); top: calc(var(--w) * .05); display: flex; flex-direction: column; align-items: center; font-size: calc(var(--w) * .32); line-height: 1; font-weight: 800; }
.pcard b i { font-style: normal; font-size: calc(var(--w) * .28); }
.pcard em { position: absolute; right: calc(var(--w) * .08); bottom: calc(var(--w) * .04); font-style: normal; font-size: calc(var(--w) * .6); line-height: 1; opacity: .9; }
.pcard.back { background: repeating-linear-gradient(45deg, var(--backA) 0 6px, var(--backB) 6px 12px); border: 3px solid var(--cardBg); }
.pcard.fresh { animation: drop .3s ease-out; }
@keyframes drop { from { transform: translateY(-14px) scale(1.06); opacity: .3; } }

/* Экран партии */
.game { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 16px; width: 100%; max-width: 620px; margin: 0 auto; flex: 1; }
.o-head .theme-btn { flex: none; }
.o-head h2 small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
/* Стол как в покере: овальное сукно, соперники по кругу, карты захода в центре, колода с козырем слева внизу, отбой справа внизу */
.area { position: relative; width: 100%; height: clamp(330px, 47vh, 470px); margin: 4px auto 0; }
.oval { position: absolute; inset: 10% 1% 2% 1%; border-radius: 999px; background: radial-gradient(ellipse at 50% 42%, var(--felt), var(--feltEdge)); border: 5px solid oklch(0.35 0.05 60); box-shadow: inset 0 0 0 2px oklch(0.7 0.08 85 / .5), inset 0 8px 20px oklch(0.15 0.04 160 / .3); }
.area .table { position: absolute; left: 20%; right: 20%; top: 27%; bottom: 20%; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-content: center; color: var(--feltInk); z-index: 1; }
.area.n1 .table, .area.n2 .table { top: 24%; }
.deck { position: absolute; left: 9%; bottom: 7%; width: 64px; height: 70px; display: flex; align-items: center; justify-content: center; color: var(--feltInk); z-index: 1; }
.deck .trumpcard { --w: 40px; transform: rotate(90deg) translateY(-10px); box-shadow: 0 0 0 2px var(--trumpGlow); }
.deck .top { --w: 40px; position: absolute; left: 2px; top: 4px; }
.deck .dn { position: absolute; left: 4px; bottom: -6px; font-size: 12px; font-weight: 800; background: oklch(0.2 0.02 260 / .6); padding: 1px 6px; border-radius: 8px; }
/* Масть козыря — всегда видна значком у колоды (и когда колода кончилась) */
.deck .ts { position: absolute; right: -4px; bottom: -8px; width: 26px; height: 26px; border-radius: 50%; background: var(--cardBg); color: var(--cardInk); display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 0 0 2px var(--trumpGlow); }
.deck .ts.red { color: var(--cardRed); }
.bito { position: absolute; right: 9%; bottom: 7%; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--feltInk); z-index: 1; }
.bito .pile { --w: 30px; transform: rotate(-8deg); opacity: .85; }
.table.taking { outline: 2px dashed oklch(0.9 0.12 60 / .8); outline-offset: 4px; border-radius: 12px; }
.table .empty { font-size: 13px; opacity: .75; }
.table .flash { font-size: 15px; font-weight: 800; text-align: center; padding: 0 6px; animation: drop .3s ease-out; }

/* Места игроков */
.seat { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 2; width: 92px; }
.seat.out { opacity: .55; }
.seat.gone .av { filter: grayscale(1); }
.seat .ring, .me .ring { position: relative; padding: 3px; border-radius: 50%; }
.seat.turn .ring, .me.turn .ring { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.av { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: var(--ink); border: 1px solid var(--line); }
.seat .cnt { position: absolute; right: -16px; bottom: -4px; display: flex; align-items: center; }
.seat .cnt .mini { --w: 20px; border-width: 2px; }
.seat .cnt b { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: white; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px oklch(0.2 0.02 260); }
.seat .nick { font-size: 12px; font-weight: 700; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; line-height: 1.3; }
.tag.defend { background: var(--warn); color: white; }
.tag.attack, .tag.throw { background: var(--accent); color: var(--accent-ink); }
.tag.fool { background: var(--danger); color: white; }
.tag.out { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.tag.none { visibility: hidden; }
.pair { position: relative; width: 58px; height: 92px; padding: 0; border: 0; background: none; }
.pair .pcard { --w: 50px; position: absolute; left: 0; top: 0; }
.pair .pcard.d { left: 8px; top: 20px; transform: rotate(8deg); }
button.pair { cursor: pointer; }
button.pair .pcard.a { box-shadow: 0 0 0 3px var(--ok); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--ok); } }

.me { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; margin-top: -6px; }
.me .av { width: 36px; height: 36px; font-size: 15px; }
.me.turn .nm { color: var(--accent); }
.note { min-height: 20px; font-size: 14px; color: var(--muted); text-align: center; line-height: 1.35; }

/* Рука: карты внахлёст, сколько бы их ни было — в одну линию по ширине экрана */
.hand { --cw: clamp(46px, 13vw, 64px); display: flex; justify-content: center; padding: 14px 4px 4px; min-height: 104px; }
/* Места мало — кнопки карт сжимаются, а сами карты сохраняют ширину и ложатся внахлёст; последняя видна целиком */
.hc { position: relative; padding: 0; border: 0; background: none; cursor: pointer; flex: 0 1 calc(var(--cw) + 4px); min-width: 14px; height: calc(var(--cw) * 1.4); transition: transform .15s ease; }
.hc:last-child { flex: 0 0 var(--cw); }
.hc .pcard { --w: var(--cw); position: absolute; left: 0; top: 0; }
.hc .pcard.ok { box-shadow: 0 0 0 2px var(--ok), 0 2px 4px oklch(0.2 0.02 260 / .25); }
.hc .pcard.no { filter: saturate(.6) brightness(.92); }
.hc .pcard.tr::after { content: ''; position: absolute; inset: 3px; border-radius: inherit; box-shadow: inset 0 0 0 1.5px var(--trumpGlow); pointer-events: none; }
.hc:has(.ok):hover, .hc:has(.sel) { transform: translateY(-12px); z-index: 2; }
.hc .pcard.sel { box-shadow: 0 0 0 3px var(--focus); }
.actions { display: flex; gap: 10px; min-height: 46px; }
.actions .btn { flex: 1; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: white; }
@media (max-width: 380px) { .pair { width: 46px; height: 74px; } .pair .pcard { --w: 40px; } .seat { width: 80px; } .av { width: 38px; height: 38px; font-size: 16px; } }
@media (min-width: 700px) { .hand { --cw: 76px; padding-top: 18px; } .pair { width: 72px; height: 110px; } .pair .pcard { --w: 62px; } .deck .trumpcard, .deck .top { --w: 52px; } .av { width: 52px; height: 52px; } }

