:root {
  --ink: #18221d;
  --ink-2: #222e28;
  --ink-3: #2f3d36;
  --paper: #eef0ea;
  --cream: #f4f6f0;
  --pink: #ff8fb0;
  --pink-deep: #f2729a;
  --lime: #c8ee6a;
  --muted: #a9b3ad;
  --muted-ink: #4b5852;
  --display: "Inter Tight", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
em { font-style: normal; color: var(--pink); }

.topbar, .foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 28px clamp(20px, 5vw, 64px);
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--cream); text-decoration: none;
  font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -0.05em;
}
.mark {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 50%; background: var(--pink); border: 3px solid var(--ink);
  box-shadow: 0 0 0 2px var(--lime); color: var(--ink);
  font-size: 24px; line-height: 1; letter-spacing: 0;
}

.eyebrow {
  margin: 0; font-family: var(--display); font-weight: 700; font-size: 13px;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted);
}
.eyebrow.lime { color: var(--lime); }

.view { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 64px) 40px; }

/* ---------- Landing ---------- */
#home { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px 64px; align-items: center; }
.hero h1 {
  font-family: var(--display); font-weight: 900; letter-spacing: -0.06em; line-height: 0.9;
  font-size: clamp(64px, 10vw, 140px); margin: 18px 0 24px;
}
.lede { font-size: clamp(18px, 2vw, 22px); line-height: 1.45; color: #d6ddd8; max-width: 30ch; margin: 0; }

.card {
  background: var(--paper); color: var(--ink);
  border-radius: var(--radius); padding: 28px;
}
.card .eyebrow { color: var(--muted-ink); }
.create form, .join { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend {
  font-family: var(--display); font-weight: 700; font-size: 15px; padding: 0; margin-bottom: 8px;
}
.field > span { margin-bottom: 0; }
input:not([type="radio"]) {
  font: 500 17px var(--body); color: var(--ink);
  background: var(--cream); border: 2px solid var(--ink); border-radius: 14px;
  padding: 14px 16px; width: 100%; outline: none;
}
input:not([type="radio"]):focus { box-shadow: 0 0 0 4px var(--lime); }

.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid var(--ink); border-radius: 999px; padding: 11px 8px;
  font: 600 15px var(--body); cursor: pointer; transition: background .15s;
}
.seg input:checked + span { background: var(--ink); color: var(--cream); }
.seg input:focus-visible + span { box-shadow: 0 0 0 4px var(--lime); }

.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid var(--ink); }
.dot.white { background: var(--cream); }
.dot.black { background: var(--ink); border-color: var(--cream); }
.seg .dot.black { border-color: var(--ink); }
.seg input:checked + span .dot.black { border-color: var(--cream); }
.dot.lime { background: var(--lime); }
.dot.pink { background: var(--pink); border-color: var(--pink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 17px var(--display); letter-spacing: -0.01em; text-decoration: none;
  border: 2px solid var(--ink); border-radius: 999px; padding: 15px 24px; cursor: pointer;
  background: var(--cream); color: var(--ink); transition: transform .1s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--pink); }
