/* The board owns its HUD; the surrounding page owns reserved advertising. */
body.compact-board { --ad-separation: 150px; --hud-ink: #f3ead7; --hud-muted: #c5b798; }
body.compact-board .play-screen { height: auto; min-height: 100svh; overflow: visible; }
body.compact-board .game-layout {
  width: min(1160px, 100%); margin: 0 auto; padding: 16px 24px 24px;
  grid-template-columns: minmax(0, 640px) 300px; grid-template-rows: auto;
  column-gap: var(--ad-separation); align-items: start; justify-content: center; flex: 1;
}
body.compact-board .stage { width: min(100%, max(320px, calc(100svh - 320px))); max-width: 640px; justify-self: center; }
body.compact-board .stage-head { min-height: 42px; padding: 0 0 8px; gap: 8px; }
body.compact-board .stage-title { display: flex; min-width: 0; align-items: center; gap: 9px; }
body.compact-board #game-kicker { display: none; }
body.compact-board .stage h1 { margin: 0; font-size: clamp(21px, 2.5vw, 29px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#title-options { flex: none; }
.board-size-control { display: flex; }
.board-size-control select { font: inherit; font-size: 15px; font-weight: 600; color: var(--hud-ink); background: #30251b; border: 1px solid #806443; border-radius: 5px; min-height: 34px; padding: 4px 7px; cursor: pointer; }
.board-size-control select:disabled { cursor: default; opacity: .65; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
body.compact-board #help-button { display: block; flex: none; margin: 0; min-height: 34px; padding: 5px 9px; color: var(--hud-muted); border: 1px solid #736047; border-radius: 5px; background: transparent; font-size: 12px; text-decoration: none; }
body.compact-board .play-screen .board-frame { width: 100%; max-height: none; height: auto; aspect-ratio: auto; margin: 0; padding: 5px 7px; border-radius: 10px; flex: none; }
.board-surface { position: relative; width: 100%; aspect-ratio: 1; }
body.compact-board #board { width: 100%; height: 100%; border-radius: 5px; }
.board-topline, .board-bottomline { min-height: 29px; display: flex; align-items: center; gap: 8px; padding: 2px 3px; }
#board-player-top { flex: 1; min-width: 0; }
#board-player-bottom .player-card { width: 100%; }
body.compact-board .play-screen .player-card { min-width: 0; min-height: 24px; padding: 0; gap: 6px; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--hud-ink); }
body.compact-board .player-card > div { display: flex; min-width: 0; align-items: baseline; gap: 8px; }
body.compact-board .play-screen .player-card strong { display: inline; flex-shrink: 1; max-width: 48%; font-size: 12px; color: var(--hud-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact-board .play-screen .player-card small { display: inline; min-width: 0; margin: 0; font-size: 11px; color: var(--hud-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact-board .player-disc { width: 13px; height: 13px; flex: 0 0 13px; box-shadow: 0 1px 2px #0008; }
body.compact-board .turn-dot { width: 5px; height: 5px; flex: 0 0 5px; margin-right: 3px; }
body.compact-board .player-card.is-active .turn-dot { background: #81cfb0; }
body.compact-board .stage-status { max-width: 49%; gap: 5px; font-size: 11px; text-align: right; flex: 0 1 auto; color: #a9ddc3; }
body.compact-board #status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact-board .status-light { width: 5px; height: 5px; flex: 0 0 5px; }
body.compact-board #shogi-hands, body.compact-board #backgammon-stats, body.compact-board #morris-boxes { display: none; }
body.compact-board .play-screen #actions { width: 100%; min-height: 27px; max-height: none; padding: 5px 1px; border: 0; border-radius: 0; background: transparent; box-shadow: none; font-weight: 400; font-size: 11px; line-height: 1.4; text-align: center; color: #c5b798; }
body.compact-board .play-screen #actions > span { color: #c5b798 !important; }
body.compact-board #actions button { min-height: 31px; font-size: 12px; }
.board-toolbar { width: 100%; display: flex; flex-direction: column; gap: 7px; }
.room-tools { display: flex; align-items: flex-start; gap: 8px; }
.room-tools:has(> [hidden]):not(:has(> :not([hidden]))) { display: none; }
body.compact-board .mode-actions { display: flex; gap: 8px; }
body.compact-board .mode-actions button { flex: 1; min-height: 37px; padding: 6px 9px; font-size: 12px; }
body.compact-board .board-toolbar .secondary-btn { color: var(--hud-ink); border-color: #897052; background: #30251b; }
body.compact-board .board-toolbar .secondary-btn:hover { background: #443123; }
body.compact-board .restart-controls { flex: 1; min-width: 0; }
body.compact-board .invite-row { flex: 1; min-width: 0; width: 100%; }
body.compact-board[data-room-phase="playing"] .invite-row input,
body.compact-board[data-room-phase="finished"] .invite-row input { display: none; }
body.compact-board .room-tools #copy-btn { min-height: 34px; flex: none; }
body.compact-board[data-room-phase="playing"] #copy-btn,
body.compact-board[data-room-phase="finished"] #copy-btn { width: 100%; }
body.compact-board .invite-row input { color: #e7d3b0; background: #282019; border-color: #806443; }
.ad-zone { width: 300px; justify-self: center; padding-top: 65px; text-align: center; }
.ad-label { font-size: 10px; letter-spacing: .14em; color: #9c907c; margin-bottom: 8px; }
.ad-slot { width: 300px; height: 250px; box-sizing: border-box; position: relative; border: 0; background: transparent; }
.ad-placeholder { color: #7b705f; font-size: 11px; pointer-events: none; }
.ad-slot[data-ad-state="filled"] { border: 0; background: transparent; }
.ad-slot[data-ad-state="filled"] .ad-placeholder { display: none; }
.ad-slot iframe { display: block; max-width: 100%; border: 0; }
.rules-dialog { width: min(640px, calc(100% - 32px)); max-height: min(80svh, 760px); box-sizing: border-box; padding: 24px; border: 1px solid #8a6840; border-radius: 12px; background: #f3ead7; color: #30241a; overflow: auto; }
.rules-dialog::backdrop { background: #080604b8; backdrop-filter: blur(4px); }
.rules-dialog .below-inner { padding: 0; max-width: none; }
.rules-dialog h2 { font-size: 23px; margin: 15px 0 9px; }
.rules-dialog h3 { font-size: 17px; }
.rules-dialog p { font-size: 14px; line-height: 1.65; color: #594832; }
.rules-dialog .panel-label, .rules-dialog #mode-label { display: none; }
.rules-dialog .game-links { display: flex; flex-wrap: wrap; gap: 7px; }
.rules-dialog .game-links a { color: #46301f; background: #e4d5b8; border: 1px solid #bfaa87; font-size: 12px; }
.rules-dialog .piece-guide-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.rules-dialog .piece-guide-list li { color: #30241a; background: #e9dcc3; }
.rules-close { float: right; min-height: 34px; padding: 5px 12px; color: #594832; border: 1px solid #b3a181; border-radius: 5px; background: transparent; }
body.compact-board .pp-tip-btn { display: none !important; }
body.compact-board #support-tools .pp-tip-btn { display: inline-flex !important; position: static !important; transform: none !important; width: auto !important; height: auto !important; min-height: 34px; margin: 10px 0 0; box-shadow: none !important; }
@media (max-width: 1023px) {
  body.compact-board .game-layout { grid-template-columns: minmax(0, 1fr); padding: 10px 12px 20px; row-gap: 0; }
  body.compact-board .stage { width: 100%; max-width: 560px; }
  .ad-zone { padding-top: var(--ad-separation); width: min(320px, 100%); }
  .ad-slot { width: 100%; height: 50px; }
}
@media (max-width: 540px) {
  body.compact-board .game-layout { padding: 8px 8px 18px; }
  body.compact-board .stage h1 { font-size: 22px; }
  body.compact-board .stage-head { min-height: 39px; padding-bottom: 6px; }
  body.compact-board .play-screen .board-frame { padding: 3px 5px; }
  body.compact-board .player-card strong { font-size: 11px; }
  body.compact-board .player-card small { font-size: 10px; }
  body.compact-board .player-card > div { gap: 5px; }
  body.compact-board .stage-status { font-size: 10px; }
  .board-size-control select { font-size: 14px; }
  .rules-dialog { padding: 17px; }
}

/* Portraits bring the two players into the table without covering the board. */
.board-topline, .board-bottomline { min-height: 58px; padding: 4px 3px; gap: 10px; }
body.compact-board .play-screen .player-card { position: relative; min-height: 48px; gap: 9px; }
body.compact-board .play-screen .player-card .player-identity { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
body.compact-board .play-screen .player-card strong { font-size: 14px; max-width: 100%; width: 100%; }
body.compact-board .play-screen .player-card small { font-size: 11px; max-width: 100%; }
body.compact-board .avatar-button { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; border: 2px solid #bba17a; border-radius: 50%; background: #ad9170; box-shadow: 0 2px 5px #0004; overflow: hidden; }
body.compact-board .avatar-button img { width: 100%; height: 100%; display: block; }
body.compact-board .avatar-button:disabled { opacity: 1; cursor: default; }
body.compact-board .avatar-button.is-empty { opacity: .35; filter: grayscale(1); }
body.compact-board .is-active .avatar-button { border-color: #8dd5b5; box-shadow: 0 0 0 2px #74bd9233; }
body.compact-board .player-disc { position: absolute; left: 32px; top: 34px; width: 13px; height: 13px; border: 1px solid #c8b28c; }
body.compact-board .turn-dot { display: none; }
body.compact-board #board-player-bottom .player-card { width: auto; min-width: 0; flex: 1; }
body.compact-board .stage-status { font-size: 12px; max-width: 43%; }
body.compact-board #status { white-space: normal; line-height: 1.4; }
.table-quick-actions { display: flex; flex: none; align-items: center; gap: 6px; }
.table-quick-actions button { min-height: 34px; padding: 5px 10px; border: 1px solid #927a55; border-radius: 6px; color: #f3ead7; background: #33271d; font: inherit; font-size: 12px; cursor: pointer; }
.table-quick-actions button:disabled { opacity: .4; cursor: default; }
.table-quick-actions button:not(:disabled):hover { background: #55402a; }
.table-menu-actions { display: flex; flex-direction: column; gap: 10px; clear: both; }
.table-menu-actions button { width: 100%; min-height: 40px; border: 1px solid #b9a27f; border-radius: 6px; background: #e6d8bd; color: #35261a; font: inherit; cursor: pointer; }
.table-menu-actions button:disabled { opacity: .45; cursor: default; }
.table-menu .room-tools { flex-direction: column; }
.table-menu .restart-controls, .table-menu .invite-row { width: 100%; }
.table-menu .invite-row { flex-direction: column; align-items: stretch; }
body.compact-board .table-menu .invite-row input { width: 100%; min-height: 36px; flex: none; }
body.compact-board .table-menu .invite-row input { color: #3a2a1b; background: #faf3e6; }
.profile-name { display: flex; flex-direction: column; gap: 8px; font-size: 14px; clear: both; }
.profile-name input { padding: 10px 12px; background: #fffaf0; border: 1px solid #bca27d; border-radius: 6px; font: inherit; color: #35261a; }
#avatar-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
#avatar-options button { padding: 3px; border-radius: 50%; border: 3px solid transparent; background: transparent; cursor: pointer; justify-self: center; }
#avatar-options button[aria-pressed="true"] { border-color: #407c5d; background: #b9ccb0; }
#avatar-options img { display: block; width: 56px; height: 56px; }
#profile-form > button { width: 100%; min-height: 42px; padding: 8px 14px; color: #fff9ee; background: #a83f2b; border: 0; border-radius: 6px; font: inherit; cursor: pointer; }
.online-count { flex: none; color: #9aceb1; font-size: 11px; white-space: nowrap; font-family: system-ui, sans-serif; }
.avatar-image { display: block; width: 100%; height: 100%; border-radius: 50%; background-repeat: no-repeat; flex: none; }
#lobby-avatar { width: 64px; height: 64px; border: 2px solid #ceb083; box-sizing: border-box; }
#avatar-options .avatar-image { width: 56px; height: 56px; }
.flight-players { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; min-height: 60px; padding: 4px 0; }
.flight-game .flight-players .player-card { min-width: 0; gap: 7px; }
.flight-game .flight-players .player-card[hidden] { display: none !important; }
.flight-game .flight-players .player-disc { display: none; }
.flight-game .flight-players .avatar-button { border-color: var(--seat-color); }
.flight-game .flight-players .is-active .avatar-button { box-shadow: 0 0 0 3px #ecd08e70; }
.flight-game .flight-players .player-card strong { font-size: 12px; }
.flight-game .flight-players .player-card small { font-size: 10px; }
.flight-game .stage-head { flex-wrap: wrap; }
.flight-game .stage-head #stage-status { flex: 1 0 100%; max-width: none; justify-content: flex-end; margin-bottom: 2px; }
body.flight-game .stage { width: min(100%, max(320px, calc(100svh - 450px))); }
body.flight-game #actions { display: block; min-height: 88px !important; }
.flight-dice-controls { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 8px; }
.flight-dice-controls button { cursor: pointer; border-radius: 7px; padding: 8px 12px; color: #f2dfbc; background: #35291e; border: 1px solid #816846; }
.flight-dice-controls button:disabled { opacity: .45; cursor: default; }
body.flight-game #actions .flight-dice-controls button { color: #f2dfbc; background: #35291e; }
body.flight-game #actions #flight-roll { color: #f2dfbc; background: #6c3b28; }
body.flight-game #flight-roll-label { color: inherit; }
.flight-dice-controls #flight-roll { display: flex; align-items: center; gap: 13px; min-width: 125px; justify-content: center; padding: 5px 12px; background: #6c3b28; }
.flight-die { display: block; width: 42px; height: 42px; border-radius: 9px; box-sizing: border-box; padding: 7px; background: linear-gradient(135deg,#fffcf4,#dfd5bf); border: 1px solid #fff7e2; box-shadow: 3px 4px 0 #a7977e, 4px 7px 10px #0007; transform: rotate(-5deg); }
.die-pips { display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); width: 100%; height: 100%; gap: 3px; }
.die-pips i { background: #3e3228; border-radius: 50%; box-shadow: inset 1px 1px 1px #0004; }
.flight-die.rolling { animation: dice-tumble .32s linear infinite; }
@keyframes dice-tumble { 0%{transform:translateY(0) rotate(-8deg) scale(1)}25%{transform:translateY(-5px) rotate(85deg) scale(.93)}50%{transform:translateY(-2px) rotate(182deg) scale(1.05)}75%{transform:translateY(-6px) rotate(273deg) scale(.96)}100%{transform:translateY(0) rotate(352deg) scale(1)} }
#flight-moves { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#flight-moves button { min-height: 38px; background: #d9bd84; color: #302519; border: 1px solid #99815a; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
#flight-hint { margin: 8px 0; font-size: 11px; color: #ccb998; }
.flight-confirm-actions { display: flex; gap: 10px; }
.flight-confirm-actions button { min-height: 40px; padding: 7px 12px; border-radius: 6px; border: 1px solid #ad9570; background: #eadcc2; color: #35291d; flex: 1; cursor: pointer; }
.flight-confirm-actions button:first-child { background: #a3432e; color: #fff7e9; }
#flight-player-count,#flight-takeoff { min-height: 36px; padding: 4px 8px; color: #f3ead7; background: #2e241b; border: 1px solid #806947; border-radius: 6px; }
@media (max-width: 1023px) { body.flight-game .stage { width: 100%; } }
@media (max-width: 540px) { .flight-players { gap: 6px; min-height: 56px; } .flight-game .flight-players .avatar-button { width: 38px; height: 38px; flex-basis: 38px; } .flight-game .flight-players .player-card strong { font-size: 11px; } }
@media (prefers-reduced-motion: reduce) { .flight-die.rolling { animation: none; } }
.town-inspector { position: absolute; inset: 17% 16%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #3e503d; text-align: center; pointer-events: none; }
.town-inspector .town-art { width: 44%; aspect-ratio: 1; background-image: url('/assets/town-buildings-v1.png'); background-size: 400% 400%; border-radius: 24%; box-shadow: 0 4px 14px #50664615; }
.town-inspector #town-round { font: 600 clamp(9px,1vw,12px) system-ui,sans-serif; letter-spacing: .08em; color: #658367; }
.town-inspector h2 { font: 700 clamp(13px,1.65vw,23px) system-ui,sans-serif; margin: 2px 0; }
.town-inspector p,.town-inspector #town-owner { font: 500 clamp(10px,1vw,13px)/1.4 system-ui,sans-serif; margin: 0; }
.town-inspector #town-upgrade-rule { font: 500 clamp(9px,.95vw,12px)/1.3 system-ui,sans-serif; color: #68735a; }
.town-inspector button { pointer-events: auto; background: transparent; color: #506a4f; border: 0; text-decoration: underline; font-size: 10px; cursor: pointer; }
body.estate-game .flight-dice-controls { flex-wrap: wrap; gap: 7px; }
body.estate-game #actions .flight-dice-controls #town-primary { background: #4c755b; color: #fff5dd; border-color: #789c70; min-height: 40px; }
body.estate-game #actions #town-secondary { background: transparent; color: #d9c7a6; }
body.estate-game #actions #flight-roll { min-width: 98px; gap: 8px; }
body.estate-game #actions .flight-dice-controls button[hidden] { display: none; }
#town-message { color: #cdbc9d; min-height: 2.8em; margin: 9px 0 4px; font-size: 11px; line-height: 1.4; }
#town-property-actions { display: flex; gap: 8px; justify-content: center; }
body.estate-game #town-property-actions button { border: 1px solid #9b855e; border-radius: 5px; padding: 5px 10px; color: #ead4a6; background: #3b3625; cursor: pointer; }
.town-clock { font: 12px ui-monospace,monospace; color: #d4c298; min-width: 34px; }
#town-deeds { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
#town-deeds button { padding: 10px; border: 1px solid #bfa984; border-radius: 6px; background: #e8dcc3; color: #3e4937; font: 12px/1.5 system-ui,sans-serif; text-align: left; cursor: pointer; }
#town-standings p { padding-left: 8px; margin: 6px 0; font-size: 12px; }
#town-log { padding-left: 20px; font-size: 12px; line-height: 1.8; }
#town-round-limit { min-height: 36px; padding: 4px 8px; color: #f3ead7; background: #2e241b; border: 1px solid #806947; border-radius: 6px; }
#town-player-count { min-height: 36px; padding: 4px 8px; color: #f3ead7; background: #2e241b; border: 1px solid #806947; border-radius: 6px; }
@media (max-width:540px) { .town-inspector { gap: 3px; } #town-deeds { grid-template-columns: 1fr; } }
body[data-entry="lobby"] .board-frame, body[data-entry="lobby"] #actions { display: none !important; }
body[data-entry="play"] #online-lobby { display: none; }
.online-lobby { width: 100%; padding: 26px 24px 20px; border: 1px solid #927653; border-radius: 12px; background: linear-gradient(145deg, #453523, #251c15); box-sizing: border-box; color: #f3ead7; margin-bottom: 12px; }
.lobby-eyebrow { font-size: 11px; color: #b4a080; letter-spacing: .13em; }
.online-lobby h2 { font-size: 23px; margin: 8px 0 0; }
.lobby-players { display: flex; align-items: center; justify-content: space-around; margin: 28px 0 20px; }
.lobby-players button, .lobby-open-seat { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 92px; color: #e8d9bc; font: inherit; font-size: 13px; border: 0; background: transparent; padding: 0; }
.lobby-players button { cursor: pointer; }
.lobby-players img { width: 64px; height: 64px; border: 2px solid #ceb083; border-radius: 50%; box-sizing: border-box; }
.lobby-vs { color: #99815e; font-family: Georgia, serif; font-size: 16px; }
.open-seat-icon { display: grid; place-items: center; width: 64px; height: 64px; box-sizing: border-box; border: 1px solid #806944; border-radius: 50%; font: 25px Georgia, serif; color: #ac9370; }
.online-lobby p { font-size: 13px; line-height: 1.65; color: #c6b591; margin: 12px 0; }
#lobby-description { min-height: 43px; text-align: center; }
#lobby-settings { margin: 16px 0; border-top: 1px solid #79624070; border-bottom: 1px solid #79624070; padding: 12px 0; }
#lobby-settings summary { cursor: pointer; color: #e4ceb0; font-size: 13px; }
#lobby-settings label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 13px; }
#lobby-settings .bot-preference { justify-content: flex-start; }
#lobby-settings input { accent-color: #a74631; width: 17px; height: 17px; }
#turn-limit, #room-code { min-height: 36px; border: 1px solid #806947; border-radius: 6px; color: #f3ead7; background: #261d16; padding: 5px 8px; font: inherit; font-size: 13px; }
#join-room-form { margin: 16px 0; }
#join-room-form label { font-size: 12px; color: #dbc6a2; }
#join-room-form > div { display: flex; gap: 7px; margin-top: 8px; }
#room-code { min-width: 0; flex: 1; }
#join-room-form button, #copy-room-code { min-height: 36px; padding: 6px 12px; border: 1px solid #a18b65; border-radius: 6px; background: #59422b; color: #f5e6ce; cursor: pointer; font: inherit; font-size: 12px; }
.practice-link { display: block; margin: 14px auto 0; padding: 6px; border: 0; background: transparent; color: #c1aa84; font: inherit; font-size: 11px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#lobby-room { text-align: center; padding: 12px; background: #1e1711; border-radius: 8px; font-size: 12px; }
#lobby-room-code { display: block; font: 22px ui-monospace, monospace; color: #ffe5b7; letter-spacing: .05em; margin: 9px 0; overflow-wrap: anywhere; }
.invite-room-code { font: 18px ui-monospace, monospace; overflow-wrap: anywhere; }
body.compact-board[data-entry="lobby"] .mode-actions { display: grid; grid-template-columns: 1fr 1fr; }
body[data-entry="lobby"] #match-btn { grid-column: 1 / -1; }
body[data-entry="lobby"] #online-btn:only-child { grid-column: 1 / -1; }
body.is-online[data-entry="lobby"] #online-btn { grid-column: 1 / -1; }
body.compact-board .mode-actions button { min-height: 41px; }
body.compact-board .avatar-button img { object-fit: cover; }
@media (max-width: 540px) { .online-lobby { padding: 23px 18px 18px; } .online-lobby h2 { font-size: 21px; } .online-count { font-size: 10px; } body.compact-board .stage-title { gap: 7px; } }
@media (max-width: 540px) {
  .board-topline, .board-bottomline { min-height: 54px; gap: 8px; }
  body.compact-board .play-screen .player-card strong { font-size: 13px; }
  body.compact-board .play-screen .player-card small { font-size: 11px; }
  body.compact-board .stage-status { font-size: 11px; }
  .table-quick-actions { gap: 5px; }
  .table-quick-actions button { padding: 5px 8px; }
}
