/* Shot 1: one responsive match shell for every Classic board renderer.
   Board coordinates, artwork and turn commands remain owned by their existing modules. */
#screen-game {
  --game-topbar-height: 58px;
  --game-hud-height: 0px;
  --game-gap: 12px;
}
#screen-game.active-screen {
  grid-template-rows: var(--game-topbar-height) minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
}
#screen-game .game-topbar {
  min-height: var(--game-topbar-height);
  background: rgba(12, 12, 39, .94);
  border-bottom: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 8px 28px rgba(5,5,22,.22);
}
#screen-game .game-turn-title { font-size: clamp(.86rem, 1.25vw, 1.05rem); }
#screen-game .game-turn-detail { color: rgba(255,255,255,.72); }
#screen-game .game-dock {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(250px,292px);
  grid-template-rows: minmax(0,1fr);
  align-items: center;
  gap: clamp(16px,2.6vw,38px);
  /* L6d: the dock grows with tall screens so the board can keep ≥76% of the viewport height. */
  width: min(100%, max(1500px, calc(100vh + 380px)));
  width: min(100%, max(1500px, calc(100dvh + 380px)));
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: 12px clamp(16px,2.5vw,40px) max(12px,env(safe-area-inset-bottom,0px));
  overflow: hidden;
}
#screen-game .main-layout,
#screen-game .board-panel {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: none;
  padding: 0;
  overflow: visible;
}
#screen-game .board-frame-shell {
  /* L6d: no fixed 812px cap — the board takes the full height beside the side HUD. */
  width: min(calc(100vh - var(--game-topbar-height) - 30px), calc(100vw - 330px));
  width: min(calc(100dvh - var(--game-topbar-height) - 30px), calc(100vw - 330px));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
}
#screen-game .bottom-hud {
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  align-self: center;
  width: 100%;
  max-width: none;
  min-height: min(520px,100%);
  height: auto;
  max-height: 100%;
  margin: 0;
  padding: 25px 22px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 24px;
  background: linear-gradient(155deg,rgba(36,31,82,.96),rgba(12,14,44,.97));
  box-shadow: 0 24px 54px rgba(2,3,23,.34), inset 0 1px rgba(255,255,255,.1);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
#screen-game .hud-left {
  display: grid;
  grid-template-columns: 46px minmax(0,1fr);
  gap: 12px;
  align-self: stretch;
  min-width: 0;
}
#screen-game .hud-player-chip { width: 46px; height: 46px; }
#screen-game .hud-section-label {
  display: block;
  color: #d6cbff;
  font-size: .61rem;
  letter-spacing: .14em;
}
#screen-game .hud-player-name { max-width: 100%; font-size: .97rem; }
#screen-game .hud-turn-status {
  display: block;
  max-width: none;
  color: rgba(255,255,255,.72);
  font-size: .78rem;
  font-style: normal;
}
#screen-game .hud-center {
  display: grid;
  place-items: center;
  align-self: center;
}
#screen-game .hud-dice-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 138px;
  height: 136px;
  min-width: 0;
  min-height: 0;
  padding: 9px;
  border: 2px solid rgba(255,255,255,.22);
  border-radius: 22px;
  background: linear-gradient(155deg,rgba(75,68,132,.94),rgba(27,29,72,.98));
  box-shadow: 0 14px 28px rgba(2,2,20,.3), inset 0 1px rgba(255,255,255,.18);
  touch-action: manipulation;
}
#screen-game .hud-dice-btn:not(:disabled) {
  border-color: #f3ff20;
  background: linear-gradient(150deg,#f7ff61,#e8f514);
  box-shadow: 0 12px 28px rgba(243,255,32,.2), inset 0 2px rgba(255,255,255,.65);
}
#screen-game .hud-dice-btn:hover:not(:disabled),
#screen-game .hud-dice-btn:focus-visible:not(:disabled) {
  border-color: #fff;
  background: #f7ff61;
  box-shadow: 0 12px 28px rgba(243,255,32,.27);
  outline: 3px solid #fff;
  outline-offset: 3px;
}
#screen-game .hud-dice-btn:active:not(:disabled) { transform: scale(.96); }
#screen-game .hud-dice-btn:disabled { opacity: 1; cursor: default; }
#screen-game #hud-dice-canvas { width: 76px; height: 76px; }
#screen-game .hud-dice-label,
#screen-game .hud-dice-btn:not(:disabled) .hud-dice-label {
  margin-top: 3px;
  color: #fff;
  font-size: .72rem;
  font-weight: 950;
  letter-spacing: .12em;
  text-shadow: none;
}
#screen-game .hud-dice-btn:not(:disabled) .hud-dice-label { color: #111426; }
#screen-game .hud-dice-btn:disabled .hud-dice-label { opacity: .8; color: #fff; }
#screen-game .hud-right {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
#screen-game .hud-event-block { flex-basis: 100%; min-width: 0; max-width: none; }
#screen-game .hud-event-label { display: block; color: #d6cbff; }
#screen-game .hud-last-roll { color: rgba(255,255,255,.83); font-size: .78rem; }
#screen-game .hud-action-button {
  min-height: 42px;
  padding: 0 14px;
  border-color: rgba(255,255,255,.28);
  border-radius: 11px;
  color: #fff;
  font-size: .7rem;
}
/* L6d: stack board over HUD on narrow, near-square and portrait screens; wide landscape tablets
   (aspect > 5:4, taller than 560px) keep the side HUD so the board stays ≥76% of the height. */
