:root {
  --bg: #15171b;
  --panel: #1d2026;
  --card: #262a32;
  --card-2: #2e333d;
  --line: #3a404c;
  --text: #ece6d8;
  --muted: #9aa0ab;
  --gold: #e2b24f;
  --gold-2: #f3cd72;
  --danger: #e0584f;
  --ok: #5cb85c;
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Cinzel', Georgia, 'Times New Roman', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
.row { display: flex; gap: 8px; align-items: center; }
.error { color: var(--danger); margin: 12px 0 0; font-size: 14px; }

.logo { font-family: var(--display); font-weight: 800; letter-spacing: .04em; color: var(--gold); }
.logo.small { font-size: 20px; }

/* ---------- buttons & inputs */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: 600 14px var(--font); padding: 10px 16px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover:not(:disabled) { border-color: #566070; background: #363c48; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #24190a; }
.btn.primary:hover:not(:disabled) { background: var(--gold-2); border-color: var(--gold-2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn .ico { width: 16px; height: 16px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover:not(:disabled) { background: #363c48; }
.icon-btn:disabled { opacity: .4; cursor: default; filter: grayscale(1); }
.icon-btn.on { border-color: var(--gold); color: var(--gold); }
input {
  font: 15px var(--font); color: var(--text); background: #14161a; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
input:focus { border-color: var(--gold); }
.field { display: block; margin: 20px 0 14px; text-align: left; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ---------- home */
.screen { position: fixed; inset: 0; }
#home, #lobby {
  display: flex; align-items: center; justify-content: center; gap: 20px; padding: 16px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(226,178,79,.12), transparent 60%),
    url('/tiles/base/Grass.jpg') center / 220px repeat;
  overflow: auto;
}
#home::before, #lobby::before { content: ''; position: fixed; inset: 0; background: rgba(12,14,18,.82); }
.home-card, .lobby-card, .lobby-chat {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.home-card { width: 380px; max-width: 100%; text-align: center; }
.home-tile { width: 96px; height: 96px; border-radius: 14px; transform: rotate(-6deg); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.logo { font-size: 40px; margin-top: 10px; }
.tagline { color: var(--muted); margin: 4px 0 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 8px; }
#home-code { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }
.archive-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; text-decoration: none; border-bottom: 1px dashed var(--line); }
.archive-link:hover { color: var(--gold); border-color: var(--gold); }
.archive-links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.archive-link.inline { margin: 0 0 0 8px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.account { margin: 0 0 12px; display: flex; justify-content: center; min-height: 40px; align-items: center; }
.account-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.account-info b { color: var(--text); }
.account-info img { width: 26px; height: 26px; border-radius: 50%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--gold-2); font: inherit; cursor: pointer; text-decoration: underline; }
.open-rooms { margin-top: 16px; text-align: left; }
.open-rooms-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.open-rooms ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.open-room {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--text); font: inherit;
}
.open-room:hover { border-color: var(--gold); }
.or-main { flex: 1; min-width: 0; }
.or-dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 4px; }
.or-dots i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.or-sub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.or-code { font-weight: 800; letter-spacing: .2em; color: var(--gold); }
.my-rooms { margin-top: 16px; text-align: left; }
.my-rooms ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.my-room { border-color: var(--gold); background: #2f2c25; }
.my-room-row { display: flex; gap: 6px; }
.my-room-row .open-room { flex: 1; min-width: 0; }
.abandon-btn {
  flex: none; width: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); cursor: pointer; font-size: 14px;
}
.abandon-btn:hover { color: var(--danger); border-color: var(--danger); }
.my-room.your-turn { box-shadow: 0 0 0 2px var(--gold) inset; }
.my-turn { color: var(--gold-2); }
.or-empty { color: var(--muted); font-size: 13px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; }

/* ---------- lobby */
.lobby-card { width: 460px; max-width: 100%; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.room-code { font: 800 36px var(--display); letter-spacing: .15em; color: var(--gold); }
.lobby-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lobby-players li {
  display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 10px; padding: 8px 10px;
}
.lobby-players .name { flex: 1; font-weight: 600; }
.lobby-players .tag { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: .06em; }
.lobby-players .kick { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }
.meeple-ico { width: 26px; height: 26px; flex: none; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.15);
}
.swatch.mine { border-color: #fff; }
.swatch.taken { opacity: .25; cursor: not-allowed; }
.expansions label { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; line-height: 1.35; }
.expansions input { margin-top: 3px; }
.expansions input { width: auto; }
.lobby-actions { display: flex; justify-content: space-between; margin-top: 24px; }
.lobby-chat { width: 320px; height: min(520px, 80vh); display: flex; flex-direction: column; padding: 16px; }

/* ---------- chat & log */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; font-size: 14px; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.chat-log .msg b { margin-right: 4px; }
.chat-log .empty { color: var(--muted); font-size: 13px; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { padding: 8px 10px; }
.chat-form .btn { padding: 8px 12px; }

/* ---------- game layout */
#game { display: grid; grid-template-columns: 280px 1fr 280px; }
#game.chat-hidden { grid-template-columns: 1fr 280px; }
#game.chat-hidden .chatbar { display: none; }
.chatbar {
  background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  min-height: 0; padding: 14px; gap: 10px; overflow: hidden;
}
.chatbar-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 6px; }
.chatbar-head .tabs { flex: 1; }
.chatbar .tab-panel { flex: 1; min-height: 0; }
.icon-btn.small { width: 28px; height: 28px; font-size: 16px; }
.chat-open {
  position: absolute; left: 12px; top: 12px; z-index: 4; display: flex; align-items: center; gap: 6px;
  background: rgba(20,22,26,.9); border: 1px solid var(--line); color: var(--text); border-radius: 999px;
  padding: 6px 12px; font: 600 13px var(--font); cursor: pointer;
}
.chat-open b { background: var(--gold); color: #2b1a00; border-radius: 999px; padding: 0 6px; font-size: 12px; }
.board-wrap {
  position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(70,90,60,.35), transparent 70%),
    repeating-linear-gradient(45deg, #1a1f1b 0 14px, #1c221d 14px 28px);
}
#board { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
#board.panning { cursor: grabbing; }
.board-tools { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.toast {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%); background: rgba(20,22,26,.92);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-weight: 600; pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.err { border-color: var(--danger); color: #ffb3ad; }
.idle-banner {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px);
  background: rgba(20,22,26,.96); border: 1px solid var(--gold); border-radius: 12px; padding: 10px 16px;
  font-weight: 600; font-size: 14px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); cursor: pointer;
}

/* quick reactions */
.emote-bar {
  position: absolute; right: 12px; bottom: 12px; z-index: 4; display: flex; gap: 2px;
  background: rgba(20,22,26,.85); border: 1px solid var(--line); border-radius: 999px; padding: 3px;
}
.emote-bar button {
  width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 0; transition: transform .12s, background .12s;
}
.emote-bar button:hover { background: var(--card); transform: scale(1.18); }
.emote-bar button:active { transform: scale(.92); }
.emote-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.emote {
  position: absolute; bottom: 70px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transform: translateX(-50%); animation: emote-fly 3.2s ease-out forwards;
}
.emote-ico { font-size: 56px; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0,0,0,.45)); }
.emote-name {
  font-size: 13px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: rgba(20,22,26,.85);
  border: 1px solid var(--line); white-space: nowrap;
}
@keyframes emote-fly {
  0% { opacity: 0; transform: translate(-50%, 30px) scale(.4); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  20% { transform: translate(-50%, -10px) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -260px) scale(1); }
}
@media (max-width: 820px) {
  .emote-bar { bottom: 8px; right: 8px; }
  .emote-bar button { width: 28px; height: 28px; font-size: 16px; }
  .emote-ico { font-size: 42px; }
}

.sidebar {
  background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  min-height: 0; padding: 14px; gap: 12px; overflow: hidden;
}
.side-head { display: flex; justify-content: space-between; align-items: center; }
.side-fold, .side-mini { display: none; } /* phones only, see the mobile section */
.side-mini {
  flex: 1; min-width: 0; gap: 4px; align-items: center; overflow-x: auto; scrollbar-width: none; cursor: pointer;
}
.side-mini span {
  display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 2px 7px; border-radius: 999px;
  background: var(--card); border: 1px solid transparent; font: 800 14px var(--display); color: var(--gold);
}
.side-mini span.current { border-color: var(--gold); background: #2f2c25; }
.side-mini i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.side-mini .mini-bag { color: var(--muted); font: 600 12px var(--font); background: none; }
.room-pill {
  font: 700 13px var(--font); letter-spacing: .2em; padding: 4px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); cursor: pointer;
}
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.players li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 6px;
  background: var(--card); border-radius: 9px; padding: 5px 8px; border: 2px solid transparent; font-size: 13px;
}
.players li > svg, .players li > img { width: 22px; height: 22px; }
.players li.current { border-color: var(--gold); background: #2f2c25; }
.players .pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.players .pname .off { color: var(--danger); font-size: 11px; font-weight: 500; margin-left: 4px; }
.players .score { font: 800 17px var(--display); color: var(--gold); min-width: 26px; text-align: right; }
.players .pright { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.players .pclock { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.players li.current .pclock { color: var(--gold-2); }
.players .followers { display: flex; gap: 2px; margin-top: 2px; }
.players .followers i { width: 6px; height: 8px; border-radius: 3px 3px 2px 2px; display: block; }
.players .followers i.used { opacity: .18; }
.players .followers { align-items: center; }
.players .followers .kind-ico {
  width: 12px; height: 12px; margin-left: 3px; display: block;
  -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.players .followers .kind-ico.used { opacity: .18; }
.players .fcount { display: inline-flex; align-items: center; gap: 1px; font-size: 13px; font-weight: 800; margin-right: 5px; font-variant-numeric: tabular-nums; }
.players .fcount .kind-ico { width: 14px; height: 14px; margin-left: 1px; }
.players .fcount.used { opacity: .4; }
.players .goods { display: flex; gap: 6px; margin-top: 2px; font-size: 11px; font-weight: 700; }
.players .goods span { display: inline-flex; align-items: center; gap: 2px; }
.players .goods span.none { opacity: .35; }
.players .goods img { width: 14px; height: 14px; }
.turn-title .bonus { font-size: 12px; font-weight: 700; color: #2b1a00; background: var(--gold); border-radius: 8px; padding: 1px 7px; margin-left: 6px; vertical-align: 1px; }
.log-goods { width: 15px; height: 15px; vertical-align: -3px; }

.turn-card { background: var(--card); border-radius: var(--radius); padding: 10px; font-size: 13px; }
.turn-title { font-weight: 700; margin-bottom: 2px; }
.turn-body { display: flex; gap: 12px; align-items: center; }
.tile-card { position: relative; width: 92px; height: 92px; flex: none; border-radius: 8px; overflow: hidden; background: #111; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.tile-card img#tile-img { width: 100%; height: 100%; display: block; transition: transform .2s; }
.tile-card.empty img { visibility: hidden; }
.turn-actions { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.turn-actions .btn { width: 100%; }
.hint { margin: 10px 0 4px; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.bag { margin: 0 0 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; color: var(--muted); font: 600 13px var(--font); padding: 6px 10px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }
.tab-panel { flex: 1; min-height: 0; overflow-y: auto; }
.tab-panel.chat { overflow: hidden; }
.log { margin: 0; padding: 0 0 0 4px; list-style: none; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.log .pts { color: var(--gold); font-weight: 700; }
.help p { font-size: 13px; margin: 0 0 8px; }

/* ---------- board elements */
.cell { fill: rgba(226,178,79,.10); stroke: var(--gold); stroke-width: 1.6; stroke-dasharray: 6 5; cursor: pointer; }
.cell:hover { fill: rgba(226,178,79,.28); }
.cell.passive { fill: rgba(255,255,255,.04); stroke: rgba(255,255,255,.25); cursor: default; }
.preview { cursor: pointer; }
.preview-frame { fill: none; stroke: var(--gold); stroke-width: 3; }
.rotate-badge { cursor: pointer; }
.last-mark { fill: none; stroke-width: 3.5; }
.owner-dot { stroke: rgba(15,16,20,.85); stroke-width: 1.5; }
.spot { fill: rgba(255,255,255,.85); stroke: #24190a; stroke-width: 2; cursor: pointer; transition: r .1s; }
.spot:hover { fill: var(--gold-2); }
.spot.sel { fill: var(--gold); }
.spot.only-abbot { fill: #e4d4ff; stroke: #3b2366; }
.spot.only-builder { fill: #ffe0b0; stroke: #6b3d00; }
.spot.only-pig { fill: #ffd3de; stroke: #7a2a40; }
.spot.multi { stroke: #6b3fb3; stroke-width: 3; }
.recalling { opacity: .35; }
.recall-btn { cursor: pointer; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.recall-btn circle { fill: #f4eefe; stroke: #3b2366; stroke-width: 1.8; }
.recall-btn path { fill: none; stroke: #3b2366; stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.recall-btn:hover circle { fill: #fff; }
.recall-btn.on circle { fill: var(--gold); stroke: #24190a; }
.recall-btn.on path { stroke: #24190a; }
.recall-pts { font: 800 15px var(--display); fill: var(--gold-2); paint-order: stroke; stroke: #1a1208; stroke-width: 4px; pointer-events: none; }
.tile-overlay { pointer-events: none; }
.tile-ovl { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
/* ---------- tile in hand (bottom centre of the board) */
.hand {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.hand-label {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 4; pointer-events: none;
  font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  background: rgba(20,22,26,.85); border: 1px solid var(--line); white-space: nowrap;
}
.hand-label kbd { font: 700 11px var(--font); padding: 0 5px; border-radius: 4px; background: var(--card-2); border: 1px solid var(--line); }
.hand-row { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.hand-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(38,42,50,.92); color: var(--text); font-size: 20px; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.hand-btn:hover { border-color: var(--gold); color: var(--gold); }
.hand-card {
  width: 132px; height: 132px; padding: 7px; border-radius: 14px; cursor: pointer;
  background: linear-gradient(160deg, #3a3326, #231f18); border: 2px solid var(--gold);
  box-shadow: 0 18px 40px rgba(0,0,0,.6), 0 0 0 4px rgba(226,178,79,.15);
  transform: perspective(500px) rotateX(8deg); transition: transform .2s, filter .3s, opacity .3s;
}
.hand-card:hover { transform: perspective(500px) rotateX(0deg) translateY(-6px); }
.hand-tile { position: relative; width: 100%; height: 100%; border-radius: 6px; overflow: hidden; transition: transform .25s ease; }
.hand-tile > img:first-child { width: 100%; height: 100%; display: block; user-select: none; }
.hand.waiting .hand-card {
  filter: grayscale(1) brightness(.8); opacity: .8; border-color: #6b707a;
  box-shadow: 0 14px 30px rgba(0,0,0,.5);
}
.hand-label.waiting { color: var(--muted); }
.cell:not(.fit) { fill: rgba(226,178,79,.04); stroke-opacity: .55; }
.cell:not(.fit):hover { fill: rgba(226,178,79,.2); stroke-opacity: 1; }
@media (max-width: 820px) {
  .hand { bottom: 10px; }
  .hand-card { width: 92px; height: 92px; padding: 5px; }
  .hand-btn { width: 34px; height: 34px; font-size: 17px; }
}

/* feature highlight (hover over a follower or a placement spot) */
.feature-hl { pointer-events: none; filter: drop-shadow(0 0 5px rgba(255,214,110,.9)); }
.hl-field { fill: rgba(255,238,170,.42); stroke: #fff3c4; stroke-width: 2; stroke-linejoin: round; }
.hl-fill { fill: #ffe39a; opacity: .5; }
.hl-road { fill: none; stroke: #fff3c4; stroke-width: 9; stroke-linecap: round; opacity: .85; }
.hl-area { fill: rgba(255,238,170,.08); stroke: #fff3c4; stroke-width: 2.5; stroke-dasharray: 7 6; }
.hit { fill: transparent; cursor: help; }
.confirm-btn { cursor: pointer; filter: drop-shadow(0 3px 4px rgba(0,0,0,.55)); }
.undo-btn { cursor: pointer; filter: drop-shadow(0 3px 4px rgba(0,0,0,.55)); animation: confirm-in .25s cubic-bezier(.3,1.6,.6,1); transform-box: fill-box; }
.undo-ring { fill: #2a2e36; stroke: #8d939e; stroke-width: 1.5; transition: fill .12s; }
.undo-btn:hover .undo-ring { fill: #3a404c; }
.undo-cross { fill: none; stroke: #e6e8ec; stroke-width: 2.6; stroke-linecap: round; pointer-events: none; }
.confirm-ring { fill: var(--gold); stroke: #24190a; stroke-width: 2; transition: fill .12s; }
.confirm-btn:hover .confirm-ring { fill: var(--gold-2); }
.confirm-check { fill: none; stroke: #24190a; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.confirm-btn { animation: confirm-in .25s cubic-bezier(.3,1.6,.6,1); transform-box: fill-box; }
@keyframes confirm-in { from { opacity: 0; } to { opacity: 1; } }
.feature-tip {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; max-width: 260px;
  background: rgba(20,22,26,.95); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 11px; font-size: 13px; line-height: 1.5; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.feature-tip b { color: var(--gold-2); }
.feature-tip div:first-child b { color: var(--text); }
.tip-owner { display: inline-flex; align-items: center; gap: 5px; margin-right: 10px; opacity: .65; }
.tip-owner.lead { opacity: 1; font-weight: 600; }
.tip-owner i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tip-free { color: var(--muted); }
.follower-menu {
  position: absolute; left: 0; top: 0; z-index: 6;
  background: rgba(20,22,26,.97); border: 1px solid var(--line); border-radius: 12px;
  padding: 4px; box-shadow: 0 12px 34px rgba(0,0,0,.5); display: flex; align-items: center; gap: 2px;
}
.follower-menu button {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px;
  background: transparent; border: 0; border-radius: 9px; padding: 0; color: var(--text);
  font: inherit; cursor: pointer;
}
.follower-menu button:hover { background: var(--card); }
.follower-menu button.on { background: var(--card); box-shadow: inset 0 0 0 2px var(--gold); }
.follower-menu .fm-ico { width: 28px; height: 28px; display: block; object-fit: contain; }
.follower-menu .fm-remove { font-size: 18px; color: var(--muted); }
.follower-menu .fm-sep { width: 1px; align-self: stretch; margin: 6px 3px; background: var(--line); }
.follower-menu .fm-recall b { position: absolute; left: 2px; top: 0; font-size: 13px; color: var(--gold-2); }
.follower-menu .fm-recall small { position: absolute; right: 2px; bottom: 0; font-size: 10px; font-weight: 700; color: var(--gold-2); }
.tile-in { animation: tile-in .35s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes tile-in { from { opacity: 0; transform: scale(1.18); } to { opacity: 1; transform: scale(1); } }
.meeple { pointer-events: none; }
.meeple-in { animation: meeple-in .35s cubic-bezier(.3,1.6,.6,1); transform-box: fill-box; transform-origin: center bottom; }
@keyframes meeple-in { from { transform: translateY(-14px) scale(1.3); opacity: 0; } to { transform: none; opacity: 1; } }
.ghost-meeple { opacity: .8; pointer-events: none; }
.draw-stroke {
  fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
#board.drawing { cursor: crosshair; }
/* eraser: a ring the size of what it erases (12 px radius) */
#board.erasing {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26'%3E%3Ccircle cx='13' cy='13' r='11.5' fill='rgba(255,255,255,.15)' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 13 13, cell;
}
.final-pts {
  font: 800 22px var(--display); paint-order: stroke; stroke: #15110a; stroke-width: 5px; stroke-linejoin: round;
  pointer-events: none; text-anchor: start; animation: fx-in .4s ease-out;
}
@keyframes fx-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fx-score {
  font: 800 28px var(--display); paint-order: stroke; stroke: #1a1208; stroke-width: 5px;
  animation: fx-up 2.2s ease-out forwards; pointer-events: none; text-anchor: middle;
}
@keyframes fx-up { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40px); } }
.fx-complete { fill: rgba(255,230,150,.35); stroke: #ffe9a8; stroke-width: 3; animation: fx-flash 1.4s ease-out forwards; pointer-events: none; }
@keyframes fx-flash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- modal */
.modal { position: fixed; inset: 0; background: rgba(8,9,12,.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; width: 420px; max-width: 100%;
  text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.6);
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; /* many players: scroll */
}
.modal-ico { width: 48px; height: 48px; }
.modal-card h2 { font-family: var(--display); color: var(--gold); margin: 8px 0 16px; }
.ranking { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 6px; text-align: left; }
.ranking li { display: flex; align-items: center; gap: 10px; background: var(--card); padding: 10px 12px; border-radius: 10px; }
.ranking li.win { border: 2px solid var(--gold); }
.modal-card.wide { width: 860px; }
.end-tabs { display: flex !important; justify-content: center; margin: -4px 0 14px; }
@media (max-width: 640px) { .modal-card { padding: 18px; } }
.summary-wrap { overflow-x: auto; margin: 0 0 20px; }
.summary { width: 100%; border-collapse: collapse; font-size: 13px; }
.summary th, .summary td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.summary th:first-child, .summary td:first-child { text-align: left; color: var(--muted, #9aa3b2); }
.summary th { font-weight: 700; }
.summary .muted-row td { font-size: 12px; white-space: normal; }
.summary tr.total td { font-weight: 800; font-size: 15px; color: var(--gold); border-bottom: 0; }
.summary tr.total td:first-child { color: var(--gold); }
#btn-summary { margin-top: 8px; width: 100%; }
.replay-line { margin: -8px 0 18px; font-size: 13px; color: var(--muted); }
.replay-line b { color: var(--text); letter-spacing: .08em; }
.replay-line a { color: var(--gold-2); }
.ranking .place { font: 800 18px var(--display); width: 22px; color: var(--muted); }
.ranking .name { flex: 1; font-weight: 600; }
.ranking .score { font: 800 22px var(--display); color: var(--gold); }

/* ---------- mobile */
@media (max-width: 820px) {
  #game, #game.chat-hidden { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .chatbar, .chat-open { display: none !important; }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); max-height: 46vh; overflow-y: auto; padding: 10px; gap: 8px; }
  .players { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .tile-card { width: 84px; height: 84px; }
  .tabs, .tab-panel { display: none; }
  .side-head { gap: 8px; }
  .side-fold { display: inline-flex; flex: none; }
  .sidebar.folded { padding: 6px 10px; }
  .sidebar.folded > :not(.side-head), .sidebar.folded .logo { display: none; }
  .sidebar.folded .side-mini { display: flex; }
  #lobby { flex-direction: column; align-items: stretch; }
  .lobby-card, .lobby-chat { width: 100%; }
  .lobby-chat { height: 260px; }
}
