/* LuckyChess — турниры. Светлая строгая тема, без внешних зависимостей. */
:root {
  --bg: #f6f5f1;
  --paper: #fdfcfa;
  --ink: #191919;
  --ink-2: #5c5c57;
  --ink-3: #8b8b84;
  --line: #e3e0d8;
  --line-2: #c9c5bb;
  --accent: #14683f;
  --accent-soft: #14683f1a;
  --danger: #8c2f2f;
  --sq-light: #f0d9b5;
  --sq-dark: #b58863;
  --shadow: 0 1px 2px rgba(25,25,25,.06), 0 10px 28px -14px rgba(25,25,25,.2);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.06; margin: 0 0 10px; }
h2 { font-size: 22px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; color: var(--ink-2); }
.hidden { display: none !important; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

.t-top {
  width: 100%; max-width: 1120px; margin: 0 auto; padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.t-brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: .14em; font-size: 15px; color: var(--ink); }
.t-brand:hover { text-decoration: none; }
.t-brand-mark { width: 22px; height: 22px; flex: none; }
.t-brand-name { font-weight: 600; letter-spacing: .14em; font-size: 15px; }
.t-brand-name b { font-weight: 800; }
@media (max-width: 640px) {
  .t-brand-name { display: none; }
  .t-brand-mark { width: 18px; height: 18px; }
}
.t-nav { display: flex; gap: 16px; font-size: 13px; }
.t-nav a { color: var(--ink-2); }
.t-nav a:hover { color: var(--ink); text-decoration: none; }
.t-wrap { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 18px 20px 56px; }
.t-dev-note { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.t-dev-note span {
  display: block; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--paper); color: var(--ink-2); font-size: 13px; line-height: 1.45;
}
.t-dev-note b { color: var(--ink); }
.t-footer {
  width: 100%; max-width: 1120px; margin: 0 auto; padding: 18px 20px 26px;
  display: flex; justify-content: space-between; gap: 16px; color: var(--ink-3);
  font-size: 12px; border-top: 1px solid var(--line);
}
.t-fv { font-family: ui-monospace, Consolas, monospace; }
.t-loading { padding: 36px 0; color: var(--ink-3); }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 780px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.btn {
  appearance: none; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 4px;
  padding: 9px 14px; transition: background .12s, border-color .12s, color .12s, transform .12s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #0f4c2d; border-color: #0f4c2d; color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: var(--line-2); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; text-align: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-2); border-radius: 4px; padding: 9px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 2px 8px;
}
.badge.ok { color: #14683f; background: #14683f1a; }
.badge.live { color: #8c2f2f; background: #8c2f2f14; }
.badge.off { color: var(--ink-2); background: #ece9e2; }
.pill { font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }

.notice { padding: 10px 12px; border-radius: 4px; background: #f4f2e9; border: 1px solid var(--line); font-size: 13px; margin-bottom: 12px; }
.notice.err { background: #f7e9e7; border-color: #d9b7b2; color: var(--danger); }
.notice.ok { background: #eaf2ec; border-color: #c8dfcf; color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: #f8f6f1; border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--ink-2); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.pairing { border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.pairing .pn { font-weight: 600; }
.pairing .res { font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.round-title { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button {
  border: 1px solid var(--line-2); background: var(--paper); color: var(--ink); border-radius: 4px;
  padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.tabs button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.role-tabs { margin: 18px 0 20px; }
.role-tabs button { padding: 9px 16px; font-weight: 600; }
.role-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tabs button:hover { border-color: var(--ink); }

/* board */
.board-wrap { width: 100%; max-width: 520px; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; aspect-ratio: 1 / 1;
  border: 2px solid #8d6e4c; border-radius: 2px; overflow: hidden; user-select: none;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,.38);
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq img { width: 92%; height: 92%; object-fit: contain; pointer-events: none; }
.sq.last { box-shadow: inset 0 0 0 3px rgba(20,104,63,.55); }
.sq.sel { box-shadow: inset 0 0 0 3px rgba(20,104,63,.85); }
.sq.target { cursor: pointer; }
.sq.coord::after {
  content: attr(data-coord); position: absolute; left: 3px; bottom: 2px;
  font-size: 10px; color: rgba(25,25,25,.5); font-family: ui-monospace, monospace;
}
.board.watch .sq { cursor: default; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
@media (max-width: 760px) { .game-layout { grid-template-columns: 1fr; } }
.game-side { display: grid; gap: 10px; }
.player-line { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.player-line .who { font-weight: 600; }
.player-line .clock { font-family: ui-monospace, Consolas, monospace; font-size: 15px; }
.player-line.turn { border-color: var(--accent); background: #f3faf5; }
.clock.low { color: var(--danger); }
.move-list { max-height: 260px; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--ink-2); padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }

.tour-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.tour-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }

.list-item { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .name { font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px;
  font-size: 14px; z-index: 50; box-shadow: var(--shadow); max-width: min(90vw, 520px);
}
.toast.err { background: var(--danger); }

.challenge-box { border: 1px solid var(--line-2); border-radius: 4px; padding: 14px; background: #f8f6f1; margin-top: 12px; }
.challenge-box .pin-demo { font-family: ui-monospace, Consolas, monospace; font-size: 24px; letter-spacing: .14em; color: var(--accent); font-weight: 700; }
.challenge-box a { word-break: break-word; }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-right: 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

details { margin-top: 8px; }
summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
