:root {
  --bg: #0b0c16;
  --bg-2: #120f24;
  --surface: #161629;
  --surface-2: #1f1e37;
  --surface-3: #2a2847;
  --line: #2e2c4d;
  --text: #f1effb;
  --muted: #8f8cb0;
  --accent: #7c6bff;
  --accent-2: #b35cff;
  --pink: #ff38aa;
  --cyan: #00e5ff;
  --ok: #2ee59d;
  --warn: #ffb938;
  --bad: #ff4f6d;
  --gold: #ffd23f;
  --felt: #17603f;
  --felt-2: #0e4029;
  --radius: 16px;
  --gutter: 14px;
  --vh: var(--tg-viewport-stable-height, 100dvh);
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  /* fullscreen Mini App: the status bar and the strip with Telegram's close/menu pill */
  --safe-top: var(--tg-safe-area-inset-top, 0px);
  --strip-top: var(--tg-content-safe-area-inset-top, 0px);
  --top-inset: calc(var(--safe-top) + var(--strip-top));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); height: 100%; overflow: hidden; }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(124, 107, 255, .16), transparent 60%),
    radial-gradient(80% 50% at 100% 110%, rgba(255, 56, 170, .10), transparent 60%),
    var(--bg);
}
button { font: inherit; color: inherit; }
input, textarea { font: inherit; user-select: text; -webkit-user-select: text; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#app { display: flex; flex-direction: column; height: var(--vh); max-width: 640px; margin: 0 auto; }
body.fullscreen #app { padding-top: var(--safe-top); }
/* the "sheet handle" strip in fullscreen: drag it down (or tap) to leave fullscreen and swipe the app away */
.grip { display: none; height: var(--strip-top); flex-shrink: 0; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
body.fullscreen .grip { display: flex; }
.grip i { display: block; width: 44px; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .28); box-shadow: 0 0 10px rgba(0, 229, 255, .25); transition: transform .15s, background .15s; }
.grip:active i, .grip.pull i { background: var(--cyan); transform: scaleX(1.15); }

@keyframes float { 50% { transform: translateY(-5px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glowPulse { 50% { box-shadow: 0 0 0 4px rgba(255, 56, 170, .18), 0 0 26px rgba(255, 56, 170, .25); } }
.float { animation: float 3.2s ease-in-out infinite; display: inline-block; }

/* view transitions between screens */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
::view-transition-old(root) { animation-name: vtOut; }
::view-transition-new(root) { animation-name: vtIn; }
::view-transition-group(game-hero) { animation-duration: .35s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
@keyframes vtOut { to { opacity: 0; transform: scale(.985); } }
@keyframes vtIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- splash ---------- */
.splash { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); }
.splash .pixel-logo svg { filter: drop-shadow(0 0 18px rgba(255, 56, 170, .45)); }
.splash-logo { font: 900 28px "Courier New", monospace; color: #fff; text-shadow: 3px 3px 0 var(--pink); }
.splash-bar { width: 160px; height: 8px; border: 2px solid var(--cyan); padding: 1px; }
.splash-bar i { display: block; height: 100%; width: 30%; background: repeating-linear-gradient(90deg, var(--pink) 0 6px, transparent 6px 8px); animation: load 1.1s steps(8) infinite; }
@keyframes load { from { margin-left: 0; } to { margin-left: 70%; } }
.splash-text { font: 700 12px "Courier New", monospace; letter-spacing: .3em; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }
.pixel-logo { display: inline-flex; line-height: 0; }
.pixel-logo svg { height: 28px; width: auto; image-rendering: pixelated; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 10px var(--gutter);
  border-bottom: 1px solid var(--line); background: rgba(11, 12, 22, .85); backdrop-filter: blur(10px);
  flex-shrink: 0;
}
.topbar .who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; cursor: pointer; }
.topbar .who .name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line);
  padding: 6px 12px 6px 8px; border-radius: 999px; font-weight: 800; white-space: nowrap; transition: color .3s, border-color .3s, box-shadow .3s;
}
.balance.big { font-size: 18px; padding: 8px 16px 8px 10px; }
.balance.up { color: var(--ok); border-color: var(--ok); box-shadow: 0 0 14px rgba(46, 229, 157, .35); }
.balance.down { color: var(--bad); border-color: var(--bad); }
.coin {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 50% 50%, #fff6c2 0 18%, var(--gold) 19% 48%, #e09a00 49% 60%, var(--gold) 61%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25), 0 0 0 1px #b87400;
}
.coin.sm { width: 14px; height: 14px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface-2); position: relative;
  width: 36px; height: 36px; border-radius: 12px; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.icon-btn:active { transform: scale(.92); }
.qbadge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--pink); color: #fff; font-size: 11px; font-weight: 900; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.qbadge.static { position: static; box-shadow: none; }
.netbar { background: var(--warn); color: #221a00; text-align: center; font-size: 13px; padding: 4px; font-weight: 700; }

/* ---------- screen ---------- */
.screen { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; position: relative; min-height: 0; }
.screen.game-mode, .screen.fixed-mode { overflow: hidden; display: flex; flex-direction: column; }
.game-root { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; touch-action: none; overscroll-behavior: none; }
.pad { padding: var(--gutter); }
h1, h2, h3 { margin: 0; }
.h1 { font-size: 22px; font-weight: 900; letter-spacing: -.01em; }
.h2 { font-size: 17px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.section { margin-top: 18px; }
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 14px 0 8px; font-weight: 800;
}
.section-title .muted { text-transform: none; letter-spacing: 0; font-weight: 600; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tip { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(124, 107, 255, .08); border: 1px dashed rgba(124, 107, 255, .35); color: #c9c4f2; font-size: 13px; }
.skeleton { height: 62px; border-radius: 14px; margin-bottom: 8px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 40%, var(--surface) 80%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton.tall { height: 150px; }
.form-error { color: var(--bad); font-size: 13px; min-height: 16px; }

/* ---------- tab bar ---------- */
.tabbar {
  display: flex; border-top: 1px solid var(--line); background: rgba(11, 12, 22, .92); backdrop-filter: blur(10px);
  padding: 4px 4px calc(4px + var(--safe-bottom)); flex-shrink: 0;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0 5px; border: 0; background: none; color: var(--muted); font-size: 10.5px; font-weight: 700; cursor: pointer;
  border-radius: 12px; position: relative; transition: color .2s;
}
.tab .ico { font-size: 21px; line-height: 1; transition: transform .2s; filter: grayscale(.6); }
.tab.active { color: var(--text); }
.tab.active .ico { transform: translateY(-2px) scale(1.12); filter: none; }
.tab.active::after {
  content: ""; position: absolute; bottom: 0; left: 30%; right: 30%; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--pink), var(--cyan)); box-shadow: 0 0 10px var(--pink);
}
.tab .dot {
  position: absolute; top: 1px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--pink); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 900; line-height: 17px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-weight: 800; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35); transition: transform .08s ease, box-shadow .08s ease, opacity .15s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--pink), var(--accent-2) 55%, var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 3px 0 #5b1f8f, 0 6px 18px rgba(255, 56, 170, .25); }
.btn.primary:active { box-shadow: 0 1px 0 #5b1f8f; }
.btn.ok { background: linear-gradient(135deg, #3cf0aa, #1fc184); border-color: transparent; color: #04241a; box-shadow: 0 3px 0 #0f7a52; }
.btn.danger { background: transparent; border-color: rgba(255, 79, 109, .5); color: var(--bad); box-shadow: none; }
.btn.gold { background: var(--gold); border-color: transparent; color: #2a1d00; box-shadow: 0 3px 0 #a67c00; }
.btn.pink { background: var(--pink); border-color: transparent; color: #fff; box-shadow: 0 3px 0 #99195f; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.block { width: 100%; }
.btn.big { padding: 15px 18px; font-size: 16px; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 11px; box-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }

/* ---------- lists ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: linear-gradient(180deg, var(--surface), rgba(22, 22, 41, .8)); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
  transition: transform .1s, border-color .2s;
}
.item:active { transform: scale(.985); }
.item .title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.item.glow-item { border-color: rgba(46, 229, 157, .5); box-shadow: 0 0 0 3px rgba(46, 229, 157, .08); }
.item.online-item { border-color: rgba(46, 229, 157, .25); }
.item.unread { border-color: rgba(255, 56, 170, .45); }
.item.unread .sub { color: var(--text); }
.item .place, .item .value { font-weight: 900; }
.item .place { width: 26px; text-align: center; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty.small { padding: 16px 8px; font-size: 14px; }
.empty .big { font-size: 42px; margin-bottom: 6px; }
.room-seats { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; }

/* names: guild tag + anonymous mark */
.pname { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; vertical-align: middle; }
.pname-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gtag {
  display: inline-block; padding: 1px 5px; border-radius: 5px; font: 800 10px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .06em; color: var(--cyan); background: rgba(0, 229, 255, .12); border: 1px solid rgba(0, 229, 255, .35);
  margin-left: 6px; flex-shrink: 0;
}
.pname .gtag { margin-left: 0; }
.gtag.big { font-size: 12px; padding: 2px 7px; vertical-align: middle; }
.anon-mark { font-size: 13px; }

/* ---------- home ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 18px; margin-bottom: 12px; min-height: 132px;
  background: linear-gradient(180deg, #150c33 0%, #2c0f4f 70%, #3f0d52 100%); border: 2px solid var(--pink);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, .35) inset, 0 10px 30px rgba(255, 56, 170, .15);
}
.hero-grid {
  position: absolute; left: -20%; right: -20%; bottom: -30px; height: 90px; transform: perspective(160px) rotateX(55deg);
  background:
    repeating-linear-gradient(0deg, rgba(255, 56, 170, .6) 0 2px, transparent 2px 18px),
    repeating-linear-gradient(90deg, rgba(255, 56, 170, .5) 0 2px, transparent 2px 28px);
  animation: gridMove 2.4s linear infinite; opacity: .55;
}
@keyframes gridMove { to { background-position: 0 18px, 0 0; } }
.hero-body { position: relative; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.hero-hi { font-weight: 900; font-size: 18px; }
.hero-row { display: flex; gap: 8px; align-items: center; }
.hero-coins { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: 18px; background: rgba(0, 0, 0, .3); padding: 5px 12px 5px 8px; border-radius: 999px; }
.hero-guild { font-weight: 800; background: rgba(0, 229, 255, .15); border: 1px solid rgba(0, 229, 255, .4); color: var(--cyan); padding: 5px 10px; border-radius: 999px; cursor: pointer; }
.quick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.quick {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-weight: 800; font-size: 13px; cursor: pointer;
}
.quick span { font-size: 22px; }
.quick:active { transform: scale(.96); }
.banner { background: var(--surface-2); border: 1px solid var(--gold); border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.banner.glow { animation: glowPulse 2s infinite; border-color: var(--pink); cursor: pointer; }
.warn-banner { border-color: var(--warn); color: var(--warn); font-size: 13px; }

.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-card, .lobby-hero, .guild-card, .profile-card {
  --g1: #2c2352; --g2: #141029; --gl: rgba(124, 107, 255, .5);
  position: relative; overflow: hidden; isolation: isolate;
  background: linear-gradient(150deg, var(--g1), var(--g2));
  border: 1px solid rgba(255, 255, 255, .08); border-radius: 18px;
}
[data-game="poker"] { --g1: #147a4c; --g2: #07291a; --gl: rgba(46, 229, 157, .55); }
[data-game="durak"] { --g1: #8a1a45; --g2: #2a0916; --gl: rgba(255, 79, 109, .55); }
[data-game="blackjack"] { --g1: #6b4b05; --g2: #1f1500; --gl: rgba(255, 210, 63, .55); }
[data-game="chess"] { --g1: #3b2d7a; --g2: #120d2b; --gl: rgba(124, 107, 255, .6); }
[data-game="checkers"] { --g1: #7a4520; --g2: #26140a; --gl: rgba(255, 170, 90, .5); }
[data-game="battleship"] { --g1: #0f4c8a; --g2: #061a33; --gl: rgba(0, 229, 255, .55); }
[data-game="connect4"] { --g1: #2350d6; --g2: #0b1f5c; --gl: rgba(255, 210, 63, .5); }
[data-game="tictactoe"] { --g1: #0c6670; --g2: #052326; --gl: rgba(0, 229, 255, .5); }
.gc-scan { position: absolute; inset: 0; z-index: -1; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 4px); pointer-events: none; }
.game-card {
  padding: 14px 12px 12px; cursor: pointer; min-height: 138px; display: flex; flex-direction: column; gap: 3px;
  transition: transform .15s cubic-bezier(.2, .8, .2, 1), box-shadow .2s;
}
.game-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, var(--gl), transparent 70%); opacity: .6;
}
.game-card:active, .game-card.picked { transform: scale(.95); box-shadow: 0 0 0 2px var(--gl), 0 0 24px var(--gl); }
.game-card .emoji { font-size: 38px; line-height: 1.1; margin-bottom: 6px; animation: float 3.2s ease-in-out infinite; filter: drop-shadow(0 5px 0 rgba(0, 0, 0, .35)); width: fit-content; }
.game-card .gt { font-weight: 900; font-size: 16px; }
.game-card .gd { font-size: 12px; color: rgba(255, 255, 255, .62); }
.game-card .online { position: absolute; top: 10px; right: 10px; font-size: 11px; color: var(--ok); font-weight: 800; background: rgba(0, 0, 0, .35); padding: 2px 7px; border-radius: 999px; }

/* ---------- lobby ---------- */
.lobby-hero { display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 6px; }
.lobby-hero .back { position: absolute; top: 8px; left: 8px; }
.lobby-emoji { font-size: 52px; line-height: 1; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .35)); }
.lobby-desc { color: rgba(255, 255, 255, .7); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 800; font-size: 14px; cursor: pointer; transition: transform .1s;
}
.chip:active { transform: scale(.94); }
.chip.active { background: linear-gradient(135deg, var(--pink), var(--accent-2)); border-color: transparent; color: #fff; box-shadow: 0 0 14px rgba(255, 56, 170, .35); }
.chip:disabled { opacity: .35; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--surface-3); white-space: nowrap; }
.tag.ok { background: rgba(46, 229, 157, .15); color: var(--ok); }
.tag.warn { background: rgba(255, 185, 56, .15); color: var(--warn); }
.tag.bad { background: rgba(255, 79, 109, .15); color: var(--bad); }
.tag.gold { background: rgba(255, 210, 63, .15); color: var(--gold); }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); outline: none; font-weight: 600; resize: none;
}
.input.code { text-transform: uppercase; letter-spacing: .15em; font-weight: 900; }
.input:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 56, 170, .15); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--pink); flex-shrink: 0; }
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 3px; gap: 3px; border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: none; padding: 9px 4px; border-radius: 11px; font-weight: 800; color: var(--muted); cursor: pointer; font-size: 13px; transition: background .2s, color .2s; }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--pink), 0 0 12px rgba(255, 56, 170, .15); }