.btn.primary:hover { background: var(--pink-deep); }
.btn.small { padding: 10px 16px; font-size: 15px; }
.btn.ghost { background: transparent; color: var(--cream); border-color: var(--ink-3); }
.btn.ghost:hover { border-color: var(--cream); }
.card .btn.ghost { color: var(--ink); border-color: var(--ink); }
.btn:disabled { opacity: .6; cursor: progress; }
.form-error { margin: 0; color: #b0284f; font-weight: 600; min-height: 1px; }
.form-error:empty { display: none; }

.features {
  grid-column: 1 / -1; list-style: none; margin: 8px 0 0; padding: 0;
  border-top: 1px solid var(--ink-3);
}
.features li {
  display: flex; align-items: center; gap: 18px; padding: 20px 0;
  border-bottom: 1px solid var(--ink-3); font-size: clamp(17px, 2vw, 22px); font-weight: 500;
}
.features .dot { width: 26px; height: 26px; }
.features .dot.black { background: var(--ink); border-color: var(--cream); }

/* ---------- Game ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.board-col { display: grid; gap: 14px; width: 100%; max-width: min(640px, calc(100vh - 230px)); min-width: 280px; justify-self: center; }

.player-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.player { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.player .dot { width: 22px; height: 22px; }
.player small { font: 500 13px var(--body); color: var(--muted); letter-spacing: 0; }
.player.turn .dot { box-shadow: 0 0 0 4px var(--lime); }
.presence { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.presence::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.presence.on::before { background: var(--lime); }
.captured { font-size: 20px; letter-spacing: -0.1em; color: var(--muted); }

.board-wrap { position: relative; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1;
  border-radius: 18px; overflow: hidden; border: 3px solid var(--ink-3);
  user-select: none; touch-action: manipulation;
}
.sq {
  position: relative; display: flex; align-items: center; justify-content: center;
  background: var(--cream); border: 0; padding: 0; margin: 0; cursor: default; font: inherit;
}
.sq.dark { background: var(--pink); }
.sq.last::after { content: ""; position: absolute; inset: 0; background: rgba(200, 238, 106, .55); }
.sq.selected::after { content: ""; position: absolute; inset: 0; background: var(--lime); }
.sq.check { background: radial-gradient(circle, #ff4f7e 0%, #ff4f7e 35%, transparent 72%), var(--cream); }
.sq.dark.check { background: radial-gradient(circle, #e0245a 0%, #e0245a 35%, transparent 72%), var(--pink); }
.sq.movable { cursor: pointer; }
.sq.target { cursor: pointer; }
.sq.target::before {
  content: ""; position: absolute; z-index: 2; width: 28%; height: 28%; border-radius: 50%;
  background: var(--ink); opacity: .35;
}
.sq.target.capture::before {
  width: 86%; height: 86%; background: transparent; border: 5px solid var(--ink); opacity: .35;
}
.sq:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; z-index: 3; }

.piece {
  position: relative; z-index: 1; line-height: 1;
  font-size: clamp(26px, 6.4vw, 60px);
  font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols 2", "Apple Symbols", serif;
  transition: transform .12s;
}
.piece.w { color: var(--cream); -webkit-text-stroke: 1.6px var(--ink); paint-order: stroke fill; text-shadow: 0 2px 0 rgba(24, 34, 29, .25); }
.piece.b { color: var(--ink); text-shadow: 0 2px 0 rgba(24, 34, 29, .18); }
.sq.selected .piece { transform: scale(1.08); }

.coord { position: absolute; z-index: 2; font: 700 11px var(--display); color: var(--ink); opacity: .55; pointer-events: none; }
.coord.file { right: 5px; bottom: 3px; }
.coord.rank { left: 5px; top: 3px; }

.promo {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center;
  background: rgba(24, 34, 29, .72); border-radius: 18px;
}
.promo-box { background: var(--paper); border-radius: var(--radius); padding: 20px; display: grid; gap: 12px; text-align: center; color: var(--ink); }
.promo-box .choices { display: flex; gap: 10px; }
.promo-box button {
  width: 68px; height: 68px; border-radius: 16px; border: 2px solid var(--ink);
  background: var(--cream); cursor: pointer; display: grid; place-items: center;
}
.promo-box button:hover { background: var(--lime); }
.promo-box .piece { font-size: 44px; }

.side { display: grid; gap: 16px; }
.status-card {
  border-radius: var(--radius); padding: 22px 24px; background: var(--ink-2);
  border: 1px solid var(--ink-3);
}
.status-card h2 { margin: 6px 0 4px; font-family: var(--display); font-weight: 900; font-size: 34px; letter-spacing: -0.05em; line-height: 1; }
.status-card p { margin: 0; color: var(--muted); }
.status-card.your-turn { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.status-card.your-turn p, .status-card.your-turn .eyebrow { color: var(--muted-ink); }
.status-card.over { background: var(--pink); color: var(--ink); border-color: var(--pink); }
.status-card.over p, .status-card.over .eyebrow { color: var(--ink); }

.invite { display: grid; gap: 12px; }
.invite-copy { margin: 0; color: var(--muted-ink); }
.link-row { display: flex; gap: 8px; }
.link-row input { font-size: 14px; padding: 10px 12px; }
.join h2 { margin: 0; font-family: var(--display); font-weight: 900; font-size: 30px; letter-spacing: -0.04em; }

.moves-card { padding: 20px 22px; }
.moves-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: #c9cfcb; }
.conn.on { background: #6aa51a; }
.moves {
  margin: 0; padding: 0; list-style: none; max-height: 260px; overflow: auto;
  display: grid; grid-template-columns: 34px 1fr 1fr; row-gap: 2px;
  font: 500 15px var(--body); font-variant-numeric: tabular-nums;
}
.moves li { display: contents; }
.moves .n { color: var(--muted-ink); }
.moves .m { padding: 3px 6px; border-radius: 6px; }
.moves .m.latest { background: var(--lime); }
.moves .empty { grid-column: 1 / -1; color: var(--muted-ink); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--cream); color: var(--ink); padding: 12px 20px; border-radius: 999px;
  font-weight: 600; transition: .2s; pointer-events: none; z-index: 20; border: 2px solid var(--ink);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { border-top: 1px solid var(--ink-3); margin: 0 clamp(20px, 5vw, 64px); padding-left: 0; padding-right: 0; color: var(--muted); font-size: 15px; }
.foot span:first-child { color: var(--cream); font-weight: 700; }

@media (max-width: 900px) {
  #home { grid-template-columns: 1fr; }
  .game-layout { grid-template-columns: 1fr; }
  .board-col { max-width: 640px; }
  .topbar .eyebrow { display: none; }
}
@media (max-width: 480px) {
  .seg span { font-size: 14px; padding: 10px 4px; }
  .card { padding: 22px; }
}
