/* 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: #eae7de;
  --sq-dark: #94a898;
  --shadow: 0 1px 2px rgba(25, 25, 25, .06), 0 8px 24px -12px rgba(25, 25, 25, .18);
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%; 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;
}
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.top {
  max-width: 1080px; margin: 0 auto; width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand svg { color: var(--accent); }
.brand-name { font-weight: 600; letter-spacing: .14em; font-size: 15px; }
.brand-name b { font-weight: 800; }
.conn { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-3); font-size: 12px; letter-spacing: .04em; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.conn-dot.ok { background: var(--accent); }
.conn-dot.bad { background: var(--danger); }

/* ---------- lobby ---------- */
.lobby { max-width: 560px; margin: 0 auto; padding: 44px 0 56px; }
h1 { font-size: clamp(34px, 6vw, 52px); line-height: 1.06; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 14px; }
.lead { color: var(--ink-2); margin: 0 0 34px; max-width: 46ch; }
.actions { display: grid; gap: 12px; margin-bottom: 26px; }
.btn {
  appearance: none; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 3px;
  padding: 10px 16px; text-align: left; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { border-color: var(--ink); }
.btn-primary:hover { background: var(--ink); color: var(--paper); }
.btn-primary:hover .btn-hint { color: #cfcfc9; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: var(--line-2); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger); color: var(--paper); }
.btn-sm { padding: 7px 12px; font-size: 13px; cursor: pointer; text-align: center; }
.actions .btn { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; }
.btn-label { font-weight: 600; font-size: 16px; letter-spacing: .01em; }
.btn-hint { font-size: 12px; color: var(--ink-3); letter-spacing: .03em; }
.actions .btn[disabled] { opacity: .45; cursor: wait; }

.lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); margin-bottom: 7px; }
.input {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 3px; padding: 9px 12px;
}
.input:focus { outline: none; border-color: var(--ink); }
.input::placeholder { color: var(--ink-3); }
.join { margin-bottom: 22px; }
.join-row { display: flex; gap: 8px; }
.join-row .input { flex: 1; }
.join-row .btn { flex: none; }
.name { margin-bottom: 34px; max-width: 260px; }

.wait, .invite {
  border: 1px solid var(--line); background: var(--paper); border-radius: 3px;
  padding: 16px 18px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.wait-title { font-weight: 600; margin-bottom: 2px; }
.wait-title::after { content: ""; display: inline-block; width: 1em; text-align: left; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.wait-sub { color: var(--ink-3); font-size: 13px; margin: 2px 0 10px; }

.how { list-style: none; margin: 0; padding: 22px 0 0; border-top: 1px solid var(--line); display: grid; gap: 8px; color: var(--ink-2); font-size: 13.5px; }
.how b { color: var(--ink); font-weight: 600; }
.how li { padding-left: 16px; position: relative; }
.how li::before { content: "—"; position: absolute; left: 0; color: var(--accent); }

/* ---------- game ---------- */
.game {
  display: grid; grid-template-columns: minmax(300px, min(100%, 62vh + 70px)) minmax(280px, 360px);
  gap: 28px; padding: 6px 0 40px; justify-content: center; align-items: start;
}
.board-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-height: 22px; }
.opp { font-size: 13px; color: var(--ink-2); letter-spacing: .02em; }
.opp .you { color: var(--accent); }
.turn-ind { margin-left: auto; font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--ink-3); }
.turn-ind.me { color: var(--accent); font-weight: 600; }
.link-copy { appearance: none; background: none; border: none; border-bottom: 1px dashed var(--line-2); cursor: pointer; color: var(--accent); font: inherit; font-size: 12px; padding: 0; }

.board-frame { position: relative; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); user-select: none; touch-action: manipulation;
  border: 1px solid var(--line-2); box-shadow: var(--shadow); background: var(--line-2);
  aspect-ratio: 1;
}
.sq { position: relative; display: grid; place-items: center; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.pc { position: relative; z-index: 2; font-size: min(9.2vw, 46px); line-height: 1; cursor: pointer; }
.pc.w { color: #fcfbf8; text-shadow: 0 0 1.5px #3c3c37, 0 1px 2px rgba(20,20,18,.45); }
.pc.b { color: #22221f; }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(20, 104, 63, .22); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(20, 104, 63, .32); }
.sq.chk::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px rgba(140, 47, 47, .75); z-index: 1; }
.sq.tgt { cursor: pointer; }
.sq.tgt::after { content: ""; width: 22%; height: 22%; border-radius: 50%; background: rgba(20, 104, 63, .38); position: absolute; z-index: 3; }
.sq.tgt.cap::after { width: 82%; height: 82%; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 4px rgba(140, 47, 47, .5); }
.board.locked .pc { cursor: default; }

.over {
  position: absolute; inset: 0; display: grid; place-items: center; gap: 0;
  background: rgba(246, 245, 241, .82); backdrop-filter: blur(2px); z-index: 5;
}
.over-text { font-size: 19px; font-weight: 600; margin-bottom: 14px; text-align: center; padding: 0 16px; }
.over-actions { display: flex; gap: 10px; }

.board-foot { min-height: 20px; }
.moves { font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 3px 12px; }
.moves .mn { color: var(--ink-3); }
.moves .num { color: var(--ink-3); margin-right: 4px; }

.promo { display: flex; align-items: center; gap: 8px; }
.promo .lbl { margin: 0 4px 0 0; }

/* ---------- side panels ---------- */
.side { display: grid; gap: 16px; min-width: 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 3px; padding: 14px 16px; box-shadow: var(--shadow); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.draw { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.video-stage {
  position: relative; aspect-ratio: 4/3; background: #efede7; border: 1px solid var(--line);
  border-radius: 3px; overflow: hidden; margin-bottom: 10px;
}
.video-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #23231f; }
.video-stage video.pip {
  position: absolute; inset: auto 8px 8px auto; width: 31%; height: auto; aspect-ratio: 4/3;
  border: 1px solid rgba(253,252,250,.6); z-index: 3;
}
.video-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.sound-need {
  position: absolute; z-index: 4; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); border: none; border-radius: 3px; padding: 8px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.video-note { font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }

.chat { display: flex; flex-direction: column; min-height: 210px; }
.chat-log { flex: 1; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px 0 8px; }
.msg { max-width: 88%; padding: 6px 10px; border-radius: 3px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--accent-soft); border: 1px solid rgba(20,104,63,.25); }
.msg.them { align-self: flex-start; background: #f1efe9; border: 1px solid var(--line); }
.msg .who { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-bottom: 2px; }
.msg.sys { align-self: center; background: none; border: none; color: var(--ink-3); font-size: 12px; }
.chat-form { display: flex; gap: 8px; }
.chat-form .input { flex: 1; }

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--line); margin-top: 24px;
  display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 20px; color: var(--ink-3); font-size: 13px;
}
.foot b { color: var(--ink); font-variant-numeric: tabular-nums; }
.foot a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--line-2); }
.foot a:hover { color: var(--accent); border-color: var(--accent); }
.foot .dot { color: var(--line-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 8px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 3px;
  font-size: 13.5px; pointer-events: none; transition: opacity .18s, transform .18s; max-width: min(90vw, 480px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- narrow ---------- */
@media (max-width: 860px) {
  .game { grid-template-columns: 1fr; }
  .board-wrap { order: 1; }
  .side { order: 2; }
  .lobby { padding-top: 20px; }
}