@media (max-width: 1100px) and (max-aspect-ratio: 5/4), (max-width: 1100px) and (max-height: 560px) {
  #screen-game { --game-topbar-height: 54px; --game-hud-height: 96px; --game-gap: 8px; }
  #screen-game .game-dock {
    grid-template-columns: minmax(0,1fr);
    grid-template-rows: minmax(0,1fr) var(--game-hud-height);
    gap: var(--game-gap);
    width: 100%;
    padding: var(--game-gap) 12px max(8px,env(safe-area-inset-bottom,0px));
  }
  #screen-game .board-frame-shell {
    width: min(calc(100vw - 24px), calc(100vh - var(--game-topbar-height) - var(--game-hud-height) - 32px));
    width: min(calc(100vw - 24px), calc(100dvh - var(--game-topbar-height) - var(--game-hud-height) - 32px));
  }
  /* L6d: the board sits directly on the bottom bar; spare height goes above it. */
  #screen-game .main-layout,
  #screen-game .board-panel { place-items: end center; }
  #screen-game .bottom-hud {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
    grid-template-rows: 1fr;
    align-items: center;
    gap: 12px;
    justify-self: center;
    width: min(800px,100%);
    min-height: 0;
    height: var(--game-hud-height);
    padding: 9px 16px;
    border-radius: 18px;
  }
  #screen-game .hud-left { grid-column: 1; grid-row: 1; align-self: center; grid-template-columns: 38px minmax(0,1fr); gap: 8px; }
  #screen-game .hud-player-chip { width: 38px; height: 38px; }
  #screen-game .hud-section-label { display: none; }
  #screen-game .hud-player-name { font-size: .83rem; }
  #screen-game .hud-turn-status { font-size: .69rem; }
  #screen-game .hud-center { grid-column: 2; grid-row: 1; }
  #screen-game .hud-dice-btn { width: 82px; height: 80px; border-radius: 14px; padding: 3px; }
  #screen-game #hud-dice-canvas { width: 54px; height: 54px; }
  #screen-game .hud-dice-label { font-size: .58rem; margin-top: 0; }
  #screen-game .hud-right { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  #screen-game .hud-event-block { display: none; }
}
@media (max-width: 760px) and (max-aspect-ratio: 5/4), (max-width: 760px) and (max-height: 560px) {
  #screen-game { --game-topbar-height: 52px; --game-hud-height: 112px; --game-gap: 10px; }
  #screen-game .game-topbar { min-height: var(--game-topbar-height); padding: 5px 10px; }
  #screen-game .game-turn-title { font-size: .79rem; }
  #screen-game .game-dock {
    grid-template-rows: minmax(0,1fr) var(--game-hud-height);
    align-content: stretch;
    align-self: stretch;
    height: 100%;
    /* L6d: 4px gutters keep the phone board ≥96% of the viewport width. */
    padding: 6px max(4px,env(safe-area-inset-right,0px)) max(8px,env(safe-area-inset-bottom,0px)) max(4px,env(safe-area-inset-left,0px));
    overflow: hidden;
  }
  /* L6d band (board 0916, Clement: centre the board): the board is width-bound on tall phones,
     so the spare height splits evenly above and below it instead of collecting above. */
  #screen-game .main-layout,
  #screen-game .board-panel { height: 100%; place-items: center; }
  #screen-game .board-frame-shell {
    width: min(calc(100vw - 8px), calc(100vh - var(--game-topbar-height) - var(--game-hud-height) - 30px));
    width: min(calc(100vw - 8px), calc(100dvh - var(--game-topbar-height) - var(--game-hud-height) - 30px));
    max-width: 100%;
  }
  #screen-game .bottom-hud {
    grid-template-columns: minmax(0,1fr) 94px 82px;
    gap: 6px;
    width: 100%;
    height: var(--game-hud-height);
    min-height: 0;
    padding: 8px 9px;
    border-radius: 18px;
  }
  #screen-game .hud-left { grid-template-columns: 32px minmax(0,1fr); gap: 6px; }
  #screen-game .hud-player-chip { width: 32px; height: 32px; }
  #screen-game .hud-player-name { font-size: .7rem; }
  #screen-game .hud-turn-status { max-width: 100%; font-size: .64rem; }
  #screen-game .hud-dice-btn { width: 92px; height: 94px; border-radius: 17px; }
  #screen-game #hud-dice-canvas { width: 64px; height: 64px; }
  #screen-game .hud-dice-label { font-size: .65rem; }
  #screen-game .hud-right { flex-direction: column; flex-wrap: nowrap; justify-content: center; align-items: stretch; justify-self: stretch; gap: 5px; }
  #screen-game .hud-action-button { min-height: 39px; padding: 0 5px; font-size: .62rem; }
}
@media (max-width: 360px) and (max-aspect-ratio: 5/4) {
  #screen-game .game-dock { padding-inline: max(4px,env(safe-area-inset-left,0px)) max(4px,env(safe-area-inset-right,0px)); }
  #screen-game .bottom-hud { grid-template-columns: minmax(0,1fr) 88px 82px; padding-inline: 6px; gap: 4px; }
  #screen-game .hud-dice-btn { width: 86px; height: 92px; }
  #screen-game .hud-player-chip { display: none; }
  #screen-game .hud-left { grid-template-columns: minmax(0,1fr); }
}
@media (orientation: landscape) and (max-height: 560px) {
  #screen-game { --game-topbar-height: 42px; --game-hud-height: 0px; --game-gap: 6px; }
  #screen-game .game-topbar { min-height: var(--game-topbar-height); padding-block: 3px; }
  #screen-game .game-dock {
    grid-template-columns: minmax(0,1fr) minmax(178px,220px);
    grid-template-rows: minmax(0,1fr);
    gap: 8px;
    padding: 5px max(8px,env(safe-area-inset-right,0px)) max(5px,env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px));
  }
  #screen-game .board-frame-shell {
    width: min(calc(100dvh - var(--game-topbar-height) - 14px), calc(100vw - 248px), 760px);
  }
  #screen-game .main-layout,
  #screen-game .board-panel { place-items: center; }
  #screen-game .bottom-hud {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 9px;
    align-self: center;
    width: 100%;
    height: auto;
    max-height: 100%;
    padding: 10px;
  }
  #screen-game .hud-left { align-self: stretch; grid-template-columns: 30px minmax(0,1fr); }
  #screen-game .hud-player-chip { display: block; width: 30px; height: 30px; }
  #screen-game .hud-center { align-self: center; }
  #screen-game .hud-dice-btn { width: 78px; height: 76px; }
  #screen-game #hud-dice-canvas { width: 48px; height: 48px; }
  #screen-game .hud-right { align-self: stretch; flex-direction: row; justify-content: center; }
  #screen-game .hud-action-button { min-height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  #screen-game .hud-dice-btn { transition: none; }
}

