/* The room follows the reference: players above, ring board, controls below. */
.seat-avatar, .seat.empty .seat-avatar { border-color: var(--seat-color); }
body.room-active { background: #0c1d40; }
.room-active .app-shell { max-width: none; padding: 0 24px; }
.room-active .site-header { height: 72px; border: 0; position: relative; }
.room-active .brand { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); gap: 7px; font-size: 23px; font-weight: 500; letter-spacing: 0; }
.room-active .brand-mark { width: 25px; height: 25px; border-radius: 7px; }
.room-active .brand-mark .icon { width: 19px; height: 19px; }
.room-active .brand-sub { display: none; }
.room-active #home-button, .room-active #end-game { position: absolute; top: 24px; padding: 2px 9px; height: 25px; border-radius: 18px; background: #dce3ee; color: #0c1d40; font-size: 12px; box-shadow: 0 2px 7px #0003; }
.room-active #home-button { left: 4px; }
.room-active #home-button .icon { display: none; }
.room-active #end-game { right: 4px; }
.room-active #sound-toggle { position: absolute; right: 87px; top: 24px; width: 25px; height: 25px; border-color: #ffffff35; }
.room-active #sound-toggle .icon { width: 14px; height: 14px; }
.room-active #connection { position: absolute; left: 91px; top: 29px; font-size: 10px; }
.room-active .room-view { padding: 0 0 12px; }
.room-active .room-heading { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); margin: 0; z-index: 2; }
.room-active .room-heading > div:first-child { display: none; }
.room-active .room-id-box { background: none; border: 0; padding: 0; gap: 4px; border-radius: 0; max-width: none; flex-wrap: nowrap; }
.room-active .room-id-box > span, .room-active .room-id-box strong { color: #f0f4ff; font-size: 14px; letter-spacing: 0; font-weight: 400; }
.room-active .room-id-box .text-button { font-size: 0; border: 0; padding: 0 3px; gap: 0; }
.room-active .room-id-box .text-button .icon { width: 13px; height: 13px; }
.room-active .room-layout { display: flex; flex-direction: column; align-items: center; gap: 0; }
.room-active .play-area { width: 100%; border: 0; border-radius: 0; background: none; overflow: visible; }
.room-active .seats { max-width: 1540px; margin: 0 auto 21px; padding: 4px 0 0; border: 0; background: none; gap: 12px; }
.room-active .seat { gap: 4px; }
.room-active .seat-avatar { width: 56px; height: 56px; border: 1px solid var(--seat-color); background: transparent; box-shadow: none; font-weight: 400; font-size: 27px; }
.room-active .seat.empty .seat-avatar { border-style: solid; border-color: var(--seat-color); color: #d5e0f3; }
.room-active .seat.is-turn .seat-avatar { border-color: var(--seat-color); background: color-mix(in srgb, var(--seat-color) 20%, #0c1d40); box-shadow: 0 0 0 3px color-mix(in srgb, var(--seat-color) 14%, transparent); }
.room-active .seat.is-turn::after { right: calc(50% - 35px); top: -8px; content: '⏱'; font-size: 14px; padding: 0; background: none; }
.room-active .host-label { border-radius: 9px; font-size: 10px; top: 0; left: -11px; line-height: 15px; }
.room-active .seat-meta { min-height: 18px; }
.room-active .seat-name { font-size: 11px; max-width: 120px; }
.room-active .you-tag { background: #ff6727; color: white; border-radius: 50%; font-size: 10px; width: 16px; height: 16px; padding: 0; text-align: center; }
.room-active .seat-number { border: 0; width: 16px; height: 16px; font-size: 10px; color: white; background: #5a6478; right: 0; bottom: 0; }
.room-active .seat-status { width: 8px; height: 8px; border: 0; bottom: 0; left: 3px; }
.room-active .seat-piece-count { font-size: 10px; color: #e2eaf9; height: 18px; }
.room-active .seat-piece-count .icon { width: 15px; height: 15px; }
.room-active .seat-action { background: #dce3ee; color: #0c1d40; border-radius: 20px; font-size: 12px; padding: 1px 9px; }
.room-active .game-panel { padding: 0; }
.room-active .board-stage { position: relative; width: min(760px, calc(100dvh - 290px), calc(100vw - 48px)); margin: 0 auto; }
.room-active .game-board { max-width: none; width: 100%; }
.room-active .game-board svg { display: block; width: 100%; height: auto; }
.room-active .board-dice-anchor { position: absolute; left: 50%; top: 50%; width: 5.4%; aspect-ratio: 1; transform: translate(-50%, -50%); display: grid; place-items: center; perspective: 220px; z-index: 3; }
.room-active .board-dice-anchor .dice { width: 100%; height: 100%; border-radius: 7px; border: 1.5px solid #557184; background: linear-gradient(135deg, #f4fbff, #bdd6e5); padding: 18%; gap: 9%; box-shadow: 0 2px 3px #0004; transform: none; transition: none; }
.room-active .dice-dot { width: 70%; height: 70%; background: #344c5c; }
.room-active .dice.rolling { animation: reference-dice-shake .16s linear infinite; will-change: transform; }
.room-active .dice.settled { animation: reference-dice-land .12s ease-out; }
.room-active .board-hint { min-height: 31px; padding: 12px 0 0; text-align: center; color: white; font-size: 15px; }
.room-active .board-hint strong { color: white; }
.room-active .play-area-footer { display: none; }
.room-active .side-panel { display: contents; }
.room-active .rules-card, .room-active .activity-card { display: none; }
.room-active .turn-card { padding: 0; border: 0; border-radius: 0; background: none; width: 300px; overflow: visible; margin: 6px auto 0; text-align: center; }
.room-active .turn-card::before { display: none; }
.room-active .turn-card .card-label { display: contents; }
.room-active #turn-label, .room-active #turn-title, .room-active #turn-description, .room-active #lobby-progress { display: none; }
.room-active .dice-area { position: static; display: flex; justify-content: center; flex-direction: row; margin: 0; gap: 0; }
.room-active .dice-area .button { width: auto; min-width: 108px; height: 40px; padding: 0 17px; border-radius: 24px; font-size: 15px; font-weight: 400; letter-spacing: 0; background: #e1e7ef; color: #0c1d40; box-shadow: 0 2px 5px #0003; }
.room-active .dice-area .button::before { content: '🎲'; margin-right: 7px; font-size: 13px; }
.room-active .dice-area .button:disabled { opacity: .7; color: #778599; }
.room-active .dice-area .button .icon { display: none; }
.room-active .countdown { position: absolute; top: 13px; left: calc(50% + 67px); font-size: 10px; color: #a3b5d2; white-space: nowrap; }
.room-active .move-options { max-width: none; justify-content: center; margin: 8px 0 0; gap: 6px; }
.room-active .move-option { flex: none; padding: 3px 9px; border-radius: 15px; font-size: 11px; }
.room-active .site-footer { display: none; }
.room-active .board-svg .piece-ring { stroke-width: 1.8; }
.room-active .board-svg .piece-core { opacity: .98; }
.room-active .board-svg .piece-halo { stroke-width: 2; }
@keyframes reference-dice-shake {
  0% { transform: translate(-2px, 1px) rotateX(0deg) rotateZ(-12deg) scale(1.12); }
  25% { transform: translate(3px, -5px) rotateX(80deg) rotateZ(25deg) scale(1.22); }
  50% { transform: translate(-3px, -2px) rotateX(180deg) rotateZ(-18deg) scale(1.14); }
  75% { transform: translate(2px, -5px) rotateX(280deg) rotateZ(16deg) scale(1.2); }
  100% { transform: translate(-2px, 1px) rotateX(360deg) rotateZ(-12deg) scale(1.12); }
}
@keyframes reference-dice-land {
  0% { transform: translateY(-4px) scale(1.18); }
  55% { transform: translateY(2px) scale(.94); }
  100% { transform: none; }
}
@media (max-width: 640px) {
  .room-active .app-shell { padding: 0 10px; }
  .room-active .site-header { height: 74px; }
  .room-active .brand { font-size: 21px; top: 9px; }
  .room-active #home-button, .room-active #end-game { font-size: 10px; padding: 1px 7px; height: 23px; top: 20px; }
  .room-active #sound-toggle { top: 50px; right: 4px; width: 23px; height: 23px; }
  .room-active #connection { display: none; }
  .room-active .seats { padding: 5px 0 0; margin-bottom: 20px; gap: 4px; }
  .room-active .seat-avatar { width: 45px; height: 45px; font-size: 23px; }
  .room-active .seat-name { max-width: 65px; font-size: 9px; }
  .room-active .seat-piece-count { font-size: 8px; height: 16px; }
  .room-active .seat-piece-count .icon { width: 12px; height: 12px; }
  .room-active .host-label { font-size: 8px; left: -9px; line-height: 13px; }
  .room-active .seat-action { font-size: 10px; }
  .room-active .board-stage { width: min(calc(100vw - 20px), calc(100dvh - 260px)); }
  .room-active .board-dice-anchor { width: 6%; }
  .room-active .board-dice-anchor .dice { border-radius: 4px; border-width: 1px; }
  .room-active .board-hint { font-size: 13px; padding-top: 14px; min-height: 36px; }
  .room-active .turn-card { margin-top: 7px; }
  .room-active .dice-area .button { height: 38px; font-size: 14px; }
  .room-active .countdown { top: 12px; }
  .room-active #lobby-message { max-width: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  .room-active .dice.rolling { animation: reference-dice-reduced .25s ease-in-out infinite; }
  .room-active .dice.settled { animation: none; }
  @keyframes reference-dice-reduced { 50% { opacity: .65; } }
}

/* The takeoff badge lists all three legal launch results. */
.rules-card .rule-takeoff { width: 34px; font-size: 9px; white-space: nowrap; }
@media (max-width: 680px) {
  .rules-card .rule-takeoff { width: 29px; font-size: 8px; }
}

/* Codes stay in a private dialog; only the action is shown beside the game. */
.lobby-start { margin-top: 14px; }
.lobby-start .start-button { width: 100%; min-width: 0; margin: 0; }
.role-tools { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 12px; }
.role-tools .text-button { padding: 3px 12px; border: 1px solid #ffffff26; border-radius: 20px; font-size: 11px; }
.role-tools .text-button:hover:not(:disabled) { background: #ffffff0b; }
.role-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
.role-dialog .role-code-field { margin: 0 0 20px; height: 45px; text-align: center; letter-spacing: 2px; font-family: Consolas, 'SFMono-Regular', monospace; font-size: 17px; }
.role-dialog .role-code-field::placeholder { font-family: var(--font); letter-spacing: 0; font-size: 12px; color: #8098be; }
.role-dialog #role-error { color: #ff9f94; margin: -10px 0 16px; }
.role-dialog .dialog-actions { flex-wrap: wrap; }
.role-dialog .dialog-actions > .button { min-width: 90px; }
.room-active .role-tools { margin-top: 10px; }
.room-active .role-tools .text-button { color: #b4c5e5; font-size: 11px; }
.afk-tools { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.afk-tools .text-button { padding: 3px 12px; border: 1px solid #ffffff26; border-radius: 20px; font-size: 11px; color: #b4c5e5; }
.afk-tools #afk-skip { color: #ffe087; border-color: #ffe08745; }
.seat-afk { border: 1px solid #ffc07759; border-radius: 12px; padding: 0 8px; background: #ffbb5513; color: #ffc889; font-size: 9px; line-height: 15px; white-space: nowrap; }
.host-dialog { width: min(470px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.host-dialog #host-description { margin-bottom: 16px; }
.host-player-list { display: grid; gap: 11px; text-align: left; }
.host-player { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #0b1d3d66; }
.host-player-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; }
.host-player-heading strong { font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.host-player-status { color: var(--muted); font-size: 10px; }
.host-player .host-code-field { margin-top: 10px; height: 37px; font-family: Consolas, 'SFMono-Regular', monospace; font-size: 15px; letter-spacing: 1px; }
.host-player .host-code-empty { margin: 10px 0 0; font-size: 11px; }
.host-player-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px 13px; margin-top: 9px; }
.host-player-actions:empty { display: none; }
.host-player-actions .text-button { padding: 2px 0; font-size: 11px; }
.host-player-actions .host-kick-button { color: #ff9f94; }
.host-dialog .host-code-note { margin: 16px 0; font-size: 10px; }
@media (max-width: 380px) {
  .role-dialog { padding: 20px; }
  .host-dialog { padding: 20px; }
  .role-dialog .dialog-actions > .button { padding: 0 8px; font-size: 11px; }
}

/* Mode belongs to the room; only the host can change it before boarding. */
.lobby-panel .mode-field { margin-top: 14px; }
.lobby-panel > .mode-description { margin-top: 12px; font-size: 11px; color: #c3d2ed; }
.lobby-panel > .mode-permission { margin-top: 4px; font-size: 10px; color: #8098bf; }
.game-mode-summary { text-align: center; color: #a7badc; font-size: 11px; margin-bottom: 10px; }
.fun-mode .game-mode-summary { color: #ffe087; }
.fun-legend { width: min(560px, 100%); margin: 12px auto 0; padding: 8px 13px; border: 1px solid #ffffff20; border-radius: 10px; background: #07183180; }
.special-legend-items { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; font-size: 11px; }
.legend-speed, .board-special.special-speed { color: #ffe175; }
.legend-trap, .board-special.special-trap { color: #ffadbe; }
.legend-safe, .board-special.special-safe { color: #a0f0ee; }
.legend-lucky, .board-special.special-lucky { color: #efc2ff; }
.legend-ice, .board-special.special-ice { color: #b9f3ff; }
.board-track.is-ice { stroke: #c3f4ff; stroke-width: 2; stroke-dasharray: 4 2; }
.piece.is-frozen .piece-core { fill: #d8f3ff; }
.frozen-mark { pointer-events: none; }
.fun-legend p { margin: 5px 0 0; color: #8fa8cf; font-size: 10px; text-align: center; line-height: 1.6; }
.board-special { pointer-events: none; }
/* Reserve turn controls; short landscape viewports keep a board and can scroll. */
.room-active .board-stage { width: min(760px, max(240px, calc(100dvh - 424px)), calc(100vw - 48px)); }
.room-active.fun-mode .board-stage { width: min(760px, max(240px, calc(100dvh - 494px)), calc(100vw - 48px)); }
.board-stage { position: relative; }
.capture-effects { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; z-index: 4; pointer-events: none; }
.capture-callout { position: absolute; top: 25%; left: 50%; transform: translateX(-50%); max-width: 88%; width: max-content; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 16px; border: 1px solid #ffe6b8; border-radius: 13px; color: #fff1d5; background: #071732ed; box-shadow: 0 6px 24px #0005; z-index: 5; text-align: center; pointer-events: none; animation: capture-caption .95s ease both; }
.capture-callout strong { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.capture-callout span { color: #ffd887; font-size: 11px; }
.captured-ghost { transform-box: fill-box; transform-origin: center; animation: capture-return .85s ease-out both; }
.bounced-ghost { animation: wall-bounce .8s ease-out both; }
.capture-pulse { fill: none; stroke: #fff0b8; stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: capture-ring .6s ease-out both; }
.missile-trail { fill: none; stroke: #ffd887; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1; animation: missile-trail .95s linear both; }
.missile-flight { animation: missile-flight .95s linear both; }
.missile-impact { opacity: 0; transform-box: fill-box; transform-origin: center; animation: missile-impact .52s ease-out .4s forwards; }
.missile-captured { animation-duration: .52s; animation-delay: .4s; }
.missile-pulse { opacity: 0; animation: capture-ring .52s ease-out .4s forwards; }
@keyframes missile-flight {
  0% { transform: translate(0, 0); opacity: 1; }
  42% { transform: translate(var(--missile-x), var(--missile-y)); opacity: 1; }
  43%, 100% { transform: translate(var(--missile-x), var(--missile-y)); opacity: 0; }
}
@keyframes missile-trail {
  0% { stroke-dashoffset: 1; opacity: .8; }
  42% { stroke-dashoffset: 0; opacity: .8; }
  80%, 100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes missile-impact {
  0% { transform: scale(.25); opacity: 0; }
  15% { transform: scale(.85); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes capture-return {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  30% { transform: translateY(-16px) rotate(-12deg) scale(1.18); opacity: 1; }
  100% { transform: translateY(-70px) rotate(-32deg) scale(.4); opacity: 0; }
}
@keyframes capture-ring {
  from { transform: scale(.5); opacity: 1; }
  to { transform: scale(2.1); opacity: 0; }
}
@keyframes wall-bounce {
  0%, 15% { transform: translate(0, 0); opacity: 1; }
  85% { transform: translate(var(--bounce-x), var(--bounce-y)); opacity: .7; }
  100% { transform: translate(var(--bounce-x), var(--bounce-y)); opacity: 0; }
}
@keyframes capture-caption {
  0% { opacity: 0; translate: 0 5px; }
  12%, 80% { opacity: 1; translate: 0 0; }
  100% { opacity: 0; translate: 0 -3px; }
}
.capture-callout.is-reduced { animation: none; }
@media (max-width: 640px) {
  .game-mode-summary { font-size: 10px; margin-bottom: 9px; }
  .room-active .board-stage { width: min(calc(100vw - 20px), max(240px, calc(100dvh - 364px))); }
  .room-active.fun-mode .board-stage { width: min(calc(100vw - 20px), max(240px, calc(100dvh - 484px))); }
  .fun-legend { padding: 7px 9px; margin-top: 10px; }
  .special-legend-items { font-size: 10px; gap: 6px 12px; }
  .fun-legend p { font-size: 9px; }
  .capture-callout { padding: 7px 11px; }
  .capture-callout strong { font-size: 11px; }
  .capture-callout span { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .capture-callout, .captured-ghost, .bounced-ghost, .capture-pulse { animation: none; }
  .missile-effect { display: none; }
}

/* Seat statistics keep the owner's colour first, with at most two pairs per row. */
.player-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px 8px; color: #e2eaf9; font-size: 10px; font-variant-numeric: tabular-nums; }
.player-stat { display: flex; align-items: center; justify-content: center; gap: 3px; min-width: 0; }
.player-stat .icon { width: 12px; height: 12px; flex: none; color: var(--stat-color); }
.stat-count { min-width: 0; overflow-wrap: anywhere; }
.seat-stats { width: 74px; max-width: 100%; min-height: 32px; align-content: start; }
.seat-rank-slot { display: flex; justify-content: center; align-items: center; min-height: 16px; max-width: 100%; }
.seat-rank { border: 1px solid #ffe08759; border-radius: 12px; padding: 0 8px; background: #ffd42a13; color: #ffe087; font-size: 9px; line-height: 15px; white-space: nowrap; }
.rankings-panel { width: min(560px, 100%); margin: 10px auto 0; padding: 14px 17px; border: 1px solid #ffffff25; border-radius: 13px; background: #071831a6; }
.rankings-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rankings-heading h2 { margin: 0; color: #ffe087; font-size: 15px; font-weight: 600; }
.rankings-stat-label { color: #a7badc; font-size: 10px; }
.rankings-panel > p { margin: 5px 0 10px; color: #a7badc; font-size: 10px; overflow-wrap: anywhere; }
.rankings-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.ranking-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 88px; align-items: center; gap: 10px; min-width: 0; padding: 7px 0; border-top: 1px solid #ffffff12; }
.ranking-place { color: #d7e4fa; font-size: 12px; white-space: nowrap; }
.ranking-row[data-rank="1"] .ranking-place { color: #ffe087; }
.ranking-player { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ranking-player > .icon { width: 15px; height: 15px; color: var(--seat-color); flex: none; }
.ranking-name { color: #e2eaf9; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.ranking-player .you-tag { flex: none; }
.ranking-stats { width: 88px; max-width: 100%; }
.rankings-panel > .stats-description { margin-bottom: 0; color: #8098bf; font-size: 9px; }
@media (max-width: 640px) {
  .seat-stats { width: 66px; gap: 1px 4px; font-size: 8px; min-height: 28px; }
  .seat-stats .icon { width: 11px; height: 11px; }
  .seat-rank { padding: 0 6px; font-size: 8px; }
  .rankings-panel { padding: 11px 12px; }
  .rankings-heading h2 { font-size: 13px; }
  .ranking-row { grid-template-columns: 42px minmax(0, 1fr) 78px; gap: 7px; }
  .ranking-place, .ranking-name { font-size: 10px; }
  .ranking-stats { width: 78px; font-size: 9px; gap: 1px 4px; }
  .ranking-stats .icon { width: 11px; height: 11px; }
}

/* Extra decisions stay below the normal turn tools and expand on demand. */
.fun-rules { min-width: 0; width: min(420px, 100%); margin: 16px auto; padding: 13px 14px; border: 1px solid #ffffff25; border-radius: 12px; text-align: left; }
.fun-rules legend { padding: 0 6px; color: #e2eaf9; font-size: 12px; }
.fun-rule-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.fun-rule-options label { display: flex; align-items: center; gap: 6px; min-width: 0; color: #c3d2ed; font-size: 11px; }
.fun-rule-options input { width: 14px; height: 14px; margin: 0; accent-color: #ffd42a; flex: none; }
.fun-rules p { margin: 10px 0 0; color: #8098bf; font-size: 10px; }
.captain-selection { width: min(460px, calc(100% - 40px)); margin: 18px auto; text-align: left; }
.captain-selection h3 { margin: 0 0 7px; font-size: 13px; font-weight: 500; color: #e2eaf9; }
.captain-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 9px; }
.captain-choice { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 10px; border: 1px solid #ffffff25; border-radius: 10px; background: #0b1d3d66; color: #c3d2ed; text-align: left; cursor: pointer; font: inherit; line-height: 1.6; overflow-wrap: anywhere; }
.captain-choice strong { color: #e2eaf9; font-size: 12px; font-weight: 500; }
.captain-choice span, .captain-choice small { font-size: 10px; }
.captain-choice small { color: #91a9ce; }
.captain-choice.is-selected { border-color: #ffe087a6; background: #ffd42a0e; }
.captain-choice:hover:not(:disabled) { border-color: #ffe08775; background: #ffffff08; }
.captain-choice:disabled:not(.is-selected) { cursor: default; opacity: .7; }
.seat-captain { max-width: 100%; min-width: 0; color: #a7badc; font-size: 10px; line-height: 16px; white-space: nowrap; }
.captain-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 9px; align-items: end; }
.captain-form #captain-use { grid-column: 1 / -1; color: #ffe087; border-color: #ffe08745; }
.captain-accept { width: 100%; margin-top: 8px; }
.captain-intro-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.captain-intro-list section { min-width: 0; border: 1px solid #ffffff20; border-radius: 8px; padding: 8px; }
.captain-intro-list h4 { margin: 0 0 5px; font-size: 12px; font-weight: 500; color: #e2eaf9; }
.captain-intro-list p { font-size: 10px; }
.room-active .dice-steps { display: block; margin-top: 4px; color: #a7badc; font-size: 11px; line-height: 1.5; }
.piece-shield { opacity: .9; }
.strategy-panel { width: min(560px, calc(100% - 20px)); margin: 10px auto 0; border: 1px solid #ffffff25; border-radius: 12px; background: #071831a6; color: #c3d2ed; text-align: left; }
.strategy-panel > summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px 12px; min-height: 32px; padding: 7px 12px; cursor: pointer; font-size: 11px; list-style: none; }
.strategy-panel > summary::-webkit-details-marker { display: none; }
.strategy-panel > summary > span:first-child::before { content: '▸'; margin-right: 6px; color: #ffe087; }
.strategy-panel[open] > summary > span:first-child::before { content: '▾'; }
.strategy-summary { color: #93adcf; font-size: 10px; }
.key-events-panel > summary { flex-wrap: nowrap; }
.key-events-panel > summary > span:first-child { flex: none; }
.key-events-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-events-content { padding: 0 12px 10px; }
.key-events-content .strategy-note { margin: 0 0 7px; }
.key-events-list { position: relative; max-height: 220px; overflow-y: auto; overflow-x: hidden; overflow-anchor: none; margin: 0; padding: 0 2px 0 0; list-style: none; scrollbar-width: thin; }
.key-event-row { min-width: 0; padding: 8px 0; border-top: 1px solid #ffffff16; }
.key-event-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 9px; }
.key-event-type { color: #ffe087; background: #ffd42a0d; border: 1px solid #ffd42a28; border-radius: 5px; padding: 1px 5px; }
.key-event-time { flex: none; color: #8098bf; font-variant-numeric: tabular-nums; }
.key-event-text, .key-event-empty { margin: 5px 0 0; color: #c3d2ed; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.key-event-empty { padding: 7px 0; color: #8098bf; }
.strategy-content { padding: 0 12px 12px; }
.strategy-section { padding: 10px 0; border-top: 1px solid #ffffff16; }
.strategy-section h3 { margin: 0 0 6px; color: #e2eaf9; font-size: 12px; font-weight: 600; }
.strategy-section p { margin: 5px 0; font-size: 11px; overflow-wrap: anywhere; }
.strategy-public { color: #ffe087; }
.strategy-note, .strategy-section .strategy-note { margin: 7px 0 0; color: #8098bf; font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.strategy-actions, .item-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px; margin-top: 9px; align-items: end; }
.strategy-field { display: grid; gap: 4px; min-width: 0; font-size: 10px; color: #a7badc; }
.strategy-field select { width: 100%; min-width: 0; min-height: 32px; border: 1px solid #ffffff25; border-radius: 8px; padding: 5px 7px; color: #e2eaf9; background: #112548; font: inherit; font-size: 11px; text-overflow: ellipsis; }
.strategy-field select:disabled { opacity: .6; }
.strategy-panel .button { min-width: 0; min-height: 32px; height: auto; padding: 6px 9px; font-size: 11px; letter-spacing: 0; border-radius: 9px; }
.strategy-actions #alliance-betray { grid-column: 1 / -1; color: #ffb8ba; }
.alliance-request { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 6px 0; font-size: 11px; }
.alliance-request > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.alliance-request-buttons { display: flex; gap: 7px; flex: none; }
.alliance-request-buttons button { padding: 4px 7px; border: 1px solid #ffffff25; border-radius: 7px; background: #112548; color: #e2eaf9; font-size: 10px; }
.board-mines, .board-mine { pointer-events: none; }
.game-mode-row { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 10px; }
.game-mode-row .game-mode-summary { margin-bottom: 0; }
.fun-intro-button { font-size: 10px; padding: 2px 8px; border: 1px solid #ffffff25; border-radius: 14px; color: #c3d2ed; }
.lobby-panel > .fun-intro-button { margin: 7px 0 0; }
.fun-intro-dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: hidden; }
.fun-intro-dialog[open] { display: flex; flex-direction: column; }
.fun-intro-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; background: #132748; }
.fun-intro-heading h2 { font-size: 20px; }
.fun-intro-heading .text-button { flex: none; }
.fun-intro-dialog #fun-intro-selection { flex: none; margin: 10px 0 16px; color: #ffe087; font-size: 11px; }
.fun-intro-content { min-height: 0; overflow-y: auto; }
.fun-intro-content h3 { margin: 17px 0 7px; font-size: 13px; color: #e2eaf9; }
.fun-intro-content p { margin: 7px 0; color: #b4c5e5; font-size: 11px; line-height: 1.8; overflow-wrap: anywhere; }
.fun-intro-table { width: 100%; table-layout: fixed; border-collapse: collapse; color: #b4c5e5; font-size: 11px; line-height: 1.7; }
.fun-intro-table th, .fun-intro-table td { padding: 7px 8px; border: 1px solid #ffffff20; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.fun-intro-table th:first-child { width: 85px; color: #e2eaf9; font-weight: 500; }
.fun-intro-content ul { margin: 7px 0; padding-left: 18px; color: #b4c5e5; font-size: 11px; line-height: 1.8; }
.fun-intro-content li { margin: 8px 0; overflow-wrap: anywhere; }
@media (max-width: 380px) {
  .fun-rules { padding: 10px; }
  .fun-rule-options { gap: 7px 5px; }
  .fun-rule-options label { font-size: 10px; }
  .strategy-panel > summary { padding: 6px 9px; }
  .key-events-content { padding: 0 9px 9px; }
  .key-event-text { font-size: 10px; }
  .strategy-content { padding: 0 9px 9px; }
  .strategy-section p, .strategy-panel .button, .strategy-field select { font-size: 10px; }
  .captain-choice { padding: 8px; }
  .captain-choice strong { font-size: 11px; }
  .captain-choices { gap: 7px; }
}
@media (max-width: 640px) {
  .room-active .seat-captain { font-size: 8px; line-height: 13px; }
  .room-active .dice-steps { font-size: 10px; }
  .captain-intro-list { grid-template-columns: minmax(0, 1fr); }
}

/* Move the event panel below first; keep enough space for a readable board. */
@media (min-width: 900px) {
  .room-active .room-layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: 'seats' 'mode' 'board' 'legend' 'hint' 'turn' 'rankings' 'events' 'strategy'; max-width: 1400px; margin: 0 auto; align-items: start; column-gap: 22px; }
  .room-active.has-strategy .room-layout { grid-template-columns: minmax(0, 1fr) 270px; grid-template-areas: 'seats seats' 'mode strategy' 'board strategy' 'legend strategy' 'hint strategy' 'turn strategy' 'rankings strategy' 'events strategy'; }
  .room-active .play-area, .room-active .game-panel { display: contents; }
  .room-active .seats { grid-area: seats; width: 100%; }
  .room-active .game-mode-row { grid-area: mode; min-width: 0; }
  .room-active .board-stage { grid-area: board; max-width: 100%; }
  .room-active .fun-legend { grid-area: legend; min-width: 0; }
  .room-active .board-hint { grid-area: hint; min-width: 0; }
  .room-active .turn-card { grid-area: turn; max-width: 100%; }
  .room-active .rankings-panel { grid-area: rankings; min-width: 0; }
  .room-active #key-events-panel { grid-area: events; }
  .room-active #strategy-panel { grid-area: strategy; }
  .room-active .strategy-panel { width: 100%; max-width: 560px; min-width: 0; align-self: start; }
}
@media (min-width: 1300px) {
  .room-active .room-layout { grid-template-columns: 270px minmax(0, 1fr); grid-template-areas: 'seats seats' 'events mode' 'events board' 'events legend' 'events hint' 'events turn' 'events rankings'; }
  .room-active.has-strategy .room-layout { grid-template-columns: 270px minmax(0, 1fr) 270px; grid-template-areas: 'seats seats seats' 'events mode strategy' 'events board strategy' 'events legend strategy' 'events hint strategy' 'events turn strategy' 'events rankings strategy'; }
  .room-active #key-events-panel, .room-active #strategy-panel { margin-top: 0; }
}