/* ---------- toasts / banners / modals ---------- */
.toasts { position: fixed; top: calc(10px + var(--top-inset)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 100; pointer-events: none; padding: 0 16px; }
.toast {
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: 14px; max-width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: toastIn .2s ease;
}
.toast.bad { border-color: rgba(255, 79, 109, .6); }
.toast.ok { border-color: rgba(46, 229, 157, .6); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
.banners { position: fixed; top: calc(8px + var(--top-inset)); left: 0; right: 0; z-index: 110; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 10px; pointer-events: none; }
.banner-pop {
  pointer-events: auto; width: 100%; max-width: 560px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #221541, #2c1450); border: 2px solid var(--pink);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, .45) inset, 0 12px 30px rgba(0, 0, 0, .55);
  border-radius: 16px; padding: 12px 12px 14px; touch-action: none;
}
.bp-main { display: flex; align-items: center; gap: 12px; }
.bp-title { font-weight: 900; }
.bp-text { font-size: 13px; color: #cfc9ef; margin-top: 2px; }
.bp-actions { display: flex; gap: 8px; margin-top: 10px; }
.bp-actions .btn { flex: 1; }
.bp-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--cyan); transform-origin: left; }
.modal-back { position: fixed; inset: 0; background: rgba(4, 4, 12, .65); backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal {
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border-top-left-radius: 22px; border-top-right-radius: 22px;
  border: 1px solid var(--line); border-bottom: 0; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  padding: 18px var(--gutter) calc(18px + var(--safe-bottom)); animation: slideUp .22s cubic-bezier(.2, .9, .3, 1);
}
.modal::before { content: ""; display: block; width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: -8px auto 12px; }
.modal .modal-title { font-size: 19px; font-weight: 900; margin-bottom: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } }
/* centred 8-BIT dialog (confirmations) */
.modal-back.center { align-items: center; padding: 0 22px calc(20px + var(--safe-bottom)); }
.modal.dialog {
  max-width: 400px; border-radius: 18px; padding: 16px 16px 14px; border: 2px solid var(--pink); border-bottom: 2px solid var(--pink);
  background: linear-gradient(160deg, #221541, #120f2c); box-shadow: 0 0 0 2px rgba(0, 229, 255, .35) inset, 0 0 26px rgba(255, 56, 170, .35), 0 24px 60px rgba(0, 0, 0, .6);
  animation: dialogIn .22s cubic-bezier(.2, .9, .3, 1); image-rendering: pixelated;
}
.modal.dialog::before { display: none; }
@keyframes dialogIn { from { transform: scale(.9) translateY(10px); opacity: 0; } }
.dialog-logo { display: flex; justify-content: center; opacity: .9; }
.dialog-logo svg { height: 12px; width: auto; }
.dialog-text { text-align: center; font-weight: 800; font-size: 16px; padding: 2px 4px 6px; line-height: 1.35; }
.dialog-body .btn-row .btn { padding: 12px 10px; }

/* ---------- fx ---------- */
.fx-ghost { transition: none !important; }
.fx-drag { box-shadow: 0 14px 30px rgba(0, 0, 0, .55) !important; filter: brightness(1.05); }
.drag-src { opacity: .25; }
.drop-hover { outline: 3px dashed var(--gold); outline-offset: 3px; }
.fx-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 120; overflow: hidden; }
.fx-confetti i { position: absolute; top: 0; display: block; border-radius: 1px; }
.fx-float { position: fixed; z-index: 90; pointer-events: none; font-weight: 900; font-size: 18px; color: var(--gold); text-shadow: 0 2px 6px rgba(0, 0, 0, .7); white-space: nowrap; }
.fx-float.bad { color: var(--bad); }
.fx-float.ok { color: var(--ok); }

/* ---------- avatars ---------- */
.avatar {
  width: var(--s, 40px); height: var(--s, 40px); border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  font-weight: 900; color: #fff; font-size: calc(var(--s, 40px) * .42); position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.avatar .online-dot { position: absolute; right: 0; bottom: 0; width: 28%; height: 28%; background: var(--ok); border: 2px solid var(--bg); border-radius: 50%; z-index: 1; }
.guild-avatar { border-radius: 30%; background: linear-gradient(150deg, #3b2d7a, #1a1440); border: 1px solid rgba(0, 229, 255, .35); font-size: calc(var(--s, 40px) * .55); }

/* computer players: the ring colour tells the difficulty */
.avatar.bot { background: linear-gradient(150deg, #2a2847, #14122b); border: 2px solid var(--line); font-size: calc(var(--s, 40px) * .52); }
.avatar.bot.lvl-easy { border-color: var(--ok); }
.avatar.bot.lvl-medium { border-color: var(--warn); }
.avatar.bot.lvl-hard { border-color: #ff7a3d; }
.avatar.bot.lvl-nightmare { border-color: var(--pink); box-shadow: 0 0 12px rgba(255, 56, 170, .55); animation: glowPulse 2s infinite; }
.bot-tag { color: var(--muted); background: rgba(255, 255, 255, .06); border-color: var(--line); }
.bot-tag.lvl-easy { color: var(--ok); border-color: rgba(46, 229, 157, .45); background: rgba(46, 229, 157, .1); }
.bot-tag.lvl-medium { color: var(--warn); border-color: rgba(255, 185, 56, .45); background: rgba(255, 185, 56, .1); }
.bot-tag.lvl-hard { color: #ff7a3d; border-color: rgba(255, 122, 61, .45); background: rgba(255, 122, 61, .1); }
.bot-tag.lvl-nightmare { color: var(--pink); border-color: rgba(255, 56, 170, .5); background: rgba(255, 56, 170, .12); }
.seg.levels button.active.lvl-easy { box-shadow: inset 0 -2px 0 var(--ok); color: var(--ok); }
.seg.levels button.active.lvl-medium { box-shadow: inset 0 -2px 0 var(--warn); color: var(--warn); }
.seg.levels button.active.lvl-hard { box-shadow: inset 0 -2px 0 #ff7a3d; color: #ff7a3d; }
.seg.levels button.active.lvl-nightmare { box-shadow: inset 0 -2px 0 var(--pink), 0 0 14px rgba(255, 56, 170, .35); color: var(--pink); }
.level-desc.lvl-nightmare { color: var(--pink); }
.bots-tip { margin-top: 0; }
.btn.danger-glow { background: linear-gradient(135deg, #ff2d78, #7c1fff); animation: glowPulse 1.6s infinite; }

/* ---------- profile ---------- */
.profile-card { padding: 20px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; background: linear-gradient(160deg, #2a1552, #120c2a); border: 2px solid rgba(255, 56, 170, .5); }
.avatar-edit { position: relative; cursor: pointer; border-radius: 50%; padding: 4px; background: conic-gradient(from 0deg, var(--pink), var(--cyan), var(--accent-2), var(--pink)); }
.avatar-edit .avatar { border: 3px solid var(--bg); }
.avatar-cam { position: absolute; right: 2px; bottom: 2px; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--bg); display: flex; align-items: center; justify-content: center; font-size: 15px; }
.avatar-edit.uploading::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 4px solid transparent; border-top-color: #fff; animation: spin .8s linear infinite; }
.editable { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; max-width: 100%; }
.editable .pen { font-size: 13px; opacity: .6; }
.editable.bio { color: var(--muted); font-size: 14px; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.guild-chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: rgba(0, 229, 255, .12); border: 1px solid rgba(0, 229, 255, .35); color: var(--cyan); font-weight: 800; font-size: 13px; cursor: pointer; }
.rank { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; max-width: 260px; }
.rank-title { font: 900 13px "Courier New", monospace; letter-spacing: .15em; color: var(--gold); text-shadow: 2px 2px 0 rgba(0, 0, 0, .5); }
.rank-bar { width: 100%; height: 8px; border-radius: 4px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--pink)); transition: width .8s ease; }
.rank-next { font-size: 11px; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 21px; font-weight: 900; }
.stat span { font-size: 12px; color: var(--muted); }
table.gstats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.gstats td, table.gstats th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: center; }
table.gstats th { color: var(--muted); font-weight: 700; font-size: 12px; }
table.gstats td:first-child, table.gstats th:first-child { text-align: left; }

/* ---------- top ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 8px; margin: 6px 0 14px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; text-align: center; min-width: 0; }
.pod-name { font-weight: 800; font-size: 13px; max-width: 100%; }
.pod-value { font-weight: 900; font-size: 13px; color: var(--gold); }
.pod-step { width: 100%; border-radius: 12px 12px 0 0; display: flex; justify-content: center; padding-top: 6px; font-size: 22px; background: linear-gradient(180deg, var(--surface-3), var(--surface)); border: 1px solid var(--line); border-bottom: 0; }
.pod-1 .pod-step { height: 74px; background: linear-gradient(180deg, rgba(255, 210, 63, .35), var(--surface)); border-color: rgba(255, 210, 63, .5); }
.pod-2 .pod-step { height: 54px; }
.pod-3 .pod-step { height: 40px; }
.pod-1 .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(255, 210, 63, .5); }

/* ---------- chats ---------- */
.chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 8px var(--gutter); border-bottom: 1px solid var(--line); background: rgba(11, 12, 22, .9); flex-shrink: 0; }
.chat-head .title { font-weight: 900; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px var(--gutter); display: flex; flex-direction: column; gap: 6px; }
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 86%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 7px 10px 5px; min-width: 60px; word-break: break-word; user-select: text; -webkit-user-select: text; }
.msg.mine .msg-bubble { background: linear-gradient(135deg, #7a2bb8, #b0288f); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.msg-author { display: block; font-size: 12px; color: var(--cyan); margin-bottom: 2px; cursor: pointer; }
.msg-text { white-space: pre-wrap; }
.msg-time { display: block; text-align: right; font-size: 10px; color: rgba(255, 255, 255, .5); margin-top: 2px; }
.msg.system { align-self: center; max-width: 92%; font-size: 12px; color: #c9c4f2; background: rgba(124, 107, 255, .12); border: 1px dashed rgba(124, 107, 255, .35); padding: 5px 10px; border-radius: 999px; text-align: center; }
.chat-bar { display: flex; gap: 8px; align-items: flex-end; padding: 8px var(--gutter) calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line); background: rgba(11, 12, 22, .95); flex-shrink: 0; }
.chat-input { min-height: 44px; max-height: 120px; }
.send-btn { width: 46px; height: 44px; padding: 0; flex-shrink: 0; font-size: 18px; }
.chat-blocked { padding: 14px var(--gutter) calc(14px + var(--safe-bottom)); text-align: center; color: var(--muted); border-top: 1px solid var(--line); font-size: 13px; }

/* room chat */
.chat-btn .qbadge { top: -6px; right: -6px; }
.rc-back { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .35); }
.rc-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; max-width: 640px; margin: 0 auto; max-height: 62vh;
  display: flex; flex-direction: column; background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; padding-bottom: var(--safe-bottom);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .5);
}
.rc-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.rc-list { flex: 1; min-height: 120px; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.rc-msg { display: flex; align-items: flex-end; gap: 6px; max-width: 88%; }
.rc-msg.mine { align-self: flex-end; }
.rc-bubble { background: var(--surface-3); border-radius: 14px; padding: 6px 10px; word-break: break-word; }
.rc-bubble b { display: block; font-size: 11px; color: var(--cyan); }
.rc-msg.mine .rc-bubble { background: linear-gradient(135deg, #7a2bb8, #b0288f); }
.rc-quick { display: flex; gap: 6px; overflow-x: auto; padding: 6px 14px; scrollbar-width: none; }
.rc-quick .chip { flex-shrink: 0; padding: 6px 10px; font-size: 13px; }
.rc-input { display: flex; gap: 8px; padding: 6px 14px 10px; }
.rc-input .btn { width: 48px; padding: 0; }
.speech {
  position: fixed; top: calc(58px + var(--top-inset)); left: 50%; transform: translateX(-50%); z-index: 72; max-width: 86%;
  background: #fff; color: #1a1030; padding: 8px 12px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); cursor: pointer;
}
.speech::after { content: ""; position: absolute; top: -6px; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top: 0; border-bottom-color: #fff; }

/* ---------- guilds ---------- */
.guild-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 4px; }
.gh-emblem {
  width: 76px; height: 76px; border-radius: 22px; display: flex; align-items: center; justify-content: center; font-size: 42px; flex-shrink: 0;
  background: linear-gradient(150deg, #3b2d7a, #16103a); border: 2px solid var(--cyan); box-shadow: 0 0 0 3px rgba(255, 56, 170, .35), 0 0 24px rgba(0, 229, 255, .25);
}
.perks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.perk { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.perk b { font-size: 24px; }
.perk span { font-weight: 800; font-size: 12px; }
.perk small { color: var(--muted); font-size: 11px; }
.guild-card { display: flex; align-items: center; gap: 14px; padding: 16px; background: linear-gradient(150deg, #2d1a5e, #120c2a); border: 2px solid rgba(0, 229, 255, .45); }
.guild-level { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; }
.lvl { font-weight: 900; color: var(--gold); white-space: nowrap; }
.xp-bar { flex: 1; height: 8px; border-radius: 4px; background: rgba(0, 0, 0, .4); overflow: hidden; }
.xp-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--accent-2)); }
.guild-desc { margin-top: 10px; color: #cfc9ef; font-size: 14px; }
.guild-actions { display: flex; gap: 8px; margin-top: 12px; }
.guild-actions .btn { flex: 1; }
.guild-actions .btn:nth-child(n+3) { flex: 0 0 52px; }
.quest { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.quest.done { border-color: rgba(46, 229, 157, .5); background: linear-gradient(150deg, rgba(46, 229, 157, .1), var(--surface)); }
.quest-icon { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.quest-title { font-weight: 800; font-size: 14px; }
.quest-bar { height: 10px; border-radius: 5px; background: rgba(0, 0, 0, .45); margin: 6px 0 4px; overflow: hidden; }
.quest-bar i { display: block; height: 100%; border-radius: 5px; background: repeating-linear-gradient(90deg, var(--pink) 0 8px, var(--accent-2) 8px 16px); transition: width 1s cubic-bezier(.2, .8, .2, 1); }
.quest.done .quest-bar i { background: var(--ok); }
.quest-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.quest-reward { display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 900; color: var(--gold); font-size: 13px; }
.rank-card { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px; border-radius: 16px; background: linear-gradient(150deg, rgba(255, 210, 63, .12), var(--surface)); border: 1px solid rgba(255, 210, 63, .35); }
.rank-place { font: 900 24px "Courier New", monospace; color: var(--gold); min-width: 48px; text-align: center; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-opt { aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; cursor: pointer; }
.emoji-opt.active { border-color: var(--pink); box-shadow: 0 0 0 2px var(--pink); background: var(--surface-3); }

/* ---------- room ---------- */
.room-head { display: flex; align-items: center; gap: 6px; padding: 8px var(--gutter); border-bottom: 1px solid var(--line); flex-shrink: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--g1, #2c2352) 35%, transparent), transparent 70%); }
.room-head .title { font-weight: 900; }
.room-head .icon-btn { width: 34px; height: 34px; }
.room-emoji { font-size: 24px; }
.code-chip { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .1em; font-weight: 900; background: var(--surface-2); border: 1px dashed var(--line); padding: 4px 6px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.waiting { gap: 12px; }
.radar { position: relative; width: 170px; height: 170px; margin: 6px auto 0; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--g1, #2c2352) 55%, transparent), transparent 70%); }
.radar-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--gl, rgba(124, 107, 255, .5)); animation: ring 2.4s ease-out infinite; }
.radar-ring.r2 { animation-delay: 1.2s; }
@keyframes ring { from { transform: scale(.35); opacity: 1; } to { transform: scale(1); opacity: 0; } }
.radar-sweep { position: absolute; inset: 12%; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 75%, var(--gl, rgba(124, 107, 255, .5)) 100%); animation: spin 2.2s linear infinite; }
.radar-emoji { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 56px; animation: float 3s ease-in-out infinite; }
.seat-list { display: flex; flex-direction: column; gap: 8px; }
.seat-empty { border-style: dashed; color: var(--muted); justify-content: center; min-height: 58px; }
.waiting-dots::after { content: ""; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.result-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(22, 22, 41, .97); border-top: 2px solid var(--pink); border-radius: 22px 22px 0 0;
  padding: 14px var(--gutter) calc(14px + var(--safe-bottom)); box-shadow: 0 -12px 30px rgba(0, 0, 0, .5);
}
.result-sheet.win { border-top-color: var(--ok); }
.result-sheet.lose { border-top-color: var(--bad); }
.result-logo { display: flex; justify-content: center; margin-bottom: 2px; }
.result-logo svg { height: 34px; filter: drop-shadow(0 0 12px currentColor); }
.result-title { font-size: 24px; font-weight: 900; text-align: center; }
.result-title.win { color: var(--ok); }
.result-title.lose { color: var(--bad); }
.result-money { text-align: center; font-weight: 900; font-size: 20px; min-height: 26px; }
.result-money.win { color: var(--ok); }
.result-money.lose { color: var(--bad); }

.player-strip { display: flex; align-items: center; gap: 10px; padding: 6px var(--gutter); flex-shrink: 0; }
.player-strip .name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-strip.turn .name::after { content: " • ход"; color: var(--ok); font-size: 12px; }
.clock { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 900; font-size: 17px; background: var(--surface-2); border: 1px solid var(--line); padding: 3px 10px; border-radius: 8px; min-width: 72px; text-align: center; }
.clock.running { background: var(--text); color: var(--bg); }
.clock.low { background: var(--bad); color: #fff; border-color: var(--bad); }
.hint { text-align: center; color: var(--muted); font-size: 14px; padding: 4px 0; min-height: 26px; }
/* one line, always: a wrapping hint would resize the table above it */
.durak-bottom .hint, .poker-bottom .hint, .bj-bottom .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; padding-right: 8px; }
.hint.act { color: var(--ok); font-weight: 800; }
.timer-bar { height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.timer-bar > i { display: block; height: 100%; background: var(--ok); transition: width .25s linear; }
.timer-bar.low > i { background: var(--bad); }

/* duel layout: strips + board that fits the remaining space */
.duel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 var(--gutter); container-type: size; }
.board-wrap > * { width: 100%; max-width: 100%; }
@supports (width: 1cqw) {
  .board-wrap > .fit { width: min(100cqw, 100cqh); }
  .board-wrap > .c4-wrap.fit { width: min(100cqw, calc((100cqh - 50px) * 7 / 6)); }
}
.duel-bottom { flex-shrink: 0; padding: 0 var(--gutter) calc(8px + var(--safe-bottom)); }
.history { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); white-space: nowrap; overflow-x: auto; padding: 4px 0; }

/* ---------- playing cards ---------- */
.card {
  --cw: 46px;
  width: var(--cw); height: calc(var(--cw) * 1.42); border-radius: calc(var(--cw) * .12);
  background: linear-gradient(160deg, #ffffff, #eef0f4); color: #1a1d24; position: relative; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35); font-weight: 800;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card .cr { position: absolute; top: 3%; left: 8%; font-size: calc(var(--cw) * .34); line-height: 1; text-align: center; }
.card .cr small { display: block; font-size: calc(var(--cw) * .28); }
.card .cs { position: absolute; right: 8%; bottom: 5%; font-size: calc(var(--cw) * .5); line-height: 1; }
.card.red { color: #d3263a; }

.card.sm { --cw: 34px; }
.card.xs { --cw: 22px; }
.card.lg { --cw: 60px; }
.card.sel { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0, 0, 0, .5); }
.card.playable { box-shadow: 0 0 0 2px rgba(46, 204, 143, .9), 0 2px 6px rgba(0, 0, 0, .35); }
.card.dim { filter: brightness(.6); }
.card.ghost { background: rgba(255, 255, 255, .06); box-shadow: none; border: 1px dashed rgba(255, 255, 255, .25); }
.card.caught { box-shadow: 0 0 0 3px var(--bad), 0 0 16px var(--bad); }
.card.suspect { box-shadow: 0 0 0 3px var(--pink); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(255, 207, 90, .35); } }

.hand { display: flex; justify-content: center; padding: 20px 6px 6px; flex-shrink: 0; }
.hand .card { --cw: var(--hand-cw, 52px); margin-left: var(--overlap, -14px); cursor: grab; touch-action: none; }
.hand .card:first-child { margin-left: 0; }
.fan { display: flex; }
.fan .card { margin-left: -16px; }
.fan .card:first-child { margin-left: 0; }

.felt {
  background: radial-gradient(ellipse at center, var(--felt), var(--felt-2));
  border-radius: 22px; border: 6px solid #3a2616; box-shadow: inset 0 0 30px rgba(0, 0, 0, .45);
  position: relative;
}

/* ---------- chess / checkers boards ---------- */
.board { display: grid; aspect-ratio: 1; border-radius: 8px; overflow: hidden; position: relative; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; min-width: 0; min-height: 0; }
.sq.light { background: #ecdab9; }
.sq.dark { background: #ae8a68; }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(255, 214, 64, .38); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(91, 140, 255, .55); }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 40, 40, .9), rgba(255, 40, 40, 0) 70%); }
.sq.move::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 30, 20, .35); z-index: 2; }
.sq.capture::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 4px solid rgba(20, 30, 20, .35); z-index: 2; }
.sq.drop-hover { outline: 3px solid var(--gold); outline-offset: -3px; }
.sq .coord { position: absolute; font-size: 9px; font-weight: 700; opacity: .7; pointer-events: none; }
.sq .coord.f { right: 2px; bottom: 1px; }
.sq .coord.r { left: 2px; top: 1px; }
.sq.light .coord { color: #ae8a68; }
.sq.dark .coord { color: #ecdab9; }
.piece {
  position: relative; z-index: 3; line-height: 1; font-size: calc(var(--sq, 42px) * .82);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", "DejaVu Sans", "Apple Symbols", serif;
  touch-action: none; cursor: grab;
}
.piece.w { color: #fff; text-shadow: 0 0 1px #000, 0 0 2px #000, 1px 1px 0 #333, -1px -1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333; }
.piece.b { color: #1d1d1d; text-shadow: 0 0 1px rgba(255, 255, 255, .6); }
.board.checkers .sq.light { background: #e8d3b0; }
.board.checkers .sq.dark { background: #6b4a33; }
.board.checkers .sq.path::before { content: ""; position: absolute; inset: 0; background: rgba(255, 214, 64, .3); }
.board.checkers .sq.step::after { content: ""; position: absolute; width: 34%; height: 34%; border-radius: 50%; background: rgba(46, 204, 143, .75); z-index: 4; }
.disc {
  width: 78%; height: 78%; border-radius: 50%; position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: center; font-size: calc(var(--sq, 42px) * .45);
  touch-action: none; cursor: grab;
}
.disc.w { background: radial-gradient(circle at 35% 30%, #fff, #d9d6cf 60%, #a9a499); box-shadow: 0 3px 0 #7d786e, 0 4px 6px rgba(0, 0, 0, .5); color: #b8860b; }
.disc.b { background: radial-gradient(circle at 35% 30%, #555, #2a2a2a 60%, #111); box-shadow: 0 3px 0 #000, 0 4px 6px rgba(0, 0, 0, .5); color: var(--gold); }
.sq.sel .disc { outline: 3px solid var(--accent); outline-offset: 2px; }
.sq.can .disc { box-shadow: 0 0 0 3px rgba(46, 204, 143, .8), 0 4px 6px rgba(0, 0, 0, .5); }

.ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; aspect-ratio: 1; }
.ttt .cell {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: calc(var(--sq, 100px) * .55); font-weight: 900; cursor: pointer;
}
.ttt .cell.X { color: var(--accent); text-shadow: 0 0 14px rgba(91, 140, 255, .6); }
.ttt .cell.O { color: var(--warn); text-shadow: 0 0 14px rgba(245, 183, 59, .6); }
.ttt .cell.win { background: rgba(46, 204, 143, .2); border-color: var(--ok); }

.c4-wrap { display: flex; flex-direction: column; gap: 4px; }
.c4 {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 8px;
  background: #1f4fd6; border-radius: 14px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25), 0 6px 20px rgba(0, 0, 0, .4);
}
.c4 .hole { aspect-ratio: 1; border-radius: 50%; background: var(--bg); cursor: pointer; box-shadow: inset 0 3px 4px rgba(0, 0, 0, .6); position: relative; }
.c4 .disc4 { position: absolute; inset: 0; border-radius: 50%; }
.c4 .disc4.p1 { background: radial-gradient(circle at 35% 35%, #ff7a7a, #e0243a); }
.c4 .disc4.p2 { background: radial-gradient(circle at 35% 35%, #ffe680, #f0b400); }
.c4 .hole.win .disc4 { box-shadow: 0 0 0 3px #fff, 0 0 12px #fff; }
.c4-arrows { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 0 8px; }
.c4-arrows button { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px; }

/* ---------- battleship ---------- */
.sea { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; background: #0b2447; padding: 3px; border-radius: 10px; aspect-ratio: 1; position: relative; }
.sea .cell { background: #19376d; border-radius: 3px; position: relative; display: flex; align-items: center; justify-content: center; font-size: 12px; min-width: 0; }
.sea.target .cell { cursor: crosshair; }
.sea .cell.ship { background: #7b8fa6; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25); }
.sea .cell.ship.sel { background: var(--gold); }
.sea .cell.miss::after { content: ""; width: 26%; height: 26%; border-radius: 50%; background: #a5c9ff; opacity: .7; }
.sea .cell.hit { background: #ff8a3d; }
.sea .cell.hit::after { content: "✕"; color: #fff; font-weight: 900; }
.sea .cell.sunk { background: #d7263d; }
.sea .cell.sunk::after { content: "✕"; color: #fff; font-weight: 900; }
.sea .cell.last { outline: 2px solid var(--gold); outline-offset: -2px; }
.sea .cell.preview-ok { background: rgba(46, 204, 143, .75); }
.sea .cell.preview-bad { background: rgba(255, 90, 106, .75); }
.sea.disabled { opacity: .75; }
.bs-row { display: flex; gap: 10px; align-items: center; padding-top: 6px; }
.bs-row .sea { width: 40%; flex-shrink: 0; }
.bs-row .bs-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bs-row .player-strip { padding: 0; gap: 8px; }
.bs-row .clock { font-size: 15px; min-width: 60px; padding: 2px 6px; }
.bs-row .hint { text-align: left; min-height: 44px; } /* two lines reserved: no jumps when the text wraps */
.fx-splash, .fx-boom { position: absolute; inset: -40%; border-radius: 50%; pointer-events: none; z-index: 5; }
.fx-splash { border: 3px solid #a5c9ff; animation: ripple .6s ease-out forwards; }
.fx-boom { background: radial-gradient(circle, #fff3a0 0, #ff8a3d 35%, rgba(255, 60, 0, 0) 70%); animation: boom .6s ease-out forwards; }
@keyframes ripple { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
@keyframes boom { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* ---------- poker ---------- */
.poker { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.poker-table { flex: 1; min-height: 190px; margin: 26px var(--gutter) 6px; border-radius: 140px; }
.poker-center { position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.poker-board { display: flex; gap: 4px; }
.pot { background: rgba(0, 0, 0, .35); padding: 3px 10px; border-radius: 999px; font-weight: 800; font-size: 13px; color: var(--gold); }
.p-seat {
  position: absolute; transform: translate(-50%, -50%); width: 88px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 2;
}
.p-seat .box { background: rgba(10, 14, 20, .88); border: 1px solid var(--line); border-radius: 10px; padding: 3px 6px; text-align: center; width: 100%; }
.p-seat.turn .box { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(46, 204, 143, .35); }
.p-seat.folded { opacity: .45; }
.p-seat .nm { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-seat .ch { font-size: 11px; color: var(--gold); font-weight: 700; }
.p-seat .act { font-size: 10px; color: var(--muted); min-height: 12px; }
.p-seat .cards { display: flex; gap: 2px; min-height: 32px; }
.p-seat .bet { font-size: 11px; font-weight: 800; color: #2a1d00; background: var(--gold); border-radius: 999px; padding: 1px 7px; }
.p-seat .won { font-size: 11px; font-weight: 800; color: var(--ok); }
.p-seat .hn { font-size: 10px; color: var(--gold); font-weight: 700; }
.dealer-btn { position: absolute; top: -6px; right: -2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; color: #111; font-size: 10px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.poker-bottom { flex-shrink: 0; padding: 0 var(--gutter) calc(8px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 6px; position: relative; }
.poker-actions { min-height: 46px; }
.poker-bottom .status, .bj-bottom .status { min-height: 36px; } /* with or without the small button */
.poker-actions.idle { align-items: center; justify-content: center; }
.raise-panel {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: calc(100% - 4px); z-index: 5;
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .5); animation: slideUp .18s cubic-bezier(.2, .9, .3, 1);
}
.my-hand { display: flex; justify-content: center; gap: 6px; min-height: 60px; align-items: flex-end; }
.raise-row { display: flex; gap: 6px; }
.raise-row .chip { flex: 1; text-align: center; padding: 6px 4px; font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.chip-token { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle, #fff 0 25%, var(--gold) 26% 60%, #b8860b 61%); box-shadow: 0 2px 4px rgba(0, 0, 0, .5); }

/* ---------- blackjack ---------- */
.bj { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bj-table { flex: 1; min-height: 0; padding: 12px 10px 14px; margin: 8px var(--gutter); border-radius: 22px 22px 120px 120px; display: flex; flex-direction: column; }
.bj-dealer { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bj-shoe { position: absolute; right: 14px; top: 12px; }
.bj-seats { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 10px; margin-top: 12px; }
.bj-seat { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 90px; }
.bj-seat .nm { font-size: 12px; font-weight: 700; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bj-seat.me .nm { color: var(--gold); }
.bj-hand { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px; border-radius: 10px; }
.bj-hand.active { background: rgba(46, 204, 143, .18); box-shadow: 0 0 0 2px rgba(46, 204, 143, .6); }
.bj-hand .fan .card { margin-left: -20px; }
.bj-hand .fan .card:first-child { margin-left: 0; }
.val { background: rgba(0, 0, 0, .45); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 800; padding: 1px 8px; }
.res { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; }
.res.win, .res.blackjack { background: var(--ok); color: #04241a; }
.res.lose, .res.bust { background: var(--bad); color: #fff; }
.res.push { background: var(--surface-3); }
.bet-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #2a1d00; font-size: 11px; font-weight: 900; }
.bj-bottom { flex-shrink: 0; padding: 0 var(--gutter) calc(8px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 6px; min-height: 168px; justify-content: flex-end; } /* fixed height: the table stays put between phases */

/* ---------- durak ---------- */
.durak { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.durak-opps { display: flex; justify-content: space-around; gap: 6px; padding: 6px var(--gutter) 2px; flex-wrap: wrap; flex-shrink: 0; }
.opp { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; position: relative; }
.opp .nm { font-size: 12px; font-weight: 700; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .role { font-size: 11px; font-weight: 700; min-height: 14px; }
.opp.out { opacity: .5; }
.opp.active-turn .avatar { box-shadow: 0 0 0 3px var(--ok); }
.opp .fan .card { margin-left: -15px; }
.durak-table { flex: 1; min-height: 150px; margin: 4px var(--gutter); display: flex; flex-direction: column; transition: box-shadow .15s; }
.durak-table.drop-hover { outline: none; box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 30px rgba(0, 0, 0, .45); }
.durak-deck { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 60px; height: 70px; }
.durak-deck .trump { position: absolute; left: 12px; top: 6px; transform: rotate(90deg); }
.durak-deck .stack { position: absolute; left: 0; top: 10px; }
.durak-deck .cnt { position: absolute; left: 0; bottom: -18px; width: 44px; text-align: center; font-size: 12px; font-weight: 800; }
.trump-suit { position: absolute; top: 8px; right: 12px; font-size: 22px; background: rgba(0, 0, 0, .3); border-radius: 10px; padding: 0 8px; }
.discard { position: absolute; bottom: 8px; right: 12px; font-size: 11px; color: rgba(255, 255, 255, .7); min-width: 30px; min-height: 20px; }
.pairs { flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 12px 10px; padding-left: 62px; min-height: 0; }
.pair { position: relative; width: 50px; height: 88px; border-radius: 8px; }
.pair .card { position: absolute; top: 0; left: 0; }
.pair .card.def { top: 22px; left: 8px; }
.pair.target .card:first-child { box-shadow: 0 0 0 3px var(--gold); animation: pulse 1s infinite; }
.pair.drop-hover .card:first-child { box-shadow: 0 0 0 4px var(--ok); }
.durak-bottom { flex-shrink: 0; padding-bottom: calc(4px + var(--safe-bottom)); }
.durak-actions { display: flex; gap: 8px; padding: 0 var(--gutter); min-height: 40px; }
.durak-actions .btn { flex: 1; padding: 9px 10px; }
.felt-hint { position: absolute; left: 8%; right: 8%; top: calc(50% + 20px); font-size: 12.5px; color: rgba(255,255,255,.72); text-align: center; } /* right under the centered 8-BIT engraving */
.catch-bar { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 6; }


/* ---------- 8-BIT branding: engravings, card backs, watermarks ---------- */
.card.back {
  background:
    var(--logo-back) center / 70% auto no-repeat,
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .1) 0 3px, transparent 3px 7px),
    linear-gradient(160deg, #5a2bd6, #2d1a8a);
  border: 2px solid #f4f5f8;
  image-rendering: pixelated;
}
.card.back.xs { background-size: 82% auto, auto, auto; }
.felt { isolation: isolate; }
.felt::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; image-rendering: pixelated;
  background: var(--logo-engrave) 50% 50% / 30% auto no-repeat;
}
/* every engraving sits exactly in the middle of its table */
.durak-table::before { background-size: 32% auto; }
.poker-table::before { background-size: 22% auto; }
.bj-table::before { background-size: 24% auto; }
.board::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; image-rendering: pixelated;
  background: var(--logo-dark) center / 44% auto no-repeat; opacity: .12;
}
.sea::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; image-rendering: pixelated;
  background: var(--logo-watermark) center / 48% auto no-repeat; opacity: .07;
}
.ttt { position: relative; }
.ttt::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; image-rendering: pixelated;
  background: var(--logo-watermark) center / 58% auto no-repeat; opacity: .05;
}
.c4-brand {
  height: 18px; margin: -6px 0 0; border-radius: 0 0 14px 14px; image-rendering: pixelated;
  background: var(--logo-engrave-blue) center / auto 62% no-repeat, #1f4fd6;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25), 0 6px 14px rgba(0, 0, 0, .35);
}
.chip-token::after { content: "8"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 900 9px "Courier New", monospace; color: #7a5200; }
.chip-token { position: relative; }

@media (max-height: 700px) {
  .card { --cw: 40px; }
  .card.lg { --cw: 50px; }
  .pair { width: 44px; height: 78px; }
  .pair .card.def { top: 18px; left: 6px; }
  .player-strip { padding: 4px var(--gutter); }
  .hand { padding-top: 16px; }
  .radar { width: 130px; height: 130px; }
}
@media (max-width: 360px) {
  :root { --gutter: 10px; }
  .p-seat { width: 78px; }
  .perks { grid-template-columns: 1fr; }
  .tab { font-size: 9.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