/* Shot 2: the result remains visible beside the current action on compact screens. */
#screen-game .hud-roll-context { display: none; }
#screen-game .hud-roll-context[hidden] { display: none !important; }
#screen-game[data-turn-ui-phase="error"] .hud-dice-btn:not(:disabled) { border-color: #ffb876; box-shadow: 0 12px 28px rgba(255,150,85,.28); }
#screen-game[data-turn-ui-phase="rolling"] .hud-dice-btn,
#screen-game[data-turn-ui-phase="syncing"] .hud-dice-btn { cursor: progress; }
/* L6d fix (board 0910): LAST ROLL stays in the panel at every size. It was shown only on stacked
   layouts, so the side-HUD layouts (desktop, and since L6d wide landscape tablets) never showed it. */
#screen-game .hud-roll-context[data-placeholder="true"] { opacity: .7; }
#screen-game .hud-roll-context:not([hidden]) { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; color: #d6cbff; font-size: .61rem; font-weight: 800; letter-spacing: .03em; }

/* Shot 3: authoritative piece choices, match decisions, and finish state. */
#screen-game .piece-choice-panel[hidden],
#screen-game .match-finish-panel[hidden],
#screen-game .match-confirm-overlay[hidden] { display: none !important; }
#screen-game .piece-choice-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 16px;
  background: rgba(12,15,45,.96);
}
#screen-game .piece-choice-heading {
  grid-column: 1 / -1;
  color: #d6cbff;
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .13em;
}
#screen-game .piece-choice-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid rgba(243,255,32,.48);
  border-radius: 11px;
  color: #fff;
  background: rgba(70,66,111,.56);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
