/* Cashgammon V1.12: readable inversion, padded match header and landscape focus. */
/* Counterrotate the TEXT carrier, not an animated/hovered ancestor. */
#gameBoard .doubling-cube,
#gameBoard .doubling-cube:hover { transform:none; }
#gameBoard.board-inverted .cube-slot { transform:rotate(180deg); }
#gameBoard.board-inverted .doubling-cube { transform:none; }
.bar-count { display:grid; place-items:center; }
#gameBoard.board-inverted .bar-count { transform:rotate(180deg); }
#gameBoard.board-inverted .point-number { transform:translateX(-50%) rotate(180deg); }
#gameBoard.board-inverted .checker-count { transform:rotate(180deg); }
#gameBoard.board-inverted .combined-label { transform:translate(-50%,-50%) rotate(180deg); }
#gameBoard .off-label { writing-mode:horizontal-tb; font-size:7px; letter-spacing:.08em; }
/* The old pulsing transform replaced the counterrotation on off-tray dice counts. */
#gameBoard .bearoff-tray.combined-destination::after { animation:offCountGlow 1.45s ease-in-out infinite; }
#gameBoard.board-inverted .bearoff-tray.combined-destination::after { transform:rotate(180deg); }
@keyframes offCountGlow { 0%,100% { opacity:.68; } 50% { opacity:1; } }

