.motion-controls { display: flex; flex-wrap: wrap; gap: 1rem; }
.motion-controls label { display: flex; flex-direction: row; align-items: center; }
.motion-controls input { min-height: 24px; width: 24px; }
#motion-status { min-height: 1.4em; color: #95f5cf; }
.event-emphasis { outline: 3px solid #f6d36b; outline-offset: -3px; }
.event-traveller { position: fixed; top: 0; left: 0; margin: -12px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #07151b; background: #f6d36b; font-weight: 800; pointer-events: none; z-index: 10; }
@media (prefers-reduced-motion: reduce) { .event-traveller { display: none; } }

/* --- Cabin-game animation pass: token travel, buildings, dice, intro --- */
.event-traveller { border: 2px solid #fff; box-sizing: border-box; box-shadow: 0 3px 8px rgba(0,0,0,.6); }
#court .player-token.token-in-flight { opacity: 0; }
.tokens { position: relative; z-index: 1; }

.landed-pulse { animation: landedPulse .7s ease-out; }
@keyframes landedPulse {
  0% { box-shadow: 0 0 0 0 rgba(246,211,107,.85), inset 0 0 6px rgba(246,211,107,.6); }
  100% { box-shadow: 0 0 0 16px rgba(246,211,107,0), inset 0 0 0 rgba(246,211,107,0); }
}

body.board-page #court .space.is-here { animation: hereGlow 1.5s ease-in-out infinite; }
@keyframes hereGlow {
  0%, 100% { box-shadow: inset 0 0 2px rgba(149,245,207,.15), 0 0 2px rgba(149,245,207,.2); }
  50% { box-shadow: inset 0 0 10px rgba(149,245,207,.45), 0 0 13px rgba(149,245,207,.65); }
}

.bought-flash { animation: boughtFlash .9s ease-out; }
@keyframes boughtFlash {
  0% { background-color: #2e6b52; }
  100% { background-color: #10242c; }
}

/* Buildings sit at the foot of an upgraded space and rise when they appear. */
body.board-page #court .space { position: relative; }
.building { position: absolute; right: .35cqw; bottom: .3cqw; width: 1.9cqw; min-width: 11px; border-radius: 2px 2px 0 0; background: linear-gradient(#415e6b, #22333b); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); transform-origin: 50% 100%; }
.building::before { content: ''; position: absolute; left: 24%; right: 24%; top: 20%; bottom: 14%; background: repeating-linear-gradient(to top, #ffd978 0 .26cqw, transparent .26cqw, transparent .54cqw); opacity: .9; }
.building.lvl-1 { height: 1.2cqw; min-height: 8px; }
.building.lvl-2 { height: 1.7cqw; min-height: 11px; }
.building.lvl-3 { height: 2.25cqw; min-height: 14px; }
.building.lvl-4 { height: 2.9cqw; min-height: 18px; }
.building.lvl-4::after { content: ''; position: absolute; left: 0; right: 0; top: -.34cqw; height: .34cqw; min-height: 3px; background: #f6d36b; border-radius: 2px 2px 0 0; }
.building-rise { animation: buildingRise .7s cubic-bezier(.2,.9,.3,1) both; }
@keyframes buildingRise {
  0% { transform: scaleY(0) translateY(30%); opacity: 0; }
  55% { transform: scaleY(1.14) translateY(-2%); opacity: 1; }
  78% { transform: scaleY(.95) translateY(0); }
  100% { transform: scaleY(1) translateY(0); opacity: 1; }
}

/* Dice faces with pips; the pair tumbles whenever the roll changes. */
#dice { display: flex; gap: .55rem; justify-content: center; align-items: center; width: fit-content; margin-inline: auto; }
#dice:empty { display: none; }
.die { width: 3.8cqw; height: 3.8cqw; min-width: 28px; min-height: 28px; box-sizing: border-box; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: .5cqw; border-radius: 18%; background: linear-gradient(#ffffff, #d9e7e2); box-shadow: 0 2px 7px rgba(0,0,0,.55); }
.die .pip { width: 64%; height: 64%; margin: auto; border-radius: 50%; }
.die .pip.on { background: #10242c; }
#dice.tumbling .die { animation: dieTumble .65s cubic-bezier(.3,.7,.4,1); }
#dice.tumbling .die:nth-child(2) { animation-delay: .08s; }
@keyframes dieTumble {
  0% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-16deg) translateY(-38%); }
  55% { transform: rotate(11deg) translateY(5%); }
  80% { transform: rotate(-6deg) translateY(-10%); }
  100% { transform: rotate(0deg) translateY(0); }
}

/* Intro splash: title over the board, then a perimeter sweep of squares. */
#intro { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; text-align: center; background: radial-gradient(ellipse at center, rgba(12,29,36,.86), rgba(7,21,27,.97)); opacity: 1; transition: opacity .5s ease; cursor: pointer; }
#intro[hidden] { display: none; }
#intro.intro-out { opacity: 0; pointer-events: none; }
.intro-card { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 2rem; }
.intro-eyebrow { margin: 0; letter-spacing: .3em; text-transform: uppercase; font-size: clamp(.7rem, 2.2vw, 1rem); color: #95f5cf; }
.intro-title { margin: 0; font-size: clamp(2.6rem, 11vw, 7rem); line-height: 1; font-weight: 900; letter-spacing: .05em; color: #edf9f6; text-shadow: 0 0 34px rgba(149,245,207,.45); animation: introTitle .7s cubic-bezier(.2,.9,.3,1.15) both; }
@keyframes introTitle { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.intro-room { margin: 0; font-size: clamp(1rem, 3vw, 1.5rem); font-weight: 700; color: #f6d36b; }
.intro-room:empty { display: none; }
.intro-skip { margin: 0; font-size: .85rem; color: #c5ddd6; opacity: .75; }
#court.intro-sweep .space { animation: cellReveal .45s ease both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes cellReveal { from { opacity: .08; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .landed-pulse, .bought-flash, .building-rise, #dice.tumbling .die, #court.intro-sweep .space, .intro-title { animation: none !important; }
  body.board-page #court .space.is-here { animation: none !important; }
  #intro { display: none !important; }
}

/* Keep the public board square at every width; phones use /play. */
body.board-page main { max-width: 100%; padding: .6rem; gap: .35rem; align-items: center; }
body.board-page .eyebrow { margin: 0; }
body.board-page h1 { font-size: 1rem; }
body.board-page #code-entry { flex-direction: row; align-items: end; }
body.board-page.has-code #code-entry, body.board-page.has-code .motion-controls, body.board-page.has-code > main > .eyebrow { display: none; }
body.board-page #motion-status:empty { display: none; }
body.board-page #stage { display: grid; grid-template-columns: repeat(11,minmax(0,1fr)); grid-template-rows: repeat(11,minmax(0,1fr)); width: min(96vw,calc(100svh - 5rem)); aspect-ratio: 1; gap: 0; container-type: inline-size; }
body.board-page #court { grid-area: 1/1/12/12; display: grid; grid-template-columns: repeat(11,minmax(0,1fr)); grid-template-rows: repeat(11,minmax(0,1fr)); gap: 2px; width: 100%; min-height: 0; }
body.board-page #court .space { min-width: 0; min-height: 0; padding: .3cqw; border-radius: 3px; overflow: hidden; border-top-width: .45cqw; }
body.board-page #court .space strong { font-size: clamp(6px,1.25cqw,16px); line-height: 1.08; overflow-wrap: anywhere; }
body.board-page #court .space > span { font-size: clamp(5px,1.02cqw,13px); line-height: 1.1; }
body.board-page #readout { grid-area: 2/2/11/11; margin: .65cqw; min-height: 0; overflow: hidden; display:flex; flex-direction:column; justify-content:center; gap:1cqw; padding:2cqw; text-align:center; font-size:clamp(8px,1.6cqw,20px); border:1px solid #42626b; background:radial-gradient(ellipse at center,#183630,#0c1d24); }
body.board-page #readout #turn { font-size:clamp(10px,2.7cqw,34px); font-weight:800; color:#95f5cf; }
body.board-page #faces { grid-template-columns:repeat(4,minmax(0,1fr)); gap:.8cqw; }
body.board-page #faces figure { padding:.5cqw .4cqw 1cqw; }
body.board-page #faces img { height:11cqw; max-height:11cqw; width:100%; object-fit:contain; }
body.board-page #faces figcaption { font-size:clamp(7px,1.5cqw,18px); margin:.5cqw 0 0; }
body.board-page #faces figcaption span { font-size:clamp(6px,1.2cqw,15px); }
body.board-page #last-move { font-weight:700; }
body.board-page #chatter { color:#ffd978; font-style:italic; min-height:0; }
body.board-page #chatter:empty, body.board-page #readout p:empty { display:none; }
body.board-page #scores { display:flex; flex-wrap:wrap; justify-content:center; list-style:none; padding:0; gap:.6cqw 1.8cqw; font-size:clamp(7px,1.25cqw,17px); }
body.board-page #scores li { max-width:31%; }
body.board-page #spot { font-size:clamp(7px,1.3cqw,16px); }
body.board-page.is-waiting #spot, body.board-page.is-waiting #scores, body.board-page.is-waiting #dice { display:none; }
.tokens { display:flex; flex-wrap:wrap; gap:1px; margin-top:.3cqw; }
#court .player-token { display:grid; place-items:center; width:1.9cqw; height:1.9cqw; min-width:8px; min-height:8px; border-radius:50%; color:#07151b; background:var(--token,#fff); font-size:clamp(6px,1.25cqw,15px); font-weight:900; border:1px solid #fff; box-shadow:0 1px 3px #000; }
.game-history { width:min(94vw,70rem); color:#c5ddd6; font-size:.8rem; }

body.board-page #stage { align-items:stretch; }
body.board-page #court { height:100%; align-self:stretch; }
body.board-page #readout { align-self:stretch; }

body.board-page.has-code #motion-status { display:none; }
