:root {
  --navy: #0b1d3a; --navy-2: #12305f; --gold: #c8a45c; --gold-d: #a98536;
  --bg: #f3f5f9; --card: #ffffff; --ink: #14213d; --muted: #5b6577; --line: #dde2ec;
  --ok: #1b7f4b; --bad: #b3261e; --radius: 14px;
  --sq-light: #f0d9b5; --sq-dark: #b58863;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--navy-2); }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* buttons & fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem; border: 0; border-radius: 10px;
  background: var(--navy); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); color: #1a1405; } .btn.gold:hover { background: #d6b46d; }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: #eef1f7; }
.btn.danger { background: var(--bad); }
.btn.small { min-height: 34px; padding: .25rem .7rem; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; color: var(--navy-2); text-decoration: underline; cursor: pointer; }
.field { margin-bottom: 1rem; position: relative; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field input { width: 100%; min-height: 46px; padding: .6rem .75rem; border: 1.5px solid #b9c1d1; border-radius: 10px; background: #fff; color: var(--ink); }
.field input:focus { border-color: var(--navy-2); outline: 3px solid rgba(200,164,92,.5); }
.field small { color: var(--muted); display: block; margin-top: .25rem; }
.show-pw { position: absolute; right: .25rem; top: 0; padding: .1rem .4rem; font-size: .9rem; }
.error { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: linear-gradient(160deg, var(--navy), var(--navy-2)); }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border-radius: 18px; padding: 1.75rem; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.auth-head { text-align: center; margin-bottom: 1.25rem; }
.auth-head h1 { font-size: 1.5rem; margin-top: .5rem; }
.auth-head p { color: var(--muted); }
.tabs { display: flex; gap: .25rem; background: #eef1f7; border-radius: 12px; padding: .25rem; margin-bottom: 1.25rem; }
.tabs button { flex: 1; min-height: 42px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.auth-card .btn { width: 100%; }
.auth-foot { text-align: center; margin-top: 1rem; font-size: .95rem; }
.notice { background: #fff8e6; border: 1px solid #ecd9a3; border-radius: 10px; padding: .75rem .9rem; margin-bottom: 1rem; font-size: .95rem; }
.big-code { font: 700 1.5rem/1.2 ui-monospace, Menlo, monospace; letter-spacing: .12em; }

/* shell */
.topbar { background: var(--navy); color: #fff; border-bottom: 4px solid var(--gold); position: sticky; top: 0; z-index: 10; }
.topbar-in { max-width: 1280px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: .02em; color: #fff; text-decoration: none; }
.brand small { display: block; font-weight: 500; color: #c9d3e6; font-size: .72rem; letter-spacing: 0; }
.nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; align-items: center; }
.nav a, .nav button { color: #e8edf7; text-decoration: none; padding: .45rem .8rem; border-radius: 9px; background: none; border: 0; cursor: pointer; font-weight: 600; }
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.12); }
.nav a[aria-current="page"] { background: var(--gold); color: #1a1405; }
.conn { font-size: .8rem; color: #c9d3e6; display: flex; align-items: center; gap: .35rem; margin-right: .5rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #e0a800; display: inline-block; }
.dot.on { background: #34c26b; }
main { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card > h2:first-child { margin-top: 0; }

/* club layout */
.club { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .club { grid-template-columns: 1fr; } }
.game-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.game-card { text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); padding: .9rem; cursor: pointer; display: block; }
.game-card:hover { border-color: var(--gold); box-shadow: 0 4px 14px rgba(11,29,58,.12); }
.game-card .ico { font-size: 2rem; line-height: 1; }
.game-card b { display: block; margin-top: .35rem; }
.game-card span { color: var(--muted); font-size: .9rem; }
.table-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.table-row:first-child { border-top: 0; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #e7ecf6; color: var(--navy); }
.pill.live { background: #dff3e7; color: var(--ok); } .pill.wait { background: #fff1c9; color: #7a5b00; }
.online-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.online-list li { background: #eef1f7; border-radius: 999px; padding: .2rem .7rem; font-size: .9rem; display: flex; align-items: center; gap: .35rem; }
.online-list .dot { background: #34c26b; width: 8px; height: 8px; }
.chat { display: flex; flex-direction: column; }
.chat-log { height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; background: #fafbfd; }
.chat-log.short { height: 200px; }
.msg { margin-bottom: .4rem; overflow-wrap: anywhere; }
.msg b { color: var(--navy-2); } .msg time { color: var(--muted); font-size: .75rem; margin-left: .35rem; }
.msg.sys { color: var(--muted); font-style: italic; }
.msg.me b { color: var(--gold-d); }
.chat-form { display: flex; gap: .5rem; margin-top: .5rem; }
.chat-form input { flex: 1; min-width: 0; min-height: 44px; border: 1.5px solid #b9c1d1; border-radius: 10px; padding: .4rem .7rem; }

/* table (game) view */
.table-head { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.seats { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.seat { border: 2px solid var(--line); border-radius: 12px; padding: .35rem .7rem; background: #fff; display: flex; align-items: center; gap: .45rem; }
.seat.turn { border-color: var(--gold); background: #fff8e6; }
.seat.empty { color: var(--muted); border-style: dashed; }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.4); display: inline-block; }
.banner { padding: .65rem .9rem; border-radius: 10px; background: #e7ecf6; font-weight: 600; margin-bottom: .75rem; }
.banner.turn { background: #fff1c9; } .banner.win { background: #dff3e7; color: #0e5a33; } .banner.lose { background: #f6dcda; color: #7d1b15; }
.board-wrap { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.game-area { flex: 1 1 360px; min-width: 0; }
.side-area { flex: 1 1 240px; min-width: 220px; }

/* 8x8 boards */
.board8 { display: grid; grid-template-columns: repeat(8, 1fr); width: min(100%, 560px); aspect-ratio: 1; border: 4px solid var(--navy); border-radius: 6px; overflow: hidden; user-select: none; }
.sq { position: relative; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; cursor: default; background: var(--sq-light); font-size: min(7.5vw, 44px); line-height: 1; }
.sq.dark { background: var(--sq-dark); }
.sq.sel { outline: 4px solid var(--gold); outline-offset: -4px; }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(255, 215, 0, .35); }
.sq.check { background: #e5534b !important; }
.sq.hint::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(20,33,61,.35); }
.sq.hint.cap::after { width: 86%; height: 86%; background: none; border: 5px solid rgba(20,33,61,.35); }
.sq.movable { cursor: pointer; }
.pc { position: relative; z-index: 1; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
.pc.w { color: #fff; -webkit-text-stroke: 1.2px #222; }
.pc.b { color: #111; -webkit-text-stroke: .6px #fff; }
.coord { position: absolute; font-size: .6rem; font-weight: 700; opacity: .65; z-index: 0; }
.coord.f { right: 3px; bottom: 1px; } .coord.r { left: 3px; top: 1px; }
.promo { display: flex; gap: .5rem; margin: .5rem 0; }
.promo button { font-size: 2rem; min-width: 56px; min-height: 56px; border-radius: 10px; border: 2px solid var(--gold); background: #fff; cursor: pointer; }
.disc { width: 78%; height: 78%; border-radius: 50%; position: relative; z-index: 1; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 2px 3px rgba(0,0,0,.4); display: grid; place-items: center; color: #ffd66b; font-size: 60%; }
.disc.r { background: #c0392b; } .disc.b { background: #23272e; }
.disc.k::after { content: "♛"; }

/* snakes */
.snake-board { position: relative; width: min(100%, 560px); aspect-ratio: 1; border: 4px solid var(--navy); border-radius: 6px; overflow: hidden; background: #fff; }
.snake-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); }
.sc { font-size: min(2.2vw, 12px); padding: 2px 3px; border: .5px solid rgba(0,0,0,.08); font-weight: 700; color: rgba(20,33,61,.7); }
.sc.a { background: #fdf3d7; } .sc.b { background: #e6f0fb; } .sc.end { background: #bfe8c9; }
.snake-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tokens { position: absolute; inset: 0; pointer-events: none; }
.tok { position: absolute; width: 4.2%; height: 4.2%; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); transition: left .5s, top .5s; }
.dice { width: 72px; height: 72px; border-radius: 14px; background: #fff; border: 3px solid var(--navy); display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; margin: .5rem 0; }

/* dominoes */
.dom-table { background: #1e6b46; border: 6px solid #5b3a1e; border-radius: 16px; padding: .75rem; min-height: 180px; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.tile { display: inline-flex; background: #fdfcf6; border: 2px solid #222; border-radius: 8px; box-shadow: 0 2px 0 rgba(0,0,0,.35); overflow: hidden; }
.tile.v { flex-direction: column; }
.half { width: 38px; height: 38px; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 4px; gap: 1px; }
.tile .half + .half { border-left: 2px solid #222; } .tile.v .half + .half { border-left: 0; border-top: 2px solid #222; }
.pip { border-radius: 50%; background: #1a1a1a; width: 100%; height: 100%; }
.tile.small .half { width: 26px; height: 26px; padding: 3px; }
.tile.back { background: #354a8a; }
.hand { display: flex; gap: 8px; flex-wrap: wrap; margin: .75rem 0; min-height: 90px; align-items: flex-start; }
.hand .tile { cursor: pointer; border: 3px solid #222; }
.hand .tile.ok { border-color: var(--gold); transform: translateY(-4px); } .hand .tile.sel { border-color: #e5534b; transform: translateY(-8px); }
.hand .tile:not(.ok) { opacity: .6; cursor: default; }
.opp { display: flex; gap: 1rem; flex-wrap: wrap; color: #fff; margin-bottom: .5rem; font-size: .9rem; }
.opp .tile { margin-right: 2px; }

.toast-host, #toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 460px); }
.toast { background: var(--navy); color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.toast.error { background: var(--bad); } .toast.ok { background: var(--ok); }

table.grid { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.grid th, table.grid td { text-align: left; padding: .5rem .4rem; border-top: 1px solid var(--line); vertical-align: middle; }
table.grid th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; border-top: 0; }
.scroll-x { overflow-x: auto; }
.qr { background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: 10px; display: inline-block; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .4rem; font: 600 1rem ui-monospace, Menlo, monospace; margin: .75rem 0; }
.codes span { background: #f3f5f9; border-radius: 8px; padding: .35rem .5rem; text-align: center; }
@media (max-width: 520px) { .topbar-in { gap: .5rem; } .brand small { display: none; } .auth-card { padding: 1.25rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.logo { object-fit: contain; display: inline-block; }
