:root {
  --bg: #11131c;
  --surface: #1a1d2a;
  --surface-2: #232738;
  --border: #2f3448;
  --text: #e8e9f0;
  --muted: #9aa0b8;
  --accent: #ff7a1a;
  --accent-2: #ffb26b;
  --good: #46c37b;
  --bad: #ef5b5b;
  --light-sq: #ecdcbf;
  --dark-sq: #a77c58;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent-2); }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
img, svg { max-width: 100%; }
.container { width: min(1180px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header / footer ---------- */
.site-header { background: rgba(17, 19, 28, 0.9); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.site-header .container { display: flex; align-items: center; gap: 24px; height: 60px; }
.logo { font-weight: 800; font-size: 1.25rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 0; white-space: pre; }
.logo span { color: var(--accent); }
.main-nav { display: flex; gap: 18px; flex: 1; }
.main-nav a, .user-nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.main-nav a:hover, .user-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text); }
.user-nav a.btn-primary, .user-nav a.btn-primary:hover { color: #1b0f05; }
.user-nav { display: flex; align-items: center; gap: 14px; }
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: 0.9rem; margin-top: 48px; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.site-footer a { color: var(--muted); }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #2c3146; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1b0f05; }
.btn-primary:hover { background: var(--accent-2); color: #1b0f05; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-sm { padding: 6px 12px; font-size: 0.9rem; }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }
.form input, select {
  font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.form input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-error { color: var(--bad); min-height: 1.4em; margin: 0; }
.auth-box { max-width: 420px; margin: 56px auto; }

/* ---------- Landing ---------- */
.hero { padding: 72px 0 48px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin: 0 0 16px; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.variant-card { display: flex; flex-direction: column; gap: 10px; }
.variant-card h3 { margin: 0; font-size: 1.35rem; }
.variant-card .icon { font-size: 2.4rem; line-height: 1; }
.mode-icon { display: block; width: 64px; height: 64px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35)); transition: transform 0.2s; }
.variant-card:hover .mode-icon { transform: rotate(-5deg) scale(1.06); }
.title-with-icon { display: flex; align-items: center; gap: 16px; }
.title-with-icon .mode-icon { width: 72px; height: 72px; }
.meta-icon { width: 22px; height: 22px; vertical-align: -6px; margin-right: 6px; }
.variant-card .actions { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.section { padding: 40px 0; }
.section h2 { font-size: 1.8rem; margin-top: 0; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 700; }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--accent-2); }

/* Article pages (variant rules) */
.article h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.article h2 { margin-top: 2em; }
.article li { margin-bottom: 6px; }
.breadcrumbs { font-size: 0.9rem; color: var(--muted); margin-top: 24px; }
.breadcrumbs a { color: var(--muted); }
.callout { border-left: 4px solid var(--accent); background: var(--surface); padding: 14px 18px; border-radius: 0 8px 8px 0; }

/* ---------- Play (lobby) ---------- */
.play-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; margin-top: 32px; }
@media (max-width: 860px) { .play-layout { grid-template-columns: 1fr; } }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice {
  border: 2px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 12px;
  text-align: left; color: var(--text); font: inherit; cursor: pointer;
}
.choice strong { display: block; }
.choice small { color: var(--muted); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: #2b2520; }
.tc-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.tc-grid .choice { padding: 8px 14px; }
.stat-line { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 0.95rem; }
.stat-line b { color: var(--text); }
.seeking { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 8px; background: #2b2520; border: 1px solid var(--accent); }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Board ---------- */
.board {
  position: relative; width: 100%; aspect-ratio: var(--files, 8) / 8; display: grid;
  grid-template-columns: repeat(var(--files, 8), 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 4px; overflow: hidden; box-shadow: var(--shadow); user-select: none; touch-action: none;
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background: var(--light-sq); }
.sq.dark { background: var(--dark-sq); }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(255, 196, 0, 0.38); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(70, 160, 255, 0.45); }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 0, 0, 0.85) 0%, rgba(255, 0, 0, 0.3) 55%, transparent 75%); }
/* Legal move markers: dots on empty squares, corner rings on captures */
.sq.dest::after {
  content: ""; position: absolute; width: 32%; height: 32%; border-radius: 50%; z-index: 4; pointer-events: none;
  background: rgba(24, 28, 40, 0.42); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.sq.dest.occupied::after {
  width: 100%; height: 100%; border-radius: 0; box-shadow: none;
  background: radial-gradient(transparent 62%, rgba(24, 28, 40, 0.5) 64%);
}
.sq.movable { cursor: grab; }
.sq.dest { cursor: pointer; }
/* Target square under the mouse / dragged piece */
.sq.dest.hover { box-shadow: inset 0 0 0 100vmax rgba(255, 196, 61, 0.55), inset 0 0 0 4px rgba(255, 255, 255, 0.85); }
.sq.dest.hover::after { opacity: 0; }

/* Atomic capture preview: blast radius + pieces that will be destroyed */
.sq.blast { box-shadow: inset 0 0 0 100vmax rgba(255, 120, 30, 0.28); }
.sq.blast::after { opacity: 0; }
.sq.doomed { box-shadow: inset 0 0 0 100vmax rgba(255, 45, 20, 0.42); }
.sq.dest.hover.doomed { box-shadow: inset 0 0 0 100vmax rgba(255, 45, 20, 0.5), inset 0 0 0 4px rgba(255, 230, 200, 0.95); }
.sq.doomed .piece {
  filter: drop-shadow(0 0 4px #ff3b1f) drop-shadow(0 0 8px #ff7a1a);
  animation: doomed 0.12s linear infinite alternate;
}
@keyframes doomed { from { transform: translate(-1px, 0) rotate(-3deg); } to { transform: translate(1px, -1px) rotate(3deg); } }
.preview-label {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 9; pointer-events: none;
  background: rgba(25, 12, 6, 0.9); color: #ffd2a6; border: 1px solid #ff7a1a;
  padding: 4px 12px; border-radius: 99px; font-weight: 800; font-size: 0.85rem; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); animation: pop 0.2s ease;
}
.preview-label.bottom { top: auto; bottom: 8px; }
.preview-label.win { background: rgba(10, 40, 20, 0.92); color: #b9ffcf; border-color: var(--good); }

/* Explosion effect */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 8; overflow: hidden; }
.fx-explosion { position: absolute; width: 0; height: 0; }
.fx-explosion > div { position: absolute; left: 0; top: 0; border-radius: 50%; transform: translate(-50%, -50%); }
.fx-flash {
  width: calc(var(--sq) * 3.3); height: calc(var(--sq) * 3.3);
  background: radial-gradient(circle, #fff 0%, #fff6b0 16%, #ffc23a 34%, #ff6a1a 54%, rgba(255, 60, 0, 0) 72%);
  animation: fx-flash 0.55s ease-out forwards;
}
.fx-ring {
  width: calc(var(--sq) * 3); height: calc(var(--sq) * 3);
  border: calc(var(--sq) * 0.09) solid rgba(255, 214, 150, 0.95);
  animation: fx-ring 0.6s ease-out forwards;
}
.fx-spark {
  width: calc(var(--sq) * 0.13); height: calc(var(--sq) * 0.13);
  background: var(--c); box-shadow: 0 0 8px 2px var(--c);
  animation: fx-spark var(--d) cubic-bezier(0.1, 0.75, 0.3, 1) forwards;
}
.fx-smoke {
  width: calc(var(--sq) * 1.7); height: calc(var(--sq) * 1.7);
  background: radial-gradient(circle, rgba(60, 55, 55, 0.7), rgba(60, 55, 55, 0) 70%);
  opacity: 0; animation: fx-smoke 1.1s ease-out 0.12s forwards;
}
.fx-scorch {
  width: calc(var(--sq) * 2.6); height: calc(var(--sq) * 2.6);
  background: radial-gradient(circle, rgba(30, 15, 5, 0.55), rgba(30, 15, 5, 0) 65%);
  animation: fx-scorch 1.25s ease-out forwards;
}
.fx-debris {
  position: absolute; width: calc(var(--sq) * 0.85); height: calc(var(--sq) * 0.85);
  transform: translate(-50%, -50%); z-index: 2;
  animation: fx-debris 0.8s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
.board.shake { animation: shake 0.42s ease; }
@keyframes fx-flash { 0% { transform: translate(-50%, -50%) scale(0.15); opacity: 1; } 55% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }
@keyframes fx-ring { 0% { transform: translate(-50%, -50%) scale(0.1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.35); opacity: 0; } }
@keyframes fx-spark { 0% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2); opacity: 0; } }
@keyframes fx-smoke {
  0% { transform: translate(calc(-50% + var(--ox)), calc(-50% + var(--oy))) scale(0.4); opacity: 0.9; }
  100% { transform: translate(calc(-50% + var(--ox) * 2.2), calc(-50% + var(--oy) * 2.2 - var(--sq) * 0.7)) scale(1.7); opacity: 0; }
}
@keyframes fx-scorch { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fx-debris {
  0% { transform: translate(-50%, -50%) rotate(0) scale(1); opacity: 1; filter: brightness(2.2) sepia(1) saturate(5) hue-rotate(-25deg); }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(0.45); opacity: 0; filter: brightness(0.4); }
}
@keyframes shake {
  10%, 90% { transform: translate(-1px, 1px); }
  20%, 80% { transform: translate(3px, -2px); }
  30%, 50%, 70% { transform: translate(-5px, 3px); }
  40%, 60% { transform: translate(5px, -3px); }
}
.coord { position: absolute; font-size: clamp(8px, 1.3vw, 12px); font-weight: 700; pointer-events: none; z-index: 1; }
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 4px; }
.sq.light .coord { color: var(--dark-sq); }
.sq.dark .coord { color: var(--light-sq); }

.piece {
  position: relative; z-index: 3; display: block;
  width: var(--piece-size, 40px); height: var(--piece-size, 40px);
  background: center / contain no-repeat;
  filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}
.sq .piece { width: 88%; height: 88%; }
.piece.ghost { position: fixed; z-index: 100; transform: translate(-50%, -50%) scale(1.12); pointer-events: none; filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.45)); }
.sq.dragging-from .piece { opacity: 0.3; }