#screen-game .piece-choice-button strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  color: #171b35;
  background: #f3ff20;
  font-size: .9rem;
}
/* QA-5 (5): the label always shows in full ("Enter board", never "Enter bo…"). On narrow
   chooser buttons it wraps between words instead of being cut with an ellipsis. */
#screen-game .piece-choice-button small {
  min-width: 0;
  color: #e9e5fa;
  font-size: .7rem;
  font-weight: 750;
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}
#screen-game .piece-choice-button:hover:not(:disabled),
#screen-game .piece-choice-button:focus-visible {
  outline: 2px solid #f3ff20;
  outline-offset: 2px;
  background: rgba(87,83,135,.86);
}
#screen-game .piece-choice-button:disabled { opacity: .55; cursor: progress; }
#screen-game .match-finish-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  text-align: center;
}
#screen-game .match-finish-kicker { color: #d6cbff; font-size: .67rem; font-weight: 900; letter-spacing: .16em; }
#screen-game .match-finish-panel > strong { color: #fff; font-size: clamp(1.2rem,2vw,1.8rem); }
#screen-game .match-finish-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#screen-game .match-finish-actions button,
#screen-game .match-confirm-actions button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 10px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
#screen-game .match-finish-actions button:first-child,
#screen-game .match-confirm-actions button:last-child { border-color: #f3ff20; color: #171b35; background: #f3ff20; }
#screen-game[data-match-complete="true"] .hud-left,
#screen-game[data-match-complete="true"] .hud-center,
#screen-game[data-match-complete="true"] .hud-right { display: none; }
#screen-game[data-match-complete="true"] #winner-banner { display: none !important; }
#screen-game .match-confirm-overlay {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5,7,27,.78);
}
#screen-game .match-confirm-panel {
  width: min(390px,100%);
  padding: 25px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px;
  background: linear-gradient(150deg,#29245c,#10122f);
  box-shadow: 0 24px 60px rgba(0,0,0,.48);
}
#screen-game .match-confirm-kicker { color: #d6cbff; font-size: .66rem; font-weight: 900; letter-spacing: .16em; }
#screen-game .match-confirm-panel h2 { margin: 8px 0; color: #fff; font-size: 1.35rem; }
#screen-game .match-confirm-panel p:not(.match-confirm-kicker) { color: #e2ddf2; line-height: 1.4; }
#screen-game .match-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
/* L6d: on stacked layouts the piece choice takes over the bottom bar (beside the dice) instead of
   floating over the board or shrinking it. Leave stays in the game menu while choosing. */
