:root { --bg:#1d1612; --panel:#2a211b; --ink:#f3e9dc; --mute:#b9a994; --light:#e8cfa4; --dark:#8a5a3a; --red:#d6392f; --white:#f4efe6; --hi:#f6c945; --ok:#5fcf80; }
* { box-sizing: border-box; }
html, body { margin:0; background:var(--bg); color:var(--ink); font:16px/1.4 system-ui, sans-serif; -webkit-tap-highlight-color:transparent; }
body { min-height:100dvh; display:flex; justify-content:center; padding:env(safe-area-inset-top) 8px env(safe-area-inset-bottom); }
#app { width:100%; max-width:560px; padding:8px 0 24px; }
.hidden { display:none !important; }
h1 { margin:8px 0 0; font-size:2.2rem; letter-spacing:.02em; }
.sub { color:var(--mute); margin:4px 0 16px; }
.panel { background:var(--panel); border-radius:16px; padding:16px; }
.field { display:block; color:var(--mute); margin-bottom:12px; }
input { width:100%; padding:12px; margin-top:4px; border-radius:10px; border:1px solid #4a3b30; background:#150f0b; color:var(--ink); font:inherit; }
.modes { display:flex; flex-direction:column; gap:10px; }
button { font:inherit; color:var(--ink); cursor:pointer; }
.big { padding:14px; border-radius:12px; border:0; background:var(--dark); font-weight:600; min-height:48px; }
.big:active { filter:brightness(1.2); }
.chip { padding:8px 14px; border-radius:999px; border:1px solid #5a4739; background:#1d1612; min-height:40px; }
.chip.on { background:var(--hi); color:#1d1612; border-color:var(--hi); font-weight:600; }
.chip:disabled { opacity:.4; }
.opts { display:flex; flex-wrap:wrap; gap:8px; align-items:center; color:var(--mute); margin:-2px 0 4px; }
.opts span { width:64px; }
.row { display:flex; gap:8px; } .row input { margin:0; text-transform:uppercase; letter-spacing:.3em; text-align:center; }
.msg { color:#ff9c8a; min-height:1.4em; margin:10px 0 0; } .foot { margin:12px 0 0; text-align:center; color:var(--mute); } a { color:var(--hi); }

.bar { display:flex; align-items:center; gap:8px; margin:4px 0 8px; }
#status { flex:1; text-align:center; font-weight:600; min-height:1.4em; }
.icon { width:44px; height:44px; border-radius:12px; border:0; background:var(--panel); font-size:1.2rem; }
.invite { display:flex; justify-content:space-between; align-items:center; gap:8px; background:var(--panel); padding:8px 12px; border-radius:12px; margin-bottom:8px; }
.invite b { letter-spacing:.2em; font-size:1.3rem; color:var(--hi); }
.who { display:flex; align-items:center; gap:8px; padding:4px 4px; color:var(--mute); min-height:30px; }
.who .dot { width:14px; height:14px; border-radius:50%; } .who .turn { color:var(--ok); font-weight:600; }
.who .off { opacity:.5; }

.board { --s: min(calc(100vw - 16px), 540px, calc(100dvh - 300px)); width:var(--s); min-width:min(100%, 280px); aspect-ratio:1; margin:0 auto; display:grid; grid-template: repeat(8, 1fr) / repeat(8, 1fr); border-radius:10px; overflow:hidden; border:4px solid #4a3220; }
.sq { position:relative; display:flex; align-items:center; justify-content:center; padding:0; border:0; border-radius:0; background:var(--light); touch-action:manipulation; }
.sq.dk { background:var(--dark); }
.sq.last { box-shadow: inset 0 0 0 100px rgba(246,201,69,.28); }
.sq.sel { box-shadow: inset 0 0 0 3px var(--hi), inset 0 0 0 100px rgba(246,201,69,.3); }
.sq.tgt::after { content:""; position:absolute; width:30%; height:30%; border-radius:50%; background:var(--ok); opacity:.85; }
.sq.mov .pc { outline:2px solid rgba(246,201,69,.0); }
.sq.can .pc { box-shadow: 0 0 0 3px rgba(246,201,69,.8), 0 3px 4px rgba(0,0,0,.5); }
.pc { width:78%; height:78%; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:calc(var(--s) / 14); line-height:1; box-shadow:0 3px 4px rgba(0,0,0,.5), inset 0 -4px 6px rgba(0,0,0,.25); }
.pc.r { background:radial-gradient(circle at 35% 30%, #f06b5e, var(--red) 60%, #8f1d16); border:3px solid #ff9185; color:#ffe9a8; }
.pc.w { background:radial-gradient(circle at 35% 30%, #fff, var(--white) 60%, #c9bfae); border:3px solid #fff; color:#7a5a1a; }

.actions { display:flex; gap:8px; justify-content:center; margin:10px 0; flex-wrap:wrap; }
.moves { background:var(--panel); border-radius:12px; padding:8px 12px; }
.moves summary { cursor:pointer; color:var(--mute); }
#movelist { margin:6px 0 0; padding-left:2em; max-height:140px; overflow:auto; columns:2; font-variant-numeric:tabular-nums; }
@media (min-width: 900px) {
  #app { max-width:900px; }
  #game { display:grid; grid-template-columns: minmax(0,540px) 260px; gap:16px; align-items:start; }
  #game .bar, #game .invite { grid-column:1 / 3; }
  .board { grid-column:1; --s: min(540px, calc(100dvh - 220px)); }
  .who, .actions { grid-column:1; }
  .moves { grid-column:2; grid-row:3 / 7; }
  #movelist { max-height:60vh; columns:1; }
}