.promo-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 10; display: flex; align-items: center; justify-content: center; }
.promo-box { display: flex; gap: 6px; background: var(--surface); padding: 10px; border-radius: 10px; box-shadow: var(--shadow); }
.promo-box button { width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--border); background: var(--light-sq); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.promo-box .piece { --piece-size: 46px; }

/* ---------- Game page ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 640px) minmax(280px, 1fr); gap: 24px; margin-top: 24px; align-items: start; }
.game-layout.bughouse { grid-template-columns: minmax(0, 560px) minmax(0, 400px) minmax(260px, 1fr); }
@media (max-width: 1100px) { .game-layout.bughouse { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .game-layout.bughouse .side { grid-column: 1 / -1; } }
@media (max-width: 860px) { .game-layout, .game-layout.bughouse { grid-template-columns: 1fr; } }
.board-wrap { display: grid; gap: 8px; }
.board-wrap.partner { opacity: 0.95; }
.board-title { font-size: 0.85rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.player-bar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-height: 48px; }
.player-bar .name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-bar .name a { color: var(--text); text-decoration: none; }
.player-bar .name { display: flex; align-items: center; gap: 6px; }
.player-bar .team-dot { width: 10px; height: 10px; border-radius: 50%; }
.clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.3rem; padding: 4px 10px; border-radius: 6px; background: var(--bg); min-width: 84px; text-align: center; }
.clock.running { background: var(--accent); color: #1b0f05; }
.clock.low.running { background: var(--bad); color: #fff; }
.pocket { display: flex; gap: 2px; flex-wrap: wrap; }
.pocket-item { position: relative; width: 36px; height: 36px; border-radius: 6px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; cursor: grab; border: 1px solid transparent; touch-action: none; }
.pocket-item.empty { opacity: 0.25; cursor: default; }
.pocket-item.sel { border-color: #46a0ff; }
.pocket-item .piece { --piece-size: 28px; }
.pocket-item .count { position: absolute; right: -3px; bottom: -3px; background: var(--accent); color: #1b0f05; font-size: 0.7rem; font-weight: 800; border-radius: 99px; padding: 0 5px; z-index: 4; }

.side { display: grid; gap: 14px; }
.status-box { font-weight: 700; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); }
.status-box.win { background: rgba(70, 195, 123, 0.18); color: var(--good); }
.status-box.loss { background: rgba(239, 91, 91, 0.18); color: var(--bad); }
.moves { max-height: 340px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px; font-variant-numeric: tabular-nums; }
.moves ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 38px 1fr 1fr; }
.moves li { display: contents; }
.moves .num { color: var(--muted); padding: 3px 6px; }
.moves .mv { padding: 3px 6px; border-radius: 4px; cursor: pointer; }
.moves .mv:hover { background: var(--surface-2); }
.moves .mv.cur { background: var(--accent); color: #1b0f05; font-weight: 700; }
.moves.bug ol { grid-template-columns: 38px 34px 1fr; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.nav-controls { display: flex; gap: 6px; }
.nav-controls .btn { flex: 1; }
.seat-list { display: grid; gap: 8px; }
.seat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.share { display: flex; gap: 8px; }
.share input { flex: 1; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }

/* ---------- Profile / history ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stats .card { padding: 16px; }
.stats .big { font-size: 1.6rem; font-weight: 800; }
table.history { width: 100%; border-collapse: collapse; }
table.history th, table.history td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
table.history th { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; }
.res-win { color: var(--good); font-weight: 700; }
.res-loss { color: var(--bad); font-weight: 700; }
.res-draw { color: var(--muted); font-weight: 700; }
@media (max-width: 640px) { table.history .opt { display: none; } }

/* ---------- Bots ---------- */
.bot-say { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.bot-avatar { font-size: 2rem; line-height: 1; }
/* Variant tabs */
.variant-tabs { display: flex; gap: 12px; margin: 24px 0 16px; flex-wrap: wrap; }
.vtab {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); color: var(--text); font: inherit; text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.vtab:hover { transform: translateY(-2px); border-color: #4a5170; }
.vtab[aria-selected="true"] { border-color: var(--accent); background: linear-gradient(135deg, #2e241c, var(--surface)); }
.vtab-icon { width: 44px; height: 44px; display: block; flex: none; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35)); transition: transform 0.2s; }
.vtab:hover .vtab-icon, .vtab[aria-selected="true"] .vtab-icon { transform: rotate(-6deg) scale(1.06); }
.vtab small { display: block; color: var(--muted); }

/* Match-up panel */
.matchup-card { position: relative; overflow: hidden; background: radial-gradient(ellipse at top, #262a3d, var(--surface) 70%); }
.matchup { display: flex; align-items: center; justify-content: center; gap: clamp(12px, 4vw, 40px); flex-wrap: wrap; }
.team { display: flex; gap: 12px; }
.vs { font-size: 2rem; font-weight: 900; color: var(--accent); text-shadow: 0 0 18px rgba(255, 122, 26, 0.6); font-style: italic; }
.slot {
  display: grid; justify-items: center; gap: 4px; width: 128px; padding: 12px 8px; border-radius: 14px;
  background: var(--surface-2); border: 2px solid var(--border); color: var(--text); font: inherit; cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.slot:hover { transform: translateY(-2px); }
.slot.you { cursor: default; opacity: 0.9; }
.slot.you:hover { transform: none; }
.slot.active { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.18); animation: pulse 1.6s ease-in-out infinite; }
.avatar { display: block; border-radius: 50%; flex: none; }
.slot-avatar { width: 76px; height: 76px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
.you-avatar { display: grid; place-items: center; border-radius: 50%; background: linear-gradient(160deg, #3a3f58, #1a1d2a); border: 2px solid #4a5170; font-weight: 800; color: var(--muted); }
.bar-avatar { display: inline-block; width: 26px; height: 26px; vertical-align: middle; margin-right: 6px; }
.bot-link { display: inline-flex; align-items: center; }
.say-avatar { width: 48px; height: 48px; }
.slot-name { font-weight: 800; font-size: 0.95rem; text-align: center; }
.slot-role { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.slot-hint { text-align: center; color: var(--muted); margin: 12px 0 0; min-height: 1em; font-size: 0.9rem; }
.bubble-row { display: flex; justify-content: center; margin-top: 14px; }
.bubble {
  position: relative; display: flex; gap: 10px; align-items: center; max-width: 560px;
  background: #f4efe4; color: #1b1b1f; padding: 10px 16px; border-radius: 16px; font-size: 0.95rem;
}
.bubble::before { content: ""; position: absolute; top: -8px; left: 50%; margin-left: -8px; border: 8px solid transparent; border-top: 0; border-bottom-color: #f4efe4; }
.bubble-avatar { width: 34px; height: 34px; }
.matchup-options { display: flex; gap: 14px; justify-content: center; align-items: end; flex-wrap: wrap; margin-top: 18px; }
.matchup-options .form { gap: 4px; }
.play-btn { min-width: 220px; }

/* Bot cards */
.bot-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.bot-card {
  position: relative; text-align: left; font: inherit; color: var(--text); cursor: pointer; display: grid; gap: 8px;
  align-content: start; border: 2px solid var(--border); scroll-margin-top: 80px;
  transition: transform 0.18s ease, border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.bot-card:hover { transform: translateY(-4px); border-color: #4a5170; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }
.bot-card:hover .bot-avatar { transform: rotate(-8deg) scale(1.1); }
.bot-card[aria-selected="true"] { border-color: #6b5a45; background: #221f22; }
.bot-card.for-active { border-color: var(--accent); background: linear-gradient(160deg, #33261b, var(--surface) 60%); box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.25), 0 10px 30px rgba(255, 122, 26, 0.15); }
.bot-card.picked { animation: picked 0.45s ease; }
.bot-card.picked .bot-avatar { animation: bounce 0.6s ease; }
.bot-card .bot-head { display: flex; align-items: center; gap: 12px; }
.bot-card .bot-avatar { width: 64px; height: 64px; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
.bot-card h3 { margin: 0; font-size: 1.15rem; }
.bot-card .bot-title { color: var(--accent-2); font-size: 0.85rem; font-weight: 600; }
.bot-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.bot-card .tag { justify-self: start; }
.role-badges { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.role-badge { font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--accent); color: #1b0f05; animation: pop 0.3s ease; }
.role-badge.role-partner { background: var(--good); }
.role-badge.role-other { background: #8a90ad; }
.strength { display: flex; gap: 3px; align-items: center; }
.strength i { width: 14px; height: 6px; border-radius: 3px; background: var(--surface-2); }
.strength i.on { background: var(--accent); }

.pop { animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
.fade-in > * { animation: fadeUp 0.35s ease both; }
.fade-in > *:nth-child(2) { animation-delay: 0.04s; }
.fade-in > *:nth-child(3) { animation-delay: 0.08s; }
.fade-in > *:nth-child(4) { animation-delay: 0.12s; }
.fade-in > *:nth-child(5) { animation-delay: 0.16s; }
@keyframes pop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes picked { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-10px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.18); } 50% { box-shadow: 0 0 0 8px rgba(255, 122, 26, 0.06); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 600px) { .slot { width: 100px; } .slot-avatar { width: 56px; height: 56px; } .team { gap: 6px; } }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border); padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 200; }

/* ======================================================================
   v10 — community, analysis, settings, i18n
   ====================================================================== */

/* Language blocks and early hiding while Czech texts are applied */
html[lang="cs"] .l-en, html:not([lang="cs"]) .l-cs { display: none !important; }
html.i18n-pending body { visibility: hidden; }

/* Board colour themes */
html[data-board="green"] { --light-sq: #eeeed2; --dark-sq: #769656; }
html[data-board="blue"] { --light-sq: #dee3e6; --dark-sq: #8ca2ad; }
html[data-board="gray"] { --light-sq: #e4e4e4; --dark-sq: #9a9a9a; }
html[data-board="purple"] { --light-sq: #e8dff5; --dark-sq: #9b7fbd; }
html[data-board="coral"] { --light-sq: #f6e3d6; --dark-sq: #cf8a73; }

/* Light theme */
html[data-theme="light"] {
  --bg: #f4f5f9; --surface: #ffffff; --surface-2: #eceef4; --border: #d7dae4;
  --text: #1b1d27; --muted: #5d6378; --accent: #e8680f; --accent-2: #c2560a;
  --shadow: 0 8px 24px rgba(30, 35, 60, 0.12);
  color-scheme: light;
}
html[data-theme="light"] .site-header { background: rgba(255, 255, 255, 0.92); }
html[data-theme="light"] .btn:hover { background: #e2e5ee; }
html[data-theme="light"] .btn-primary, html[data-theme="light"] .btn-primary:hover { color: #fff; }
html[data-theme="light"] .user-nav a.btn-primary, html[data-theme="light"] .user-nav a.btn-primary:hover { color: #fff; }
html[data-theme="light"] .choice[aria-pressed="true"],
html[data-theme="light"] .seeking,
html[data-theme="light"] .bot-card[aria-selected="true"] { background: #fff3e8; }
html[data-theme="light"] .bot-card.for-active { background: linear-gradient(160deg, #ffe9d6, #fff 60%); }
html[data-theme="light"] .vtab[aria-selected="true"] { background: linear-gradient(135deg, #ffe9d6, #fff); }
html[data-theme="light"] .matchup-card { background: radial-gradient(ellipse at top, #eef0f8, #fff 70%); }
html[data-theme="light"] .status-box.win { background: rgba(34, 160, 90, 0.12); color: #16784a; }
html[data-theme="light"] .status-box.loss { background: rgba(220, 60, 60, 0.12); color: #b42323; }
html[data-theme="light"] .res-win { color: #16784a; }
html[data-theme="light"] .res-loss { color: #b42323; }
html[data-theme="light"] .preview-label { background: rgba(255, 248, 240, 0.96); color: #7a2e05; }
html[data-theme="light"] .clock { background: #e7e9f0; }

/* Header tools & user area */
.header-tools { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700;
  font-size: 0.85rem; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { border-color: var(--accent); color: var(--text); }
.main-nav { overflow-x: auto; scrollbar-width: none; }
.main-nav a { white-space: nowrap; }
.me-link { display: inline-flex; align-items: center; gap: 8px; }
.nav-avatar { width: 30px; height: 30px; }
.friends-link { position: relative; }
.count-badge { display: inline-block; margin-left: 4px; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 0.72rem; text-align: center; }
.tag-warn { background: rgba(239, 91, 91, 0.2); color: var(--bad); margin-left: 6px; }
@media (max-width: 900px) {
  .site-header .container { flex-wrap: wrap; height: auto; padding: 8px 0; gap: 10px; }
  .main-nav { order: 3; width: 100%; }
}

/* Friend challenge pop-ups */
.challenge-stack { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 300; max-width: min(380px, calc(100vw - 32px)); }
.challenge-card {
  display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--accent);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); animation: pop 0.25s ease;
}
.challenge-card .avatar { width: 40px; height: 40px; }
.challenge-actions { display: flex; flex-direction: column; gap: 6px; margin-left: auto; }

/* Game page additions */
.notice { padding: 10px 14px; border-radius: 8px; background: rgba(255, 178, 107, 0.15); border: 1px solid var(--accent-2); }
.rating { margin-left: 8px; font-weight: 600; color: var(--muted); font-size: 0.9rem; }
.rating-diff { margin-left: 6px; font-weight: 800; font-size: 0.85rem; }
.rating-diff.up { color: var(--good); }
.rating-diff.down { color: var(--bad); }
.export-controls .btn { flex: 1 1 auto; }
.analysis-panel { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.eval-graph { width: 100%; height: 80px; cursor: pointer; border-radius: 6px; }
.eg-bg { fill: #2b2b31; }
.eg-mid { stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; }
.eg-fill { fill: #f1efe7; }
.eg-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.eg-cur { stroke: #46a0ff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.an-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; font-size: 0.9rem; }
.best-move { font-size: 0.92rem; }
.mark { margin-left: 2px; font-weight: 800; }
.mark-blunder { color: #ef4444; }
.mark-mistake { color: #f97316; }
.mark-inaccuracy { color: #eab308; }
.moves .mv.cur .mark { color: inherit; }

/* Premoves & arrows */
.sq.pre::before { content: ""; position: absolute; inset: 0; background: rgba(70, 120, 255, 0.42); }
.sq.premoving::after { background: rgba(60, 100, 230, 0.45) !important; }
.arrow-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }

/* Chat */
.chat-panel { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.chat-head { display: flex; justify-content: space-between; align-items: center; }
.chat-opt { display: inline-flex; gap: 4px; align-items: center; font-size: 0.85rem; cursor: pointer; }
.chat-log { max-height: 220px; min-height: 80px; overflow-y: auto; display: grid; align-content: start; gap: 4px; font-size: 0.92rem; overflow-wrap: anywhere; }
.chat-msg.team { color: var(--accent-2); }
.chat-form { display: flex; gap: 6px; align-items: center; }
.chat-form input { flex: 1; min-width: 0; font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.quick-bar { display: flex; flex-wrap: wrap; gap: 4px; }
.quick-bar .btn { font-size: 0.78rem; padding: 4px 8px; }

/* Play page */
.my-rating { margin: 6px 0 0; }
.user-avatar { border-radius: 50%; }

/* Leaderboard & watch */
.lb-table td.rank { font-weight: 800; width: 48px; }
.flag { margin-left: 6px; }
.tv-card { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: linear-gradient(135deg, var(--surface), var(--surface-2)); }
.live-list { display: grid; gap: 10px; }
.live-card { display: flex; gap: 14px; align-items: center; padding: 12px 16px; }
.live-card .mode-icon { width: 48px; height: 48px; }
.live-info { flex: 1; min-width: 0; }
.live-players { font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.vs-small { color: var(--accent); font-style: italic; }
.btn.disabled { opacity: 0.5; pointer-events: none; }

/* Friends */
.add-friend { display: flex; gap: 8px; }
.add-friend input { flex: 1; font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.friend-list { display: grid; gap: 8px; }
.friend-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.friend-status { flex: 1; }
.friend-actions { display: flex; gap: 6px; margin-left: auto; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #6b7280; margin-right: 6px; }
.status-dot.online { background: var(--good); }
.status-dot.playing { background: var(--accent); }
.challenge-form { width: 100%; display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding-top: 8px; border-top: 1px dashed var(--border); }
.challenge-form label { display: grid; gap: 4px; font-size: 0.85rem; font-weight: 600; }

/* Segmented buttons, toggles */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; padding: 8px 14px; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #1b0f05; font-weight: 700; }
.toggle { display: flex; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Settings */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 380px); gap: 24px; align-items: start; }
@media (max-width: 860px) { .settings-layout { grid-template-columns: 1fr; } }
.settings-list { display: grid; gap: 16px; }
.settings-list h2 { margin: 0 0 12px; font-size: 1.1rem; }
.settings-preview { position: sticky; top: 80px; }
.swatches, .piece-sets { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch, .piece-set {
  display: grid; justify-items: center; gap: 6px; padding: 8px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer;
}
.swatch[aria-pressed="true"], .piece-set[aria-pressed="true"] { border-color: var(--accent); }
.swatch-board { width: 56px; height: 56px; border-radius: 6px; }
.piece-row { display: flex; }
.piece-row .piece { --piece-size: 30px; filter: none; }

/* Analysis board / editor */
.editor-top { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 16px; }
.editor-top select { margin-left: 6px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 640px) minmax(280px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .editor-layout { grid-template-columns: 1fr; } }
.palette { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.palette-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; border: 2px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 1.2rem; }
.palette-btn.active { border-color: var(--accent); background: #2b2520; }
html[data-theme="light"] .palette-btn.active { background: #fff3e8; }
.palette-btn .piece { --piece-size: 34px; }
.editor-board .sq.dest::after { display: none; }
.castling { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; font-size: 0.9rem; }
.fen-label { display: grid; gap: 6px; font-weight: 700; }
.fen-label input { font: 0.85rem monospace; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.engine-card { padding: 12px 16px; }

/* Profile */
.profile-head { display: flex; gap: 20px; align-items: center; margin-top: 24px; flex-wrap: wrap; }
.profile-head h1 { margin: 0; }
.profile-head .btn { margin-left: auto; }
.avatar-lg { width: 96px; height: 96px; box-shadow: var(--shadow); }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 6px; max-width: 560px; }
.avatar-option { padding: 2px; border-radius: 50%; border: 3px solid transparent; background: none; cursor: pointer; }
.avatar-option[aria-pressed="true"] { border-color: var(--accent); }
.avatar-option img { display: block; border-radius: 50%; }
.edit-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; }
.rating-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.rating-card { padding: 14px; }
.rating-card-head { display: flex; gap: 8px; align-items: center; }
.rating-card .big { font-size: 1.8rem; font-weight: 800; }
.rating-graph { width: 100%; height: 50px; margin-top: 6px; }
.rg-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.rg-fill { fill: rgba(255, 122, 26, 0.12); }
.badge-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.badge { display: grid; gap: 2px; padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--accent); }
.badge.locked { border-color: var(--border); opacity: 0.45; filter: grayscale(1); }
.badge-icon { font-size: 1.8rem; }
.badge .muted { font-size: 0.82rem; }
.badge-date { font-size: 0.75rem; color: var(--accent-2); }

/* Home features */
.feature-card { display: grid; gap: 6px; color: var(--text); text-decoration: none; transition: transform 0.15s, border-color 0.15s; }
.feature-card:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--text); }
.feature-card h3 { margin: 0; }
.feature-icon { font-size: 2rem; }
.site-footer nav + nav { margin-top: 6px; }
.variant-card .tag { align-self: flex-start; }
.row-actions { white-space: nowrap; }

/* ---------- v11: launch features ---------- */
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; white-space: normal; }
td.row-actions { display: table-cell; white-space: nowrap; }
.small { font-size: 0.85rem; }
.card-title { font-size: 1.1rem; margin: 0 0 8px; }
.lead { font-size: 1.08rem; max-width: 760px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 14px; }
.inline-form input { flex: 1 1 180px; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.plain-list li { display: flex; gap: 10px; align-items: center; }
.danger-zone { border: 1px solid var(--bad); border-radius: 10px; padding: 12px; margin-top: 10px; }
.flag-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 0.9rem; padding: 0 4px; opacity: 0.6; }
.flag-btn:hover { color: var(--bad); opacity: 1; }
.report-dialog { max-width: 460px; width: calc(100% - 32px); color: var(--text); border: 1px solid var(--border); }
.report-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.report-dialog textarea, .report-dialog select { width: 100%; }
.turn-link { position: relative; font-size: 1.15rem; }
.shake { animation: cv-shake 0.35s; }
@keyframes cv-shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.site-footer p a { margin: 0 2px; }

/* correspondence list */
.corr-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.corr-card { display: flex; gap: 12px; align-items: center; color: var(--text); text-decoration: none; }
.corr-card .corr-state { margin-left: auto; text-align: right; }
.corr-card.my-turn { border-color: var(--accent); }

/* explorer */
.explorer-card { margin-top: 12px; }
.explorer-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.explorer-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px; }
.explorer-table td { padding: 5px 4px; border-top: 1px solid var(--border); }
.explorer-table tr[data-uci] { cursor: pointer; }
.explorer-table tr[data-uci]:hover td { background: var(--surface-2); }
.wdb { display: flex; height: 18px; border-radius: 4px; overflow: hidden; min-width: 120px; font-size: 0.72rem; font-weight: 700; line-height: 18px; }
.wdb span { text-align: center; overflow: hidden; }
.wdb .w { background: #eeeeee; color: #222; }
.wdb .d { background: #8a8f9f; color: #fff; }
.wdb .b { background: #2a2a2a; color: #eee; }

/* puzzles */
.pz-stats { display: flex; gap: 18px; justify-content: space-between; margin-bottom: 8px; }
.pz-stats b { font-size: 1.4rem; }
.puzzle-layout .side { display: grid; gap: 12px; align-content: start; }

/* learn */
.lessons { display: grid; gap: 20px; margin-top: 20px; }
.lesson { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 420px); gap: 20px; align-items: start; }
.lesson-text h2 { margin-top: 0; display: flex; gap: 10px; align-items: center; }
.lesson-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); font-size: 0.95rem; flex: none; }
.lesson-check { color: var(--good); visibility: hidden; }
.lesson.done .lesson-check { visibility: visible; }
.lesson.done .lesson-num { background: var(--good); color: #062; }
.lesson-pocket { margin: 10px 0; min-height: 38px; }
.learn-progress.complete { color: var(--good); font-weight: 700; }
@media (max-width: 760px) { .lesson { grid-template-columns: 1fr; } }

/* admin */
.adm-tab { margin-top: 18px; display: grid; gap: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.stat-tile { display: grid; gap: 4px; }
.stat-tile b { font-size: 1.6rem; }
.stat-tile.warn b { color: var(--bad); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { text-align: left; padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.report-card header { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.evidence { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 0.9rem; display: grid; gap: 4px; margin: 8px 0; }
pre { white-space: pre-wrap; font-size: 0.78rem; overflow-x: auto; }
.legal h2 { margin-top: 28px; }
.adm-tab > .seg, .adm-tab > form { justify-self: start; }
.notice-locked { max-width: 560px; margin: 24px 0; padding: 20px 22px; display: grid; gap: 8px; justify-items: start; }
.notice-locked p { margin: 0; }
.seat-row .bar-avatar { vertical-align: middle; margin-right: 6px; }
.seat-bot { max-width: 210px; cursor: pointer; }
#seat-bot-hint { font-size: 0.88rem; margin: 8px 0 0; }
