/* Moon garden: one compact, responsive board; quiet chrome and luminous play. */
:root {
  color-scheme: light;
  --ink: #433671; --muted: #756694; --purple: #936de0; --pink: #eea6db;
  --line: #ffffffbd; --surface: #faf5ffed; --shadow: #4d367c25;
  --row: clamp(56px, 14vw, 62px); --gap: clamp(3px, .9vw, 5px);
  --die: 62px; --half-die: 31px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { min-width: 280px; background: #d6cef0; }
body { margin: 0; min-height: 100svh; color: var(--ink); font: 500 14px/1.5 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; -webkit-font-smoothing: antialiased; }
body::before { content: ''; position: fixed; inset: 0; z-index: -2; background: #d6cef0 url('/assets/moon-garden.webp') center 43% / cover no-repeat; }
body::after { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(ellipse at 50% 60%, #dcd0ff12, #b6b4ec10); }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid #8962ce; outline-offset: 3px; }
button:disabled { cursor: default; opacity: .48; }
button { -webkit-appearance: none; }
#app { position: relative; width: min(100%, 560px); margin: auto; min-height: 100svh; padding: max(12px, env(safe-area-inset-top)) 12px max(20px, env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
.view { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; gap: 7px; align-items: center; min-width: 0; }
.brand h1 { margin: 0; color: #fff; font-family: 'Songti SC', 'Noto Serif CJK SC', serif; font-size: clamp(20px, 5.6vw, 25px); font-weight: 800; letter-spacing: 1px; text-shadow: 0 2px 8px #4c397177, 0 0 16px #eacfff; white-space: nowrap; }
.brand-moon { color: #ffe6f6; font-size: 33px; line-height: 1; text-shadow: 0 0 12px #ffffffbb; }
.tb-right { display: flex; gap: 5px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 36px; padding: 5px 10px; border: 1px solid #ffffffe0; border-radius: 14px; background: #f9f3ffd9; box-shadow: inset 0 1px 2px #fff, 0 3px 10px #7252ae20; color: #625084; font-size: 12px; font-weight: 650; }
.icon-btn:active { transform: translateY(1px); }
.close-btn { width: 34px; padding: 0; border-radius: 50%; font-size: 23px; }
.room-bar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 10px; }
.room-meta { display: flex; flex-direction: column; gap: 1px; }
.room-meta .ttl { font-size: 9px; opacity: .85; }
.room-code { color: #fff; font-size: 11px; text-shadow: 0 1px 5px #4d346c; }
#g-code { font-size: 13px; letter-spacing: 1.6px; margin-left: 5px; font-weight: 700; }
.people-btn { min-height: 32px; padding: 3px 12px; background: #f8f2ffdf; }
.people-btn b { font-size: 12px; font-variant-numeric: tabular-nums; }
.subbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.pool-chip { display: flex; align-items: baseline; gap: 5px; border: 1px solid #ffffffe0; border-radius: 99px; padding: 4px 13px; color: #594082; background: linear-gradient(130deg,#fff7eae8,#f5e8ffe8); box-shadow: 0 0 15px #fff4bf40; font-size: 12px; }
.pool-chip > span:first-child { color: #d8a04f; font-size: 16px; }
.pool-chip b { font-size: 18px; font-variant-numeric: tabular-nums; }
.ttl { color: #fff; font-size: 11px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 5px #604082; padding-right: 5px; }
.board-wrap { padding: 9px; border: 1px solid #ffffff9c; border-radius: 25px; background: linear-gradient(150deg,#e8dcff45,#f2dfff24); box-shadow: inset 0 0 22px #ffffff35, 0 8px 30px #5d428524, 0 0 22px #e9d6ff6b; }
.board { position: relative; display: grid; grid-template-columns: repeat(8, minmax(0,1fr)); grid-template-rows: repeat(6, var(--row)); gap: var(--gap); isolation: isolate; }
.board-route { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; z-index: -1; pointer-events: none; }
.board-route polyline { fill: none; stroke: #fff5ffbb; stroke-width: 2px; stroke-dasharray: 2 5; stroke-linecap: round; filter: drop-shadow(0 0 3px #eccfff); }
.cell { width: 100%; height: var(--row); min-width: 0; justify-self: center; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 3px; border: 1px solid #fffffff0; border-radius: 15px; background: linear-gradient(145deg,#fffafdF2,#e4dff8ed 55%,#fbe9f4ee); box-shadow: inset 0 1px 4px #fff, inset 0 -3px 5px #bda4e324, 0 3px 5px #6550821c, 0 0 8px #fff5ff50; transition: border-color .2s, box-shadow .2s; }
.cell:hover { border-color: #fff; box-shadow: 0 0 14px #fff4ffcc; }
.cell:active { scale: .95; }
.seq { font-family: Georgia, 'Songti SC', serif; font-size: 20px; line-height: 1; color: #504076; }
.tile-kind { position: absolute; right: 2px; top: 2px; display: grid; place-items: center; min-width: 14px; height: 14px; padding: 0 2px; border-radius: 5px; background: #e4d9f5; color: #82619d; font: 650 9px/1 sans-serif; }
.t-PENALTY .tile-kind { background: #f1daed; color: #a55890; }
.t-ADV .tile-kind { background: #e5d5fa; color: #8f5bb9; }
.t-REWARD .tile-kind, .t-END .tile-kind { background: #f9ebc9; color: #a87b30; }
.t-MOVE_FORWARD .tile-kind, .t-SAFE .tile-kind { background: #d3eee7; color: #448b80; }
.t-DEDUCT .tile-kind, .t-MOVE_BACK .tile-kind { background: #f6dfdf; color: #b16972; }
.t-TELEPORT .tile-kind { background: #dbe4fa; color: #647ab6; }
.t-START { background: linear-gradient(140deg,#fff4fd,#f5cce9); }
.t-END { background: linear-gradient(140deg,#fffff2,#fbe7c8); }
.cell.has-names { background: linear-gradient(150deg,#efe0ff,#ba9eeb); border-color: #fff; box-shadow: 0 0 12px #e8c4ff, inset 0 0 6px #ffffff9e; }
.cell.has-names .seq { transform: translateY(-6px); }

.cell .names { position: absolute; bottom: 3px; left: 1px; right: 1px; display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; }
.who { display: flex; align-items: center; justify-content: center; gap: 2px; font-size: 9px; line-height: 13px; font-weight: 650; padding: 0 3px; background: #fff9ffed; border-radius: 8px; color: #584276; white-space: nowrap; max-width: 100%; }
.names:has(.who:nth-child(3)) .who { font-size: 8px; gap: 1px; padding: 0 1px; line-height: 11px; }
.names:has(.who:nth-child(3)) .pawn { width: 3px; height: 3px; }
.pawn { display: inline-block; flex: none; width: 5px; height: 5px; border-radius: 50%; box-shadow: 0 0 4px currentColor; }
.cell.landed { border-color: #f9e0ff; box-shadow: 0 0 15px #edc6ff; }
.hop { position: absolute; z-index: 20; display: flex; align-items: center; gap: 4px; padding: 4px 7px; background: #fff9ff; border: 1px solid #fff; border-radius: 12px; color: #654089; font-size: 11px; font-weight: 750; box-shadow: 0 0 15px #f7d5ff, 0 5px 10px #75579644; transform: translate(-50%,-50%); pointer-events: none; white-space: nowrap; }
.hop::after { content: '✧'; position: absolute; left: -8px; bottom: -8px; font-size: 14px; color: #fff6c5; text-shadow: 0 0 5px #fff; }
.stage-center { grid-area: 3 / 2 / 6 / 8; position: relative; display: flex; flex-direction: column; align-items: stretch; min-height: 0; min-width: 0; z-index: 3; padding: 15px 9px 10px; border-radius: 28px; background: radial-gradient(ellipse at center,#fff4ff92,#e7deff50 65%,#e7deff15); }
.stage-head { flex: none; text-align: center; line-height: 1.4; }
.stage-label { display: block; color: #6e578f; font-size: 11px; font-weight: 600; text-shadow: 0 1px 4px #fff; }
.turn-name { display: block; font-family: 'Songti SC', serif; font-size: 24px; line-height: 1.3; color: #5a3d87; margin-top: 4px; letter-spacing: 3px; text-shadow: 0 0 10px #fff, 0 1px 2px #fff; }
.stage-main { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 5px 0; }
.stage-foot { flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 7px; text-align: center; }
.stage-note { font-size: 11px; color: #71578e; text-shadow: 0 1px 5px #fff; }
.btn { min-height: 42px; border: 1px solid #fff; border-radius: 99px; padding: 9px 14px; font-weight: 650; font-size: 13px; box-shadow: 0 3px 8px #7b589226, inset 0 1px 1px #ffffffad; background: #fbf5ff; transition: transform .12s, filter .12s; }
.btn:active { transform: translateY(2px); }
.btn.primary, .btn.good { color: #fff; border-color: #fff7ff; background: linear-gradient(115deg,#c295ea,#a076d9 55%,#df99d5); box-shadow: inset 0 1px 3px #fff9, 0 0 0 2px #e3c7ff80, 0 0 15px #d5a5f0bb, 0 4px 8px #70518c30; text-shadow: 0 1px 2px #7047905c; }
.btn.big { width: 100%; font-size: 15px; }
.btn.big span { margin-left: 5px; color: #ffeccb; }
.btn.secondary, .btn.ghost, .btn.bad { background: #fff7ffeb; color: #75558d; }
.btn.small-btn { min-height: 38px; white-space: nowrap; padding: 6px 12px; font-size: 12px; }
.timer-pill { display: flex; align-items: baseline; justify-content: center; gap: 3px; color: #73568f; font-size: 11px; line-height: 1.2; text-shadow: 0 1px 3px #fff; }
.timer-num { font-variant-numeric: tabular-nums; font-size: 12px; }
.timer-pill.warn { color: #a64471; }
.stage-btns { display: flex; gap: 6px; }
.stage-btns .btn { flex: 1; padding: 8px 3px; min-width: 0; white-space: nowrap; font-size: 12px; }
.stage-center:is([data-phase="AWAIT_CHOICE"],[data-phase="PUNISH_EXECUTING"],[data-phase="DOUBLE_WINDOW"]) { padding: 12px 10px 10px; background: linear-gradient(160deg,#fff7ffcc,#eadffc9e); border: 1px solid #ffffff80; }
.task-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 0 10px; border-bottom: 1px solid #b9a1cf33; text-align: left; }
.task-heading strong { font-size: 17px; letter-spacing: 1px; color: #624281; }
.task-heading > span { font-size: 10px; color: #8a709d; }
.task-card { display: flex; flex-direction: column; width: 100%; min-height: 0; max-height: 100%; overflow: hidden; padding: 14px 1px; }
.task-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #c8a6df transparent; }
.task-copy { font-size: 17px; line-height: 1.8; font-weight: 650; text-align: center; color: #53366f; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-quantity { font-size: 1.35em; line-height: 1; color: #9a54bd; font-weight: 800; font-variant-numeric: tabular-nums; }
.task-amount { text-align: center; color: #9a54bd; font-size: 18px; line-height: 1.4; font-weight: 750; margin-top: 8px; }
.doublers { flex: none; max-height: 70px; overflow-y: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; margin-top: 17px; }
.doublers-label { font-size: 10px; color: #8b759b; margin-right: 2px; }
.doubler-name { font-size: 11px; line-height: 1.5; color: #9861ae; background: #f1dff9; border: 1px solid #e6cbef; padding: 2px 7px; border-radius: 8px; }
.lobby-art { width: 88px; height: 88px; flex: none; }
.lobby-art .role-portrait { height: 100%; margin: 0; filter: drop-shadow(0 0 9px #fff0fc); }
/* Rigid six-face die. Translation and tumbling are independently animated. */
.dice-scene { width: 150px; height: 135px; position: relative; display: grid; place-items: center; perspective: 700px; }
.die-toss { position: relative; transform-style: preserve-3d; margin-top: -10px; z-index: 2; }
.die3d { width: var(--die); height: var(--die); perspective: 550px; }
.cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; will-change: transform; }
.face { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); padding: 10px; border: 1px solid #ffffffed; border-radius: 9px; backface-visibility: hidden; background: linear-gradient(135deg,#fffefa,#eee6fa); box-shadow: inset 0 0 8px #c7b4df58; }
.face .fp { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 65% 70%,#b292df,#7954b0); box-shadow: inset 1px 1px 2px #603b914f, 0 1px 0 #fff; align-self: center; justify-self: center; }
.f-front { transform: translateZ(var(--half-die)); }
.f-back { transform: rotateY(180deg) translateZ(var(--half-die)); background: #e5d9f3; }
.f-right { transform: rotateY(90deg) translateZ(var(--half-die)); background: linear-gradient(135deg,#eee4f8,#cbb4e6); }
.f-left { transform: rotateY(-90deg) translateZ(var(--half-die)); background: #e4d6f3; }
.f-top { transform: rotateX(90deg) translateZ(var(--half-die)); background: #fffafc; }
.f-bottom { transform: rotateX(-90deg) translateZ(var(--half-die)); background: #d4bde9; }
.magic-ring { position: absolute; width: 142px; height: 56px; left: 4px; bottom: 4px; border: 1px solid #fff3db; border-radius: 50%; box-shadow: 0 0 14px #ffdcff, inset 0 0 12px #fbe1ff; transform: rotate(-5deg); }
.magic-ring::before { content: ''; position: absolute; inset: 8px -8px; border: 1px solid #fff2fcb0; border-radius: 50%; transform: rotate(9deg); }
.magic-ring::after { content: '✦'; position: absolute; right: 4px; top: -12px; color: #fff0c6; text-shadow: 0 0 9px #fff; font-size: 22px; }
.die-shadow { position: absolute; width: 75px; height: 19px; bottom: 24px; left: calc(50% - 37.5px); background: radial-gradient(ellipse,#7850a760,transparent 70%); filter: blur(2px); opacity: .35; }
.dice-result { display: block; font-size: 18px; color: #64428a; text-shadow: 0 0 8px #fff; font-weight: 750; animation: result-in .2s both; animation-delay: var(--reveal-delay,0ms); }
@keyframes result-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
/* A single people menu combines names and current scores. */
.float-panel { position: absolute; right: 12px; top: 92px; z-index: 40; width: min(224px,calc(100% - 24px)); max-height: min(440px,65svh); overflow-y: auto; padding: 17px; border: 1px solid #fff; border-radius: 21px; background: #fbf6fff5; backdrop-filter: blur(18px); box-shadow: 0 12px 40px #4c346a40, 0 0 15px #eed5ff; }
.people-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 9px; border-bottom: 1px solid #e9dff0; }
.people-heading strong { font-size: 15px; }
.people-heading > span { font-size: 11px; color: var(--muted); }
.prow { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #eee3f6; }
.prow:last-child { border: none; padding-bottom: 0; }
.pd { width: 9px; height: 9px; flex: none; border-radius: 50%; box-shadow: 0 0 6px #c8a6e5; }
.person-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name strong { font-size: 14px; }
.person-name small { font-size: 10px; color: var(--muted); }
.psc { color: #885bb2; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.psc small { font-size: 10px; font-weight: 400; }
/* A native modal keeps long tile text readable and focus contained. */
.tile-dialog { width: min(330px,calc(100% - 36px)); max-height: 80svh; border: 1px solid #fff; border-radius: 27px; padding: 30px 25px; color: var(--ink); background: linear-gradient(155deg,#fffaff,#eee6fa); box-shadow: 0 0 0 5px #ffffff30, 0 0 45px #d3aceaad; overflow-y: auto; }
.tile-dialog::backdrop { background: #34234e63; backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 10px; right: 10px; border: 0; background: transparent; font-size: 23px; width: 36px; height: 36px; }
.tile-detail-icon { font-size: 26px; color: #b58bda; text-align: center; text-shadow: 0 0 15px #e3afff; line-height: 1.3; }
.detail-label { text-align: center; font-size: 12px; color: #8b729e; margin: 6px 0 15px; }
.detail-text { font-size: 17px; font-weight: 600; line-height: 1.8; overflow-wrap: anywhere; white-space: pre-wrap; }
.detail-meta { margin-top: 17px; border-top: 1px solid #dccdec; padding-top: 13px; font-size: 12px; color: #8b6da2; }
.detail-meta:empty { display: none; }
/* Entry and seating use the same visual language. */
#view-join, #view-seat { padding: 16px 8px; }
.hero { text-align: center; padding: 42px 0 18px; }
.hero.small { padding: 20px 0 10px; }
.hero h1 { font-family: 'Songti SC',serif; font-size: 31px; letter-spacing: 3px; color: #fff; text-shadow: 0 2px 10px #685494; margin: 15px 0 8px; }
.hero.small h1 { font-size: 26px; }
.sub { color: #fff; font-size: 13px; text-shadow: 0 1px 6px #594179; margin: 0; }
.logo-dice { width: 76px; height: 76px; position: relative; margin: auto; border: 2px solid #fff; border-radius: 23px; background: linear-gradient(135deg,#fff,#e1d2f4); box-shadow: 0 6px 0 #b9a0d4, 0 0 32px #fff0fc; transform: rotate(-12deg); }
.logo-dice .pip { position: absolute; width: 12px; height: 12px; background: #aa85d3; border-radius: 50%; transform: translate(-50%,-50%); box-shadow: inset 0 2px 2px #8051a848; }
.card { margin-top: 16px; padding: 22px; background: #faf5ffeb; border: 1px solid #fff; border-radius: 25px; box-shadow: 0 10px 35px #6b4e8b24; }
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 8px; }
.inp { width: 100%; min-width: 0; border: 1px solid #ddcce9; background: #fffaff; border-radius: 13px; color: var(--ink); padding: 12px; font-size: 16px; }
.inp::placeholder { color: #bba6ce; }
.code-inp { font-size: 25px; text-align: center; letter-spacing: 8px; text-transform: uppercase; }
.err { font-size: 12px; color: #b15181; min-height: 21px; margin: 4px 0; }
.hint { font-size: 11px; color: var(--muted); text-align: center; margin: 15px 0 0; }
.nick-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.nick { flex: 1; font-size: 19px; color: #9970bd; }
.role-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; margin-bottom: 18px; }
.role-btn { padding: 12px 2px; background: #fffaff; border: 1px solid #e4d4f1; border-radius: 15px; font-size: 13px; }
.role-btn.sel { background: #eadcf8; border-color: #b389d5; box-shadow: 0 0 10px #d9b7ed; }
.r-emoji { display: block; font-size: 24px; }
.r-desc { font-size: 9px; margin-top: 4px; color: var(--muted); }
.code-chip { letter-spacing: 2px; }
#seat-back { margin-top: 9px; }
.banner { font-size: 11px; text-align: center; padding: 7px; border-radius: 10px; background: #fff6dde3; margin-bottom: 8px; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #3e2c5263; backdrop-filter: blur(6px); padding: 24px; }
.modal-card { width: min(100%,350px); border: 1px solid #fff; border-radius: 27px; background: #faf3ff; box-shadow: 0 0 35px #d9c2ec; padding: 24px; max-height: 85svh; overflow-y: auto; }
.modal-card h2 { text-align: center; font-size: 20px; margin: 0 0 15px; }
.settle-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #e8d9f0; }
.settle-row .score { margin-left: auto; font-weight: 700; color: #9970bd; }
.settle-row .rank { width: 25px; }
.settle-list { margin-bottom: 20px; }
#settle-close { margin-top: 10px; }
.mini-toast { position: fixed; bottom: max(25px,env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%,12px); z-index: 100; max-width: calc(100% - 32px); width: max-content; border-radius: 16px; background: #63487ceb; color: #fff; padding: 10px 16px; font-size: 12px; text-align: center; opacity: 0; pointer-events: none; transition: .2s; }
.mini-toast.show { opacity: 1; transform: translate(-50%,0); }
.board.flat { grid-template-rows: none; grid-auto-rows: var(--row); }
@media (max-width: 350px) {
  #app { padding-left: 8px; padding-right: 8px; }
  .board-wrap { padding: 7px; border-radius: 21px; }
  .cell { border-radius: 12px; }
  .seq { font-size: 18px; }
  .tile-kind { min-width: 12px; height: 12px; font-size: 8px; right: 1px; top: 1px; }
  .stage-center { padding: 10px 4px 7px; border-radius: 20px; }
  .turn-name { font-size: 21px; }
  .stage-head { line-height: 1.2; }
  .stage-label { font-size: 10px; }
  .stage-foot { gap: 5px; }
  .stage-center .btn.big { font-size: 13px; min-height: 39px; }
  .stage-btns .btn { font-size: 11px; min-height: 39px; }
  .dice-scene { scale: .85; }
  .task-copy { font-size: 14px; }
  .task-heading strong { font-size: 15px; }
  .task-heading > span { font-size: 9px; }
  .stage-center:is([data-phase="AWAIT_CHOICE"],[data-phase="PUNISH_EXECUTING"],[data-phase="DOUBLE_WINDOW"]) { padding: 9px 7px; }
}
@media (max-height: 720px) and (max-width: 599px) {
  .stage-center { padding-top: 9px; padding-bottom: 7px; }
  .turn-name { font-size: 20px; }
  .dice-scene { height: 110px; scale: .82; }
  .stage-foot { gap: 4px; }
}
@media (min-width: 600px) {
  #app { padding-top: 25px; }
  body::before { background-size: auto 125%; background-color: #aea5d3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .dice-result { animation: none; }
}

/* Current balance stays beside the shared pool, for every role. */
.my-score-chip { display: flex; align-items: baseline; gap: 5px; padding: 4px 12px; border: 1px solid #ffffffe0; border-radius: 99px; background: #f8eeffef; color: #765094; box-shadow: 0 0 14px #eac8ff66; font-size: 11px; white-space: nowrap; }
.my-score-chip b { font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; }
.my-score-chip.negative b { color: #b7618a; }
.score-effect { font-size: 10px; line-height: 1.5; color: #805b94; text-align: center; }
.tile-kind { min-width: 22px; white-space: nowrap; }
.cell.has-names .seq { align-self: flex-start; margin-left: 3px; font-size: 16px; }
@media (max-width: 350px) {
  .pool-chip, .my-score-chip { padding: 4px 9px; gap: 4px; }
  .tile-kind { min-width: 19px; padding: 0 2px; }
  .score-effect { font-size: 9px; }
}

/* Compact action area: three rows, with content and controls kept together. */
.board-wrap{padding:7px;border-radius:21px}
.cell{border-radius:12px;padding:3px 1px}
.cell .seq{font-size:18px;line-height:1;transform:translateY(3px)}
.tile-kind{top:3px;left:50%;right:auto;transform:translateX(-50%);height:12px;font-size:8px;background:#e4d9f58c}
.cell.has-names .seq{align-self:center;margin:0;font-size:15px;transform:translateY(-1px)}
.cell .names{bottom:2px;gap:0}
.who{font-size:8px;padding:0 1px;line-height:11px;gap:1px}
.who .pawn{width:3px;height:3px}
.names:has(.who:nth-child(2)){max-height:22px;overflow-y:auto}
.names:has(.who:nth-child(2)) .who{width:100%;font-size:8px;line-height:10px}
.cell.has-names:has(.who:nth-child(2)) .seq{transform:translateY(-7px);font-size:12px}
.stage-center,.stage-center:is([data-phase="AWAIT_CHOICE"],[data-phase="PUNISH_EXECUTING"],[data-phase="DOUBLE_WINDOW"]){padding:9px 12px;border-radius:20px}
.task-heading{padding-bottom:5px}
.task-heading strong{font-size:15px}
.task-heading>span{font-size:9px}
.stage-main{padding:3px 0}
.task-card{padding:2px 0}
.task-copy{font-size:15px;line-height:1.55}
.task-quantity{font-size:23px}
.doublers{margin-top:5px;gap:4px;max-height:34px}
.doubler-name{font-size:9px;padding:1px 6px}
.stage-foot{gap:4px;position:relative}
.stage-foot .btn,.stage-foot .btn.big{min-height:34px;padding:6px 9px;font-size:12px}
.stage-foot:has(.timer-pill) {padding-top:15px}
.stage-foot .timer-pill{position:absolute;top:0;right:2px;font-size:9px;gap:2px}
.timer-num{font-size:10px}
.score-effect{font-size:9px;line-height:1.4}
.turn-heading{display:flex;align-items:center;justify-content:space-between;gap:10px}
.turn-heading .turn-name{font-size:17px;letter-spacing:1px;margin:0;line-height:1.4}
.turn-heading .stage-label{font-size:9px}
.dice-scene{height:74px;width:110px;scale:.66;flex:none}
.lobby-art{max-height:80px}
.float-panel{padding:13px 15px;border-radius:17px}
.people-heading strong{font-size:13px}.people-heading>span{font-size:10px}
.prow{padding:9px 0;gap:8px}.person-name strong{font-size:13px}.psc{font-size:17px}
#view-seat{max-width:460px;margin:auto;padding:10px 5px}
#view-seat .card{padding:23px 18px;background:#fcf7ffeb;backdrop-filter:blur(10px)}
.role-grid{gap:9px;margin:10px 0 19px}
.role-btn{padding:10px 4px 12px;border-radius:18px;overflow:hidden;transition:transform .2s,box-shadow .2s,border-color .2s}
.role-btn.sel{border-color:#bc8fdc;background:linear-gradient(160deg,#fff9ff,#eadcf8);box-shadow:0 0 0 2px #eac8fc80,0 6px 17px #a47bd12b;transform:translateY(-3px)}
.role-portrait{display:block;width:100%;aspect-ratio:1;margin:0 auto 6px;background:url('/assets/role-portraits.webp') 0 50%/300% 100% no-repeat;max-width:100px;border-radius:50%;mask-image:radial-gradient(circle,#000 61%,transparent 72%)}
.role-portrait.spectator{background-position:50% 50%}.role-portrait.referee{background-position:100% 50%}
.r-desc{font-size:9px;margin-top:4px;white-space:nowrap}
.dream-lights{position:fixed;inset:0;pointer-events:none;overflow:hidden;z-index:0}
.dream-lights i{position:absolute;left:calc(5% + var(--i)*8%);bottom:-18px;width:calc(3px + var(--i)*.2px);height:calc(3px + var(--i)*.2px);border-radius:50%;background:#fff2ff;box-shadow:0 0 9px 3px #fbd1f696;animation:dream-rise calc(14s + var(--i)*1.2s) linear infinite;animation-delay:calc(var(--i)*-2.7s)}
.board-route polyline{animation:starlight-path 8s linear infinite}
.board-wrap{animation:moon-breathe 7s ease-in-out infinite}
@keyframes dream-rise{0%{transform:translate(0,0);opacity:0}15%{opacity:.7}70%{opacity:.4}100%{transform:translate(28px,-100svh);opacity:0}}
@keyframes starlight-path{to{stroke-dashoffset:-56}}
@keyframes moon-breathe{50%{box-shadow:inset 0 0 22px #ffffff35,0 8px 30px #5d428524,0 0 26px #e8bcff99}}
@media(max-width:350px){.stage-center,.stage-center:is([data-phase="AWAIT_CHOICE"],[data-phase="PUNISH_EXECUTING"],[data-phase="DOUBLE_WINDOW"]){padding:7px 8px}.board-wrap{padding:5px}.cell{border-radius:10px}.task-copy{font-size:13px}.task-quantity{font-size:20px}.role-grid{gap:6px}.role-btn{font-size:12px}.r-desc{font-size:8px}.tile-kind{font-size:7px;min-width:17px}.cell .seq{font-size:16px}.stage-foot .btn,.stage-foot .btn.big{min-height:32px;font-size:11px}.turn-heading .turn-name{font-size:15px}}
@media(prefers-reduced-motion:reduce){.dream-lights{display:none}.board-wrap,.board-route polyline{animation:none}.role-btn{transform:none}}
/* Whole-task repetitions stay readable inside the compact task card. */
.task-amount { font-size: 12px; line-height: 1.35; margin-top: 3px; }

/* Phone proportions are independent from the desktop board. */
@media(max-width:520px){
  :root{--gap:4px;--row:clamp(44px,calc((100svh - 174px)/8 - 4px),58px)}
  #app{padding: max(12px,env(safe-area-inset-top)) 10px max(16px,env(safe-area-inset-bottom));width:100%}
  .brand h1{font-size:23px}.brand-moon{font-size:28px}.topbar{gap:6px}
  .icon-btn{min-height:40px;font-size:12px;padding:7px 11px}.close-btn{width:36px;font-size:23px;padding:0}
  .room-bar{margin:6px 0 8px}.room-meta{gap:0}.room-meta .ttl{font-size:10px}.people-btn{min-height:36px}
  .subbar{margin-bottom:9px;gap:8px}.pool-chip,.my-score-chip{padding:5px 11px;font-size:12px}.pool-chip b,.my-score-chip b{font-size:18px}
  .board:not(.flat){grid-template-columns:repeat(7,minmax(0,1fr));grid-template-rows:repeat(8,var(--row))}
  .board-wrap{padding:6px;border-radius:20px}
  .cell{border-radius:11px}.cell .seq{font-size:18px;transform:translateY(4px)}
  .tile-kind{font-size:9px;height:14px;top:3px;padding:1px 3px}
  .who{font-size:9px;line-height:12px;padding:0 2px}.cell.has-names .seq{font-size:16px}
  .stage-center,.stage-center:is([data-phase="AWAIT_CHOICE"],[data-phase="PUNISH_EXECUTING"],[data-phase="DOUBLE_WINDOW"]){grid-area:3/2/8/7;align-self:center;width:100%;height:100%;max-height:224px;padding:10px;border-radius:20px}
  .task-heading{padding-bottom:7px}.task-heading strong{font-size:16px}.task-heading>span{font-size:10px}
  .task-copy{font-size:16px;line-height:1.6}.task-quantity{font-size:24px}.task-amount{font-size:12px;line-height:1.4}
  .doublers{margin-top:6px;max-height:38px}.doubler-name{font-size:10px;padding:1px 6px}
  .stage-foot .btn,.stage-foot .btn.big{min-height:44px;padding:9px 8px;font-size:14px}
  .stage-foot{gap:5px}.stage-foot:has(.timer-pill){padding-top:17px}.timer-num{font-size:11px}
  .score-effect{font-size:10px}.turn-heading .turn-name{font-size:18px}.turn-heading .stage-label{font-size:10px}
  .dice-scene{height:90px;scale:.78}.lobby-art{max-height:90px}
  .float-panel{top:94px;right:10px;max-height:min(440px,60svh)}
  #view-seat{padding:0;max-width:430px}.hero.small{padding-top:15px}#view-seat .card{padding:18px 15px}.role-btn{font-size:14px}.r-desc{font-size:10px}
  .inp{font-size:16px;min-height:46px}.role-grid{gap:8px}.nick-row .btn{min-height:44px}
  .tile-dialog{padding:28px 22px;max-height:calc(100dvh - 36px)}
}
@media(max-width:350px){
  #app{padding-left:8px;padding-right:8px}.board-wrap{padding:5px}.brand h1{font-size:20px}.brand-moon{font-size:25px}
  .icon-btn{padding:6px 9px}.close-btn{padding:0}.cell .seq{font-size:16px}.tile-kind{font-size:8px;padding:1px 2px}
  .stage-center,.stage-center:is([data-phase="AWAIT_CHOICE"],[data-phase="PUNISH_EXECUTING"],[data-phase="DOUBLE_WINDOW"]){padding:9px 8px}
  .task-copy{font-size:14px}.task-quantity{font-size:22px}.stage-foot .btn,.stage-foot .btn.big{font-size:12px}.task-heading strong{font-size:15px}
  .r-desc{font-size:9px}.pool-chip,.my-score-chip{font-size:11px;padding:5px 9px}
}
@media(max-height:500px) and (orientation:landscape){#app{padding-top:10px}.hero{padding-top:10px}.hero.small{padding-top:4px}}

/* The measured board size controls both route placement and cell dimensions. */
.board:not(.flat){grid-template-columns:repeat(var(--board-columns,8),minmax(0,1fr));grid-template-rows:repeat(var(--board-rows,6),var(--row))}
.board:is([data-columns="6"],[data-columns="7"]) .stage-center{align-self:center;height:100%;max-height:224px}
.board[data-columns="6"] .stage-center{grid-area:3/2/9/6}
.board[data-columns="7"] .stage-center{grid-area:3/2/8/7}
.board[data-columns="8"] .stage-center{grid-area:3/2/6/8}
.board[data-columns="7"]:not(.flat) #cell-30{grid-area:3/7/5/8!important;height:100%;border-radius:14px}
.board[data-columns="7"]:not(.flat) #cell-30 .tile-kind{top:10px}
.board[data-columns="7"]:not(.flat) #cell-30 .seq{font-size:24px}

/* Standard board keeps the same 42-cell route on every screen. */
.board[data-standard="true"] .stage-center{grid-area:3/2/9/6;align-self:center;height:100%;max-height:224px}

/* One clear invitation action, with room for the keyboard on short screens. */
#view-join{max-width:420px;margin:0 auto;padding:clamp(28px,8svh,72px) 6px 24px}
.join-heading{text-align:center;color:white;text-shadow:0 2px 15px #534273}
.join-moon{display:block;font-size:48px;line-height:1;color:#fff0d8}
.join-heading p{font-size:12px;letter-spacing:3px;margin:14px 0 5px}
.join-heading h1{font-family:'Songti SC',serif;font-size:34px;letter-spacing:3px;margin:0}
.join-card{position:relative;margin-top:64px;padding:51px 24px 26px;background:linear-gradient(155deg,#fffafff5,#eee1f8ef);border:1px solid white;border-radius:28px;box-shadow:0 16px 45px #60457630,0 0 24px #e9c5ef88}
.join-character{position:absolute;top:-48px;left:calc(50% - 46px);width:92px;height:92px;padding:4px;border-radius:50%;background:#f9ecff;box-shadow:0 0 18px #fff2fa}
.join-character .role-portrait{margin:0}
.join-card h2{text-align:center;font-size:18px;margin:0 0 22px;color:#634784}
.join-card .lbl{font-size:12px;margin-bottom:9px}.join-code-row{display:flex;gap:8px;align-items:stretch}
.join-code-row .code-inp{flex:1;width:0;min-height:52px;font-family:inherit;font-size:22px;letter-spacing:3px;padding:12px 6px}
.join-code-row .code-inp::placeholder{font-size:13px;letter-spacing:0}.join-code-row .btn{flex:none;border-radius:14px;padding:10px 14px;min-width:64px}
.join-card .err{min-height:27px;margin:7px 0;font-size:12px}.join-card #join-btn{min-height:48px;font-size:16px}
@media(max-height:650px){#view-join{padding-top:16px}.join-moon{font-size:35px}.join-heading h1{font-size:29px}.join-card{margin-top:55px;padding-bottom:22px}}

.task-heading > strong{min-width:0;overflow-wrap:anywhere}
.task-meta{display:flex;flex-direction:column;align-items:flex-end;gap:3px;flex-shrink:0}
.turn-dice{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border-radius:8px;background:#ffffff80;color:#795394;font-size:10px;white-space:nowrap}
.turn-dice b{font-size:13px;color:#8b4cc1}
