@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/inter-latin.woff2) format("woff2");
}
:root {
  --page: #e7ebef; --panel: #ffffff; --panel-2: #f4f6f8; --line: #e1e5ea; --line-2: #d3d9e0;
  --text: #1d232a; --text-2: #3b434c; --muted: #69727d; --faint: #9aa2ab;
  --accent: #2f6fd6; --accent-soft: #e7effc;
  --sea: #6d9fc4; --sea-2: #5b8fb7;
  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.06);
  --shadow-2: 0 12px 32px rgba(16,24,40,.16), 0 2px 6px rgba(16,24,40,.08);
  --ease: cubic-bezier(.2,.7,.2,1);
  --cw: 58px; --ch: 82px; --fan: 12px;  /* hand cards: width, height, fan step */
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font: 400 14px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow: hidden;
  -webkit-tap-highlight-color: transparent; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; }
.emo { flex: none; }
.count, .act .n, #status .turnno, #status .clock, #bank .slot, .prow .vp b, .prow .stats, #log .pc, .score .pts, .pop .pickn { font-variant-numeric: tabular-nums; }
#app, .modal { -webkit-user-select: none; user-select: none; }
#log { -webkit-user-select: text; user-select: text; }

/* ---------- layout ---------- */
#app { height: 100%; max-width: 1760px; margin: 0 auto; padding: 12px; display: grid; gap: 12px;
  grid-template-columns: 52px minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "rail stage side" "rail bottom side"; }
#rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 2px; }
#rail .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#rail .brand-text { display: none; }
#stage { grid-area: stage; position: relative; min-height: 0; border-radius: var(--radius); overflow: hidden; touch-action: manipulation;
  background: radial-gradient(120% 90% at 50% 40%, #80b0d2 0%, var(--sea) 45%, var(--sea-2) 100%); box-shadow: var(--shadow-1); }
#bottom { grid-area: bottom; display: flex; gap: 12px; min-width: 0; }
#side { grid-area: side; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.card-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 10px; background: none; cursor: pointer; color: var(--muted); transition: background .15s, border-color .15s, transform .1s; }
.icon-btn:active { transform: translateY(1px); }

/* ---------- board ---------- */
#board, #board > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#board > svg { animation: fadeIn .25s ease-out both; }
.tile-in { animation: tileIn .55s var(--ease) both; transform-box: fill-box; transform-origin: center; }
@keyframes tileIn { from { opacity: 0; transform: scale(.9); } }
.drop { transform-box: fill-box; transform-origin: 50% 100%; }
.drop.in { animation: pieceIn .42s cubic-bezier(.2,.8,.3,1.2) both; }
@keyframes pieceIn { 0% { opacity: 0; transform: translateY(-10px) scale(.8); } 60% { opacity: 1; } }
.drop.out { animation: pieceOut .22s ease-in both; }
@keyframes pieceOut { to { opacity: 0; } }
.noanim * { animation: none !important; }
.robber { transition: transform .55s var(--ease); }
.robber.still { transition: none; }
.robber .hop { transform-box: fill-box; transform-origin: 50% 100%; }
.robber .hop.go { animation: hop .55s var(--ease); }
@keyframes hop { 40% { transform: translateY(-9px) scale(1.04); } }
.prod { animation: prod 1.8s ease-out both; pointer-events: none; }
@keyframes prod { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
.targets { animation: fadeIn .2s ease-out both; }
@keyframes fadeIn { from { opacity: 0; } }
.spot, .edge, .hexsel { cursor: pointer; }
.spot .dot { transition: transform .15s var(--ease); transform-box: fill-box; transform-origin: center; }
.spot .halo { animation: halo 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes halo { 0%, 100% { opacity: 0; transform: scale(.8); } 50% { opacity: .55; transform: scale(1.25); } }
.edge .line { transition: opacity .15s, stroke-width .15s; animation: breathe 1.8s ease-in-out infinite; }
.hexsel .ring { animation: breathe 1.6s ease-in-out infinite; transition: fill .15s; }
@keyframes breathe { 0%, 100% { opacity: .95; } 50% { opacity: .5; } }
.hintring { animation: breathe 1.2s ease-in-out infinite; pointer-events: none; }

#dice { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 8px; transition: opacity .3s; pointer-events: none; }
#dice.idle { opacity: .55; }
#dice.none { opacity: 0; }
.die { width: 42px; height: 42px; border-radius: 9px; background: linear-gradient(#fff, #f1efe9); box-shadow: 0 3px 8px rgba(0,0,0,.25), inset 0 -2px 0 rgba(0,0,0,.08); position: relative; }
.die i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #262a30; transform: translate(-50%, -50%); }
.die.red i { background: #c8372d; }
.die.tumble { animation: tumble .6s var(--ease); }
.die.tumble:nth-child(2) { animation-duration: .7s; }
@keyframes tumble { 0% { transform: translate(-30px, -26px) rotate(-260deg) scale(.7); opacity: 0; } 60% { opacity: 1; } 80% { transform: translate(0, 2px) rotate(8deg); } }

#toasts { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; z-index: 5; max-width: calc(100% - 28px); }
.toast { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.97); box-shadow: var(--shadow-2); font-size: 13px; color: var(--text-2);
  animation: toastIn .28s var(--ease) both; white-space: nowrap; max-width: 100%; }
.toast.out { animation: toastOut .25s ease-in both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

/* ---------- panels over the board ---------- */
#overlay { position: absolute; left: 12px; right: 12px; bottom: 16px; z-index: 6; display: flex; justify-content: center; pointer-events: none; }
.pop { pointer-events: auto; max-width: 100%; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-2); padding: 16px 18px; min-width: 320px; animation: popIn .26s var(--ease) both; }
.pop.out { position: absolute; bottom: 0; animation: popOut .16s ease-in both; pointer-events: none; }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes popOut { to { opacity: 0; transform: translateY(6px) scale(.99); } }
.pop h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.pop .label { font-size: 12px; color: var(--muted); font-weight: 500; margin: 12px 0 6px; }
.pop .row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.pop .foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.pop .note { color: var(--muted); font-size: 13px; }
.pop .swap { align-self: flex-end; height: 62px; display: grid; place-items: center; color: var(--faint); font-size: 18px; padding: 0 2px; }
.pop .pickcol { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pop .pickn { font-size: 11.5px; color: var(--muted); }
.pop .pickn b { color: var(--accent); font-weight: 600; }
.pop .hm { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); }
.pop .hm.top { color: var(--text); font-weight: 500; }
.pop .hn { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #69727d; color: #fff; font-size: 11px; font-weight: 700; font-style: normal; }
.pop .hn.top { background: var(--accent); }
.pop .bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.pop .bar i { display: block; height: 100%; border-radius: 3px; background: #b8c2cf; }
.pop .bar.top i { background: var(--accent); }
.btn { height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.good { background: #2e9e57; border-color: #2e9e57; color: #fff; font-weight: 600; }

/* ---------- bottom bar ---------- */
#hand { flex: 1; min-width: 0; height: 120px; display: flex; align-items: center; padding: 0 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; position: relative; }
#hand .msg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--faint); transition: opacity .2s; pointer-events: none; }
#hand .sep { flex: none; width: 1px; height: 64px; background: var(--line-2); margin-right: 14px; transition: opacity .2s, margin .25s var(--ease), width .25s var(--ease); }
#hand .sep.gone { opacity: 0; margin-right: 0; width: 0; }
.stack { --n: 1; position: relative; flex: none; height: var(--ch); width: calc(var(--cw) + (var(--n) - 1) * var(--fan)); margin-right: 14px;
  transition: width .25s var(--ease), margin .25s var(--ease), opacity .2s, transform .15s var(--ease); }
.stack.gone { width: 0; margin-right: 0; opacity: 0; pointer-events: none; }
.stack > .card { position: absolute; top: 0; left: calc(var(--i) * var(--fan)); width: var(--cw); height: var(--ch); transition: transform .18s var(--ease), left .25s var(--ease); }
.stack > .card.in { animation: cardIn .32s var(--ease) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(-18px); } }
.stack > .card.lift { transform: translateY(-14px); }
.stack.click { cursor: pointer; }
.stack.click::after { content: ""; position: absolute; inset: -4px; border-radius: 12px; box-shadow: 0 0 0 2px var(--accent); opacity: 0; transition: opacity .15s; }
.stack.wait > .card { filter: saturate(.55) brightness(1.05); opacity: .75; }
.stack .tag { position: absolute; z-index: 3; left: 50%; bottom: -9px; transform: translateX(-50%); padding: 1px 6px; border-radius: 6px; background: var(--panel); color: var(--muted);
  font-size: 10px; font-weight: 600; box-shadow: 0 0 0 1px var(--line-2); white-space: nowrap; }
.count { position: absolute; z-index: 3; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--text); color: #fff; font-size: 12px; font-weight: 600;
  display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: opacity .15s, transform .2s; }
.count.hide { opacity: 0; transform: scale(.6); }
.bump { animation: bump .35s var(--ease); }
@keyframes bump { 40% { transform: scale(1.25); } }

#controls { display: flex; flex-direction: column; gap: 8px; }
#status { height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 14px 0 7px; }
#status .who { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; transition: background .25s; }
#status .msg { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status .turnno, #status .clock { color: var(--muted); font-size: 13px; white-space: nowrap; }
#status .clock::before { content: "·"; margin: 0 10px 0 -2px; color: var(--faint); }
#status .turnno:empty + .clock::before { content: none; }
#buttons { display: flex; gap: 8px; }
.act { position: relative; width: 68px; height: 72px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-1); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; transition: background .15s, border-color .15s, box-shadow .2s, transform .1s; }
.act:active:not(:disabled) { transform: translateY(1px); }
.act .lbl { font-size: 11px; font-weight: 500; color: var(--muted); transition: color .15s; white-space: nowrap; }
.act .n { position: absolute; top: 5px; right: 7px; font-size: 10.5px; font-weight: 600; color: var(--faint); }
.act .ic { display: grid; transition: opacity .15s, filter .15s; }
.act:disabled { cursor: default; box-shadow: none; background: var(--panel-2); }
.act:disabled .ic { opacity: .35; filter: grayscale(.8); }
.act:disabled .lbl { color: var(--faint); }
.act.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.act.next:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,214,.18); }
.act.next:not(:disabled) .lbl { color: var(--accent); font-weight: 600; }
.act.wide { width: auto; flex: 1; min-width: 220px; flex-direction: row; gap: 10px; }
.act.wide .lbl { font-size: 13px; }

/* ---------- cards ---------- */
.card { --c: #888; position: relative; flex: none; width: 58px; height: 82px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(170deg, color-mix(in srgb, var(--c) 78%, white) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 88%, black) 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.06), inset 0 1px 0 rgba(255,255,255,.3); }
.card::before { content: ""; position: absolute; width: 66%; aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.26); left: 50%; top: 50%; transform: translate(-50%, -50%); }
.card .emo { position: relative; width: 50%; height: auto; aspect-ratio: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.18)); }
.card.lab { padding-bottom: 16px; } .card.lab::before { top: calc(50% - 8px); }
.card.md.lab { padding-bottom: 12px; } .card.md.lab::before { top: calc(50% - 6px); }
.card .cl { position: absolute; bottom: 7px; left: 0; right: 0; text-align: center; color: #fff; font-size: 9.5px; font-weight: 600; letter-spacing: .02em; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.card.md { width: 44px; height: 62px; border-radius: 7px; }
.card.md .cl { font-size: 8px; bottom: 5px; }
.card.xs { width: 14px; height: 19px; border-radius: 3px; box-shadow: 0 0 0 .5px rgba(0,0,0,.2); }
.card.xs::before { display: none; }
.card.xs .emo { width: 11px; filter: none; }
.card.xs.cost { width: 22px; height: 30px; border-radius: 4px; } .card.xs.cost .emo { width: 16px; }
.card.pick { cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s, opacity .15s; }
.card.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.card.dim { opacity: .3; filter: grayscale(.4); }
.card .count { top: -7px; right: -7px; min-width: 20px; height: 20px; font-size: 11px; }
.back { flex: none; display: inline-block; width: 22px; height: 30px; border-radius: 4px; position: relative; box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 1px 1px rgba(0,0,0,.12);
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 3px, transparent 3px 6px), #3f74c4; }
.back.dev { background: repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 3px, transparent 3px 6px), #6a5acd; }
.back.xs { width: 14px; height: 19px; border-radius: 3px; vertical-align: middle; }

/* ---------- side ---------- */
#logcard { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#logcard .head { padding: 12px 16px 10px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
#logcard .head span { color: var(--faint); font-weight: 500; font-size: 11.5px; }
#log { flex: 1; overflow-y: auto; padding: 4px 16px 12px; font-size: 13px; scrollbar-width: thin; overscroll-behavior: contain; }
#log .empty { color: var(--faint); padding-top: 10px; }
#log .turn { margin: 10px 0 4px; display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .03em; }
#log .turn::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#log .le { display: flex; align-items: center; gap: 8px; padding: 2.5px 0; min-height: 24px; }
#log .le.in { animation: logIn .3s var(--ease) both; }
@keyframes logIn { from { opacity: 0; transform: translateX(-6px); } }
#log .tx { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--text-2); }
#log .pc { flex: none; min-width: 30px; text-align: right; color: var(--faint); font-size: 11px; }
.nm { font-weight: 600; }
.mini { display: inline-flex; gap: 2px; vertical-align: middle; }
.tok { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: #f7f2e6; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); font-weight: 600; font-size: 11px; color: #262a30; }
.tok.red { color: #c8372d; }
#seats { display: flex; flex-direction: column; gap: 12px; }
#bank { padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#bank .slot { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 28px; }
#bank .slot .card { width: 28px; height: 38px; border-radius: 5px; }
#bank .slot .card::before { display: none; }
#bank .slot .card .emo { width: 18px; }
#bank .slot .lbl { font-weight: 500; }
#bank .flash { animation: flash .6s ease-out; }
@keyframes flash { 30% { color: var(--accent); } }
#players { display: flex; flex-direction: column; gap: 12px; }
.prow { --pc: #888; --pr: var(--pc); position: relative; padding: 12px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; transition: box-shadow .3s, border-color .3s; }
.prow.turn { border-color: color-mix(in srgb, var(--pr) 55%, white); box-shadow: 0 0 0 2px color-mix(in srgb, var(--pr) 28%, transparent), var(--shadow-1); }
.ava { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--pc) 16%, white); box-shadow: inset 0 0 0 2px var(--pr); }
.prow .ava { grid-row: 1 / 3; }
.prow .nmrow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.prow .pname { font-weight: 600; font-size: 15px; }
.prow .vp { grid-row: 1 / 3; grid-column: 3; text-align: center; min-width: 44px; }
.prow .vp b { display: block; font-size: 26px; font-weight: 600; line-height: 1.05; }
.prow .vp span { font-size: 10.5px; color: var(--faint); font-weight: 500; }
.prow .stats { grid-column: 2; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; font-weight: 600; color: var(--text-2); }
.prow .stat { display: inline-flex; align-items: center; gap: 5px; }
.prow .badges { grid-column: 1 / 4; display: flex; gap: 6px; flex-wrap: wrap; }
.prow .badges:empty { display: none; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 4px; border-radius: 999px; background: #fff6dd; color: #7a5600; font-size: 11.5px; font-weight: 600; box-shadow: inset 0 0 0 1px #f2dc9b; animation: fadeIn .3s ease-out; }
.thinking { display: inline-flex; gap: 3px; opacity: 0; transition: opacity .2s; }
.thinking.on { opacity: 1; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: think 1.1s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes think { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

/* ---------- modals ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(20,28,38,.35);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-bg.show { display: flex; animation: fadeIn .2s ease-out both; }
.modal-bg.closing { animation: fadeOut .16s ease-in both; pointer-events: none; }
@keyframes fadeOut { to { opacity: 0; } }
.modal { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-2); padding: 22px 24px; width: min(440px, 100%); max-height: calc(100% - 32px); overflow: auto; animation: popIn .28s var(--ease) both; }
.modal h2 { margin: 0; font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.modal p { margin: 8px 0; color: var(--text-2); }
.modal .muted { color: var(--muted); }
.modal .fine { font-size: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0; }
.field > span { color: var(--muted); }
.field small { color: var(--faint); font-size: 11.5px; }
.seg { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; padding: 3px; border-radius: 10px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; transition: background .15s, color .15s, box-shadow .15s; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-1); }
.field input { font: inherit; width: 150px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); }
.field input::placeholder { color: var(--faint); }
.costs { width: 100%; border-collapse: collapse; margin: 10px 0; }
.costs td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.score { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.score:last-child { border: 0; }
.score .ava { width: 38px; height: 38px; }
.score .pts { font-size: 24px; font-weight: 600; }
.practice { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 6px 10px; border-radius: 8px; background: var(--panel-2); color: var(--muted); font-size: 12.5px; }
kbd { font: 500 11.5px Inter, sans-serif; padding: 1px 6px; border-radius: 5px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 0 var(--line-2); white-space: nowrap; }

/* ---------- start screen ---------- */
.home { position: fixed; inset: 0; z-index: 25; display: none; overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(1200px 700px at 20% 0%, #dcebf7 0%, rgba(220,235,247,0) 60%), radial-gradient(900px 600px at 100% 100%, #e8efe0 0%, rgba(232,239,224,0) 55%), var(--page); }
.home.show { display: block; animation: fadeIn .25s ease-out both; }
.home.hiding { animation: fadeOut .2s ease-in both; pointer-events: none; }
.home-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px 20px calc(32px + env(safe-area-inset-bottom)); }
.home-card { width: min(1040px, 100%); min-height: min(780px, calc(100vh - 64px)); min-height: min(780px, calc(100dvh - 64px)); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--panel); border-radius: 22px;
  box-shadow: 0 24px 64px rgba(16,24,40,.14), 0 2px 8px rgba(16,24,40,.06); overflow: hidden; animation: popIn .4s var(--ease) both; }
.home-intro { position: relative; display: flex; flex-direction: column; padding: 34px 36px 26px; background: linear-gradient(165deg, #eaf3fb 0%, #f5f8fb 55%, #f9fafb 100%); border-right: 1px solid var(--line); }
.home-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.home-brand .vs { color: var(--muted); font-weight: 500; }
.home-intro h1 { margin: 22px 0 12px; font-size: 32px; line-height: 1.12; font-weight: 700; letter-spacing: -.02em; }
.home-intro p { margin: 0 0 10px; color: var(--text-2); font-size: 15px; line-height: 1.55; max-width: 460px; }
.home-art { position: relative; flex: 1 1 0; min-height: 150px; margin: 10px 0 8px; }
.home-art svg { position: absolute; inset: 0; margin: auto; width: 100%; height: 100%; max-width: 330px; max-height: 308px; overflow: visible; }
.home-art .float { animation: float 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes float { 50% { transform: translateY(-5px); } }
.home-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--faint); font-size: 12px; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; }
.home-setup { padding: 32px 36px 28px; display: flex; flex-direction: column; justify-content: center; }
.home-setup h2 { margin: 0 0 14px; font-size: 20px; font-weight: 600; }
.home-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.home-label small { color: var(--faint); font-weight: 400; }
.ptiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 0 18px; }
.ptile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 12px 11px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--panel);
  cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s, background .15s; }
.ptile .faces { display: flex; align-items: center; gap: 2px; height: 26px; max-width: 100%; }
.ptile .faces svg { flex: 0 1 auto; min-width: 0; }
.ptile .faces i { font-style: normal; color: var(--faint); font-size: 11px; font-weight: 600; margin: 0 3px; }
.ptile b { font-size: 15px; font-weight: 600; }
.ptile.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.home-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.home-more { margin: 2px 0 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.home-more summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 6px; }
.home-more summary::-webkit-details-marker { display: none; }
.home-more summary::before { content: "›"; display: inline-block; font-size: 16px; line-height: 1; transition: transform .15s; }
.home-more[open] summary::before { transform: rotate(90deg); }
.home-more[open] summary { margin-bottom: 12px; }
.home-more input[type=text], .home-more input:not([type]) , #home-seed { font: inherit; width: 150px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); }
.btn.big { height: 48px; font-size: 16px; border-radius: 12px; justify-content: center; margin-top: 6px; }
.home-record { margin-top: 12px; text-align: center; color: var(--muted); font-size: 12.5px; min-height: 17px; }
.home-resume { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 0 22px; border-radius: 14px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.home-resume .txt { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.home-resume .txt b { display: block; color: var(--text); font-size: 14px; font-weight: 600; }

/* ---------- hover, only where a pointer can hover (no sticky hover on touch) ---------- */
@media (hover: hover) {
  .icon-btn:hover { background: var(--panel); border-color: var(--line); }
  .spot:hover .dot { transform: scale(1.3); }
  .edge:hover .line { animation: none; opacity: 1; stroke-width: 6; }
  .hexsel:hover .ring { animation: none; opacity: 1; fill: rgba(255,255,255,.22); }
  .btn:hover:not(:disabled) { background: var(--panel-2); }
  .btn.primary:hover:not(:disabled) { background: #275fbb; }
  .btn.good:hover:not(:disabled) { background: #278a4b; }
  .stack.click:hover { transform: translateY(-4px); }
  .stack.click:hover::after { opacity: 1; }
  .act:hover:not(:disabled) { border-color: var(--line-2); background: var(--panel-2); }
  .card.pick:hover { transform: translateY(-3px); }
  .seg button:hover:not(.on) { color: var(--text); }
  .ptile:hover:not(.on) { border-color: #b9c3cf; }
  .linkish:hover { text-decoration: underline; }
}

/* ---------- smaller screens ---------- */
@media (max-height: 760px) and (min-width: 1181px) {
  :root { --cw: 52px; --ch: 74px; --fan: 11px; }
  #hand { height: 104px; } .act { height: 62px; width: 62px; } .act .ic svg { width: 24px; height: 24px; }
  .prow { padding: 9px 12px; } .prow .ava { width: 40px; height: 40px; }
}
@media (max-width: 1180px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto;
    grid-template-areas: "rail rail" "stage stage" "bottom bottom" "side side";
    padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  #rail { flex-direction: row; padding: 0; }
  #rail .brand { margin: 0 auto 0 4px; }
  #rail .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
  #rail .brand-text b { font-size: 15px; font-weight: 600; }
  #rail .brand-text span { font-size: 12px; color: var(--muted); }
  #stage { height: min(78vw, 72vh); min-height: 320px; }
  #side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  #logcard { height: 360px; }
}
@media (max-width: 860px) {
  .home-card { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .home-intro { border-right: 0; border-bottom: 1px solid var(--line); padding: 26px 22px 18px; }
  .home-intro h1 { font-size: 26px; margin-top: 16px; }
  .home-art { flex: none; min-height: 0; margin: 4px 0 8px; display: grid; place-items: center; }
  .home-art svg { position: static; margin: 0; width: min(70%, 240px); height: auto; max-height: none; }
  .home-setup { padding: 22px; }
}
@media (max-width: 760px) {
  :root { --cw: 54px; --ch: 76px; --fan: 11px; }
  #app { padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); gap: 8px; }
  #stage { height: min(98vw, 66vh); min-height: 300px; }
  #bottom { flex-direction: column; gap: 8px; }
  #controls { order: -1; }
  #buttons { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .act { width: auto; height: 62px; }
  .act.wide { grid-column: 1 / -1; min-width: 0; }
  .act .lbl { font-size: 10.5px; }
  .act .ic svg { width: 24px; height: 24px; }
  .act .n { top: 3px; right: 5px; font-size: 10px; }
  #hand { height: 110px; }
  #side { grid-template-columns: minmax(0, 1fr); }
  #seats { order: -1; }
  #logcard { height: 320px; }
  #overlay { position: fixed; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); }
  .pop { min-width: 0; width: 100%; padding: 14px; max-height: calc(100vh - 24px); overflow-y: auto;
    box-shadow: var(--shadow-2), 0 0 0 100vmax rgba(20,28,38,.28); }
  .pop .row { gap: 6px; }
  .card.md { width: 40px; height: 56px; }
  .pop .swap { height: 56px; }
  #toasts { left: 8px; right: 8px; top: 8px; align-items: center; max-width: none; }
  .toast { padding: 6px 10px; font-size: 12px; white-space: normal; flex-wrap: wrap; justify-content: center; }
  .die { width: 32px; height: 32px; border-radius: 7px; } .die i { width: 6px; height: 6px; }
  #dice { right: 10px; bottom: 10px; gap: 6px; }
  .field { flex-wrap: wrap; }
  .modal { padding: 18px; }
  .home-wrap { padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); }
  .home .home-row .seg { flex: 1 1 100%; flex-wrap: nowrap; }
  .home .seg button { flex: 1 1 auto; padding: 6px 4px; }
  .ptiles { gap: 6px; } .ptile { padding: 10px 9px; } .ptile b { font-size: 14px; }
  .ptile .faces svg { width: 17px; height: 17px; } .ptile .faces i { margin: 0 2px; }
  .home-art { display: none; }
  .home-intro p { font-size: 14px; margin-bottom: 8px; }
  .home-intro h1 { font-size: 24px; margin: 14px 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