@media (max-width: 1100px) and (min-height: 561px) and (max-aspect-ratio: 5/4) {
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) { grid-template-columns: minmax(0,1fr) auto; }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) .hud-right { display: none; }
  /* L6f (board 0923, residual 2): LAST ROLL stays visible while choosing a piece. The player panel
     collapses to its LAST ROLL line in a thin row above the choices instead of disappearing. */
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) { grid-template-rows: auto minmax(0,1fr); row-gap: 2px; }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) .hud-left {
    display: block; grid-column: 1 / -1; grid-row: 1; min-width: 0; min-height: 0; padding: 0 4px;
  }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) .hud-left > :not(.hud-player-info),
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) .hud-player-info > :not(.hud-roll-context) { display: none; }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) .hud-player-info { display: block; min-width: 0; }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) .hud-center { grid-row: 2; }
  #screen-game .piece-choice-panel {
    position: static;
    grid-column: 1;
    grid-row: 2;
    align-self: stretch;
    align-content: center;
    min-width: 0;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 4px;
    padding: 5px 6px;
    border-radius: 12px;
    box-shadow: none;
  }
  #screen-game .piece-choice-button { gap: 5px; min-height: 44px; padding: 3px 5px; }
  #screen-game .piece-choice-button strong { width: 26px; height: 29px; }
  #screen-game .piece-choice-button small { font-size: .6rem; }
  #screen-game .match-finish-panel { width: 100%; gap: 5px; }
  #screen-game .match-finish-panel > strong { font-size: 1rem; }
  #screen-game .match-finish-actions button { min-height: 38px; }
}
@media (max-width: 760px) and (max-aspect-ratio: 5/4), (max-width: 760px) and (max-height: 560px) {
  #screen-game .piece-choice-panel { grid-template-columns: repeat(4,minmax(0,1fr)); }
  #screen-game .piece-choice-heading { font-size: .6rem; }
  #screen-game .piece-choice-button { flex-direction: column; justify-content: center; gap: 2px; }
  #screen-game .piece-choice-button small { max-width: 100%; text-align: center; }
  #screen-game .hud-action-button { min-height: 42px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  #screen-game .piece-choice-panel { position: static; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 5px; gap: 4px; }
  #screen-game .piece-choice-heading { font-size: .54rem; }
  #screen-game .piece-choice-button { flex-direction: row; min-height: 34px; padding: 2px 4px; }
  #screen-game .piece-choice-button strong { width: 22px; height: 24px; font-size: .73rem; }
  #screen-game .piece-choice-button small { font-size: .56rem; }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) { gap: 4px; }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) .hud-dice-btn { height: 48px; width: 58px; }
  #screen-game .bottom-hud:has(.piece-choice-panel:not([hidden])) #hud-dice-canvas { width: 31px; height: 31px; }
  #screen-game .match-finish-panel { min-height: 150px; }
}

#screen-game .hud-dice-btn:disabled .hud-dice-label { color: #fff !important; opacity: 1; }