#gameView .game-topbar {
  display:grid; grid-template-columns:44px minmax(0,1fr) auto auto auto;
  align-items:center; gap:14px; min-height:78px; height:auto; flex-basis:auto;
  padding:14px 18px; margin:0 0 12px; border:1px solid rgba(167,188,214,.17);
  border-radius:18px; background:linear-gradient(115deg,rgba(20,27,37,.97),rgba(11,16,23,.97));
  box-shadow:0 8px 24px rgba(0,0,0,.14); overflow:visible;
}
#gameView .game-topbar > .icon-button { width:44px; height:44px; min-height:44px; flex-shrink:0; }
#gameView .game-mode-copy,#gameView .game-mode-copy > div { min-width:0; }
#gameView .game-mode-copy { gap:12px; }
#gameView .game-mode-copy strong { display:block; font-size:14px; line-height:1.35; white-space:normal; overflow-wrap:anywhere; }
#gameView .game-mode-copy small { display:block; font-size:10px; line-height:1.5; white-space:normal; overflow-wrap:anywhere; color:#a6b4c8; }
#gameView .game-pot { gap:2px; min-width:64px; padding-left:16px; border-left:1px solid rgba(167,188,214,.15); }
#gameView .game-pot strong { font-size:20px; line-height:1.2; }
#gameView .game-status-chip { white-space:nowrap; }
#gameView .match-fairness { display:flex; align-items:center; justify-content:center; gap:7px; min-width:44px; min-height:44px; padding:9px 12px; border-radius:12px; }
.match-fairness-icon { font-size:13px; width:18px; height:18px; display:grid; place-items:center; border:1px solid currentColor; border-radius:50%; line-height:1; }
body.match-focus #gameView .game-topbar { margin:0; padding:9px 14px; min-height:64px; }
body.match-focus #gameView .main-content { overflow:visible; }
@media (max-width:1100px) {
  #gameView .game-topbar { grid-template-columns:44px minmax(0,1fr) auto auto; }
  #gameView .game-status-chip { display:none; }
}
@media (max-width:720px) {
  #gameView .game-topbar { gap:8px; padding:10px; border-radius:16px; min-height:66px; }
  #gameView .game-mode-copy { display:block; }
  #gameView .game-mode-copy > .mode-tag { display:none; }
  #gameView .game-mode-copy strong { font-size:12px; }
  #gameView .game-mode-copy small { font-size:9px; }
  #gameView .game-pot { padding-left:8px; min-width:46px; }
  #gameView .game-pot strong { font-size:17px; }
  #gameView .match-fairness { padding:0; width:44px; height:44px; }
  #gameView .match-fairness-label { display:none; }
}
/* Allow native full screen on the document, keeping dialogs and celebrations inside it. */
html:fullscreen { background:#090d13; }
body.match-focus .main-content { height:100%; }

/* This overlay is outside the inert game shell. Restore is always accessible. */
.rotate-match-prompt[hidden] { display:none !important; }
.rotate-match-prompt {
  position:fixed; inset:0; z-index:3000; overflow:auto; overscroll-behavior:contain;
  display:flex; align-items:center; justify-content:center;
  padding:calc(24px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background:radial-gradient(ellipse at 50% 27%,rgba(104,153,45,.18),transparent 52%),#0b1018;
}
.rotate-prompt-content { max-width:380px; width:100%; text-align:center; padding:16px 0; }
.rotate-prompt-content .section-kicker { letter-spacing:.18em; color:var(--lime); }
.rotate-phone-graphic { width:148px; height:120px; margin:24px auto 26px; position:relative; display:grid; place-items:center; }
.rotate-phone-outline { width:66px; height:104px; border:2px solid #c8ff38; border-radius:15px; background:linear-gradient(145deg,#1e2b23,#0c1616); box-shadow:0 0 42px rgba(183,255,56,.13); position:relative; transform:rotate(90deg); animation:rotatePhoneHint 3.4s ease-in-out infinite; }
.rotate-phone-outline::before { content:''; position:absolute; width:22px; height:4px; top:7px; left:20px; border-radius:9px; background:#708755; }
.rotate-phone-outline::after { content:''; position:absolute; inset:22px 9px 12px; background:repeating-linear-gradient(90deg,#a9db31 0 6px,#60519f 6px 12px); clip-path:polygon(0 0,100% 0,100% 28%,0 28%,0 70%,100% 70%,100% 100%,0 100%); opacity:.8; }
.rotate-arrow { position:absolute; right:1px; top:0; color:#9baf83; font-size:38px; line-height:1; }
@keyframes rotatePhoneHint { 0%,12% { transform:rotate(0deg); } 36%,85% { transform:rotate(90deg); } 100% { transform:rotate(0deg); } }
.rotate-prompt-content h2 { color:#f4f7fb; font-size:clamp(24px,6.6vw,31px); line-height:1.18; margin:0 0 14px; letter-spacing:-.025em; }
.rotate-prompt-content > p { font-size:14px; line-height:1.7; color:#b0bdce; margin:0 0 22px; }
.rotate-prompt-note { display:flex; align-items:flex-start; gap:8px; text-align:left; margin-bottom:24px; border:1px solid #2d3b32; background:#121d19; border-radius:12px; padding:12px; color:#b8ccba; font-size:12px; line-height:1.6; }
.rotate-prompt-note .live-dot { margin-top:7px; flex-shrink:0; }
#rotateRestoreButton { width:100%; min-height:48px; font-size:13px; }
.rotate-prompt-content .rotate-help { margin:14px 0 0; font-size:11px; line-height:1.6; color:#8795a8; }
body.match-rotate-required { overflow:hidden; }
body.match-rotate-required .app-shell,
body.match-rotate-required #modalBackdrop { pointer-events:none; visibility:hidden; }

/* Mobile focus uses the width of the phone: one header, board left, tools right. */
body.match-focus-mobile.match-focus-landscape .main-content {
  padding:max(6px,var(--safe-top)) max(10px,var(--safe-right)) max(6px,var(--safe-bottom)) max(10px,var(--safe-left));
}
body.match-focus-mobile.match-focus-landscape #gameView {
  display:grid; grid-template-columns:minmax(0,1fr) clamp(188px,26vw,242px);
  grid-template-rows:auto auto minmax(0,1fr) auto; gap:6px 8px;
}
body.match-focus-mobile.match-focus-landscape #gameView .game-topbar {
  grid-area:1 / 1 / 2 / 3; grid-template-columns:44px minmax(0,1fr) auto 44px;
  height:auto; min-height:58px; padding:6px 12px; gap:10px; border-radius:14px;
}
body.match-focus-mobile.match-focus-landscape #gameView .game-topbar .game-status-chip,
body.match-focus-mobile.match-focus-landscape #gameView .game-mode-copy > .mode-tag { display:none; }
body.match-focus-mobile.match-focus-landscape #gameView .game-mode-copy strong { font-size:12px; }
body.match-focus-mobile.match-focus-landscape #gameView .game-mode-copy small { font-size:9px; }
body.match-focus-mobile.match-focus-landscape #gameView .match-fairness { width:44px; height:44px; padding:0; }
body.match-focus-mobile.match-focus-landscape .match-fairness-label { display:none; }
body.match-focus-mobile.match-focus-landscape .game-layout,
body.match-focus-mobile.match-focus-landscape .game-sidebar { display:contents; }
body.match-focus-mobile.match-focus-landscape .board-stage { grid-area:2 / 1 / 5 / 2; display:flex; flex-direction:column; min-height:0; height:100%; }
body.match-focus-mobile.match-focus-landscape .board-frame { width:100%; height:100%; min-height:0; max-height:none; flex:1; aspect-ratio:auto; padding:7px; border-radius:17px; }
body.match-focus-mobile.match-focus-landscape .board-grid { grid-template-columns:minmax(0,1fr) 30px minmax(0,1fr) 24px; border-radius:11px; }
body.match-focus-mobile.match-focus-landscape .board-corner { width:16px; height:16px; border-radius:5px; }
body.match-focus-mobile.match-focus-landscape .board-caption { display:none; }
body.match-focus-mobile.match-focus-landscape .player-rail { display:none; }
body.match-focus-mobile.match-focus-landscape .match-tools { grid-area:2 / 2 / 3 / 3; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:7px 4px; padding:7px 6px; margin:0; min-height:0; border-radius:12px; }
body.match-focus-mobile.match-focus-landscape .series-info { gap:3px; }
body.match-focus-mobile.match-focus-landscape .series-info strong { font-size:11px; }
body.match-focus-mobile.match-focus-landscape .series-info small { font-size:9px; }
body.match-focus-mobile.match-focus-landscape .series-score { gap:4px; }
body.match-focus-mobile.match-focus-landscape .series-score > strong { font-size:20px; }
body.match-focus-mobile.match-focus-landscape .score-player { gap:0; }
body.match-focus-mobile.match-focus-landscape .score-player > span { display:none; }
body.match-focus-mobile.match-focus-landscape .score-checker { width:9px; height:9px; }
body.match-focus-mobile.match-focus-landscape .match-tool-actions { display:grid; grid-column:1 / -1; grid-template-columns:44px 44px minmax(0,1fr); gap:4px; }
body.match-focus-mobile.match-focus-landscape .match-tool-actions button { padding:4px; min-height:44px; min-width:0; }
body.match-focus-mobile.match-focus-landscape #focusMatchButton span { font-size:10px; }
body.match-focus-mobile.match-focus-landscape #invertBoardButton span,
body.match-focus-mobile.match-focus-landscape #roundForfeitButton span { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
body.match-focus-mobile.match-focus-landscape .turn-panel { grid-area:3 / 2 / 4 / 3; display:grid; align-self:start; grid-template-areas:'title dice' 'action action'; grid-template-columns:minmax(0,1fr) auto; gap:6px; padding:9px; min-height:0; max-height:100%; overflow-y:auto; border-radius:12px; }
body.match-focus-mobile.match-focus-landscape .turn-panel > .section-kicker { display:none; }
body.match-focus-mobile.match-focus-landscape .turn-title { margin:0; gap:7px; grid-area:title; }
body.match-focus-mobile.match-focus-landscape .turn-avatar { width:26px; height:26px; flex:0 0 auto; font-size:12px; }
body.match-focus-mobile.match-focus-landscape #turnName { font-size:11px; }
body.match-focus-mobile.match-focus-landscape #turnInstruction { font-size:9px; line-height:1.3; }
body.match-focus-mobile.match-focus-landscape .dice-zone { grid-area:dice; padding:4px; min-height:36px; margin:0; gap:7px; }
body.match-focus-mobile.match-focus-landscape .game-die,
body.match-focus-mobile.match-focus-landscape .die-placeholder { width:28px; height:28px; border-radius:7px; padding:5px; }
body.match-focus-mobile.match-focus-landscape .die-dot { width:4px; height:4px; }
body.match-focus-mobile.match-focus-landscape .turn-panel > #rollButton,
body.match-focus-mobile.match-focus-landscape .turn-panel > #endTurnButton { grid-area:action; min-height:44px; height:auto; padding:8px; margin:0; font-size:12px; }
body.match-focus-mobile.match-focus-landscape .roll-key { display:none; }
body.match-focus-mobile.match-focus-landscape .round-notice { grid-area:4 / 2 / 5 / 3; margin:0; padding:8px; display:flex; flex-direction:column; align-items:stretch; gap:6px; max-height:120px; overflow-y:auto; }
body.match-focus-mobile.match-focus-landscape .round-notice[hidden] { display:none; }
body.match-focus-mobile.match-focus-landscape .round-notice > div:first-child { flex:0 0 auto; }
body.match-focus-mobile.match-focus-landscape .round-notice strong { font-size:11px; }
body.match-focus-mobile.match-focus-landscape .round-notice small { font-size:9px; }
body.match-focus-mobile.match-focus-landscape .round-notice-actions { gap:4px; }
body.match-focus-mobile.match-focus-landscape .round-notice button { flex:1; font-size:10px; padding:5px; min-height:44px; }
@media (prefers-reduced-motion:reduce) {
  .rotate-phone-outline { animation:none; transform:rotate(90deg); }
  #gameBoard .bearoff-tray.combined-destination::after { animation:none; }
}