/* L8 — first-time player clarity. */
/* (6) the four-dot mark is a real button that opens the game menu */
#screen-game .game-menu-button { padding: 0; cursor: pointer; color: inherit; font: inherit; }
#screen-game .game-menu-button:hover,
#screen-game .game-menu-button:focus-visible { background: rgba(255,255,255,.2); outline: 2px solid #f3ff20; outline-offset: 2px; }
#screen-game .game-menu-actions { display: grid; gap: 8px; margin-top: 16px; }
#screen-game .game-menu-actions button {
  min-height: 46px; padding: 0 16px; border: 1px solid rgba(255,255,255,.28); border-radius: 12px;
  background: rgba(255,255,255,.08); color: #fff; font-weight: 800; text-align: left; cursor: pointer;
}
#screen-game .game-menu-actions button:first-child { border-color: #f3ff20; background: #f3ff20; color: #171b35; }
#screen-game .game-menu-actions .game-menu-close { text-align: center; background: transparent; }
/* (2) How to play */
#screen-game .how-to-play-panel { width: min(460px,100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
#screen-game .how-to-play-list { margin: 12px 0 0; padding-left: 20px; color: #e2ddf2; line-height: 1.42; font-size: .92rem; }
#screen-game .how-to-play-list li + li { margin-top: 8px; }
#screen-game .how-to-play-list strong { color: #fff; }
/* (1) "You are Red" start card */
#screen-game .match-coach {
  position: fixed; z-index: 90; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 72px); transform: translateX(-50%);
  width: min(360px, calc(100% - 32px)); display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center;
  padding: 14px 16px; border: 2px solid var(--coach-color, #f3ff20); border-radius: 16px;
  background: linear-gradient(150deg,#29245c,#10122f); box-shadow: 0 18px 44px rgba(0,0,0,.45); color: #fff;
}
#screen-game .match-coach[hidden] { display: none; }
#screen-game .match-coach[data-team="red"] { --coach-color: #E53935; }
#screen-game .match-coach[data-team="blue"] { --coach-color: #1E88E5; }
#screen-game .match-coach[data-team="yellow"] { --coach-color: #FBC02D; }
#screen-game .match-coach[data-team="green"] { --coach-color: #2E7D32; }
#screen-game .match-coach-title { grid-column: 1 / -1; font-size: 1.3rem; font-weight: 950; color: var(--coach-color, #fff); text-shadow: 0 1px 0 rgba(0,0,0,.5); }
#screen-game .match-coach-line { grid-column: 1 / -1; color: #e2ddf2; line-height: 1.38; font-size: .92rem; }
#screen-game .match-coach button { min-height: 40px; padding: 0 14px; border-radius: 10px; font-weight: 800; cursor: pointer; }
#screen-game .match-coach-how { justify-self: start; border: 1px solid rgba(255,255,255,.32); background: rgba(255,255,255,.08); color: #fff; }
#screen-game .match-coach-ok { border: 1px solid #f3ff20; background: #f3ff20; color: #171b35; }
/* (8) capture announcement */
#screen-game .match-toast {
  position: fixed; z-index: 95; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 70px); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; border: 2px solid #ffd166;
  background: #1b1440; color: #fff; font-weight: 900; text-align: center; box-shadow: 0 14px 36px rgba(0,0,0,.5);
  animation: l8-toast-in .28s cubic-bezier(.2,.9,.3,1.3);
}
#screen-game .match-toast[hidden] { display: none; }
#screen-game .match-toast[data-tone="good"] { border-color: #6ee7a0; }
#screen-game .match-toast[data-tone="bad"] { border-color: #ff6b6b; }
@keyframes l8-toast-in { from { opacity: 0; transform: translate(-50%, -10px) scale(.92); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
body.calm #screen-game .match-toast { animation: none; }
/* QA-6: the match log (game menu) and the two newest captures under RECENT (wide HUD). */
.match-feed { margin: 4px 0 14px; text-align: left; }
.match-feed-heading { margin: 0 0 6px; color: #d6cbff; font-size: .72rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.match-feed-empty { margin: 0; color: rgba(255,255,255,.7); font-size: .82rem; }
.match-feed-empty[hidden] { display: none; }
.match-feed-list { margin: 0; padding: 0; list-style: none; max-height: 168px; overflow-y: auto; }
.match-feed-list .match-feed-entry { padding: 6px 2px; border-top: 1px solid rgba(255,255,255,.12); color: #fff; font-size: .86rem; overflow-wrap: anywhere; }
.match-feed-list .match-feed-entry:first-child { border-top: 0; }
.match-feed-turn { display: inline-block; min-width: 4.6em; margin-right: 6px; color: rgba(255,255,255,.62); font-size: .74rem; font-weight: 700; }
.match-feed-team { font-weight: 900; }
.match-feed-team[data-team="red"] { color: #ff6b6b; }
.match-feed-team[data-team="blue"] { color: #6cb6ff; }
.match-feed-team[data-team="yellow"] { color: #ffd166; }
.match-feed-team[data-team="green"] { color: #6ee7a0; }
#screen-game .hud-event-feed { margin: 2px 0 0; padding: 0; list-style: none; color: rgba(255,255,255,.83); font-size: .74rem; }
#screen-game .hud-event-feed .match-feed-turn { display: none; }
/* (7) the avatar always shows the player's colour and initial when there is no portrait */
#screen-game .hud-player-chip[data-portrait="fallback"] { display: grid; place-items: center; }
#screen-game .hud-player-chip[data-portrait="fallback"]::after {
  content: attr(data-initial); color: #fff; font-weight: 950; font-size: 1rem; text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
/* (7) entry arrows stay readable above pieces */
#board-svg .start-entry-arrow { filter: drop-shadow(0 0 1.2px rgba(0,0,0,.55)); }

/* QA-7 (audit P1-8): resting pieces read clearly on their cell.
   Native boards drew every figure at one CSS scale, then base pieces got the 2.2x body scale on
   top, so a piece on the track showed at under half its yard size (about 21px on a 23px cell at
   375px wide), with its body standing on the cell above. On the track the figure now fills about
   one cell. It is lowered so it stands on its own cell, and its pedestal sits under its feet.
   Scale .96 keeps a landed piece close to the size the L15 walk stand-in ends at (1).
   Presentation only: token positions, hit areas, clones and engine state are unchanged. */
/* P1 (2026-12-01): the sprite figure's size and place on its cell now come from the one size rule
   (figure-size.js + piece-size.css). These two rules only reach the vector fallback figure. */
#screen-game #board-svg .game-token:not(.token-in-base) .warrior-figure:not(:has(> .warrior-sprite)) {
  transform-origin: 50% 88% !important;
  transform: translateY(10px) scale(.96) !important;
}
#screen-game #board-svg .game-token.selectable:not(.token-in-base) .warrior-figure:not(:has(> .warrior-sprite)) {
  transform: translateY(8.5px) scale(1) !important;
}
#screen-game #board-svg .game-token:not(.token-in-base) .token-pedestal {
  transform: translateY(10px) scale(.92);
}
/* Two colours on one square share it side by side: each figure shrinks so both stay readable. */
#screen-game #board-svg .game-token.token-shared-cell:not(.token-in-base) .warrior-figure:not(:has(> .warrior-sprite)) {
  transform: translateY(8px) scale(.7) !important;
}
#screen-game #board-svg .game-token.token-shared-cell:not(.token-in-base) .token-pedestal {
  transform: translateY(8px) scale(.66);
}

/* QA-7 (audit P1-9): no empty band on tall phones.
   The board is width-bound on a tall phone, so a fixed top bar plus board plus deck left about a
   quarter of the screen empty (board 0916 split it above and below the board). Now the board sits
   directly on the control deck, and the top bar takes the leftover height: its strip stays 52px at
   the top, and the turn banner (whose turn it is, plus what to do) is centred, larger, in the
   space above the board. The deck stays at the bottom for thumb reach, and the board width is
   unchanged. Landscape and short phones keep their layouts. */
@media (max-width: 760px) and (max-aspect-ratio: 5/4) and (min-height: 561px) {
  #screen-game.active-screen { grid-template-rows: minmax(var(--game-topbar-height), 1fr) auto; }
  #screen-game .game-topbar {
    align-items: start;
    border-bottom: 0;
    box-shadow: none;
    background: linear-gradient(180deg, rgba(27,31,35,.94), rgba(27,31,35,.94)) top / 100% var(--game-topbar-height) no-repeat;
  }
  #screen-game .game-turn-center { align-self: center; }
  #screen-game .game-dock { height: auto; grid-template-rows: auto var(--game-hud-height); row-gap: 10px; }
  #screen-game .main-layout,
  #screen-game .board-panel { height: auto; }
}
/* Tall phones have room for the full banner; shorter ones keep the compact one-line title. */
@media (max-width: 760px) and (max-aspect-ratio: 5/4) and (min-height: 700px) {
  #screen-game .game-turn-center { gap: 4px; padding: 6px 0 10px; }
  #screen-game .game-turn-kicker { display: block; font-size: .62rem; }
  #screen-game .game-turn-main { gap: 10px; }
  #screen-game .game-turn-orb { width: 30px; height: 30px; font-size: .8rem; }
  #screen-game .game-turn-title { font-size: clamp(1.05rem, 5.4vw, 1.5rem); }
  #screen-game .game-turn-detail { display: block; max-width: 86vw; font-size: .8rem; color: rgba(255,255,255,.72); }
}

/* Placements (2026-11-30): final 1st–4th standings in the match finish panel. */
#screen-game .match-finish-standings {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  color: #d6cbff; font-size: .78rem; font-weight: 800;
}
