/* Minimal, readable styling */
:root{
  --bg:#0f141a;
  --panel:#141b22;
  --card:#18212b;
  --text:#e8eef6;
  --muted:#93a4b8;
  --line:#2a3644;
  --btn:#273546;
  --btn2:#1f2a36;
  --accent:#4aa3ff;
  --danger:#ff5b5b;
  --ok:#38d27a;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  --tab-ui-scale: 1;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --right-sidebar-width: 520px;
}

*{box-sizing:border-box}
html,body{height:100%; min-height:100%; overflow:hidden; overscroll-behavior:none}
body{
  margin:0;
  font-family:var(--sans);
  background: radial-gradient(1200px 900px at 20% 10%, rgba(74,163,255,.12), transparent 55%),
              radial-gradient(900px 700px at 90% 40%, rgba(56,210,122,.10), transparent 55%),
              var(--bg);
  color:var(--text);
  overflow:hidden;
  min-height:0;
}
#app{height:100dvh; min-height:100vh; display:flex; flex-direction:column}
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 22px;
  border-bottom:1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
}
.brand .title{font-size:20px; font-weight:700; letter-spacing:.3px}
.brand .subtitle{font-size:12px; color:var(--muted); margin-top:2px}
.status{display:flex; align-items:center; gap:10px; color:var(--muted); font-size:13px}
.connInline{display:flex; align-items:center; gap:10px; color:var(--muted); font-size:13px; margin-top:6px}
.connInline .dot{width:9px; height:9px}
.connText{color:var(--muted)}
.dot{width:10px; height:10px; border-radius:999px; background:#4b5563; box-shadow:0 0 0 4px rgba(255,255,255,.04) inset}
.dot.ok{background:var(--ok)}
.dot.bad{background:var(--danger)}
.layout{
  flex:1;
  display:grid;
  grid-template-columns: 360px 1fr;
  gap:16px;
  padding:16px;
  height:100%;
  min-height:0;
  overflow:hidden;
}

/* During gameplay, the HUD overlays move onto the board. */
body.in-game .layout{grid-template-columns: minmax(0, 1fr); grid-template-rows:minmax(0, 1fr); padding:0; gap:0; height:100%; min-height:0; flex:1 1 auto;}
body.in-game .panel{display:none;}
.panel{display:flex; flex-direction:column; gap:16px; height:100%; overflow-y:auto; padding-right:6px; padding-bottom:88px}
.card{
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:14px;
  box-shadow:var(--shadow);
}
.card h2{margin:0 0 12px 0; font-size:14px; letter-spacing:.3px; color:var(--text)}

/* Card headers with inline status */
.cardTitleRow{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px}
.cardTitleRow h2{margin:0; font-size:14px; letter-spacing:.3px; color:var(--text)}
.connInline.connTight{margin-top:0; gap:8px; font-size:12px}
.connInline.connTight .dot{width:9px; height:9px}
.label{font-size:12px; color:var(--muted); margin:8px 0 6px}
.labelTiny{font-size:11px; color:var(--muted); margin:8px 0 6px}
.input{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.25);
  color:var(--text);
  outline:none;
}
.input:focus{border-color:rgba(74,163,255,.55); box-shadow:0 0 0 4px rgba(74,163,255,.12)}
.input.code{font-family:var(--mono); text-transform:uppercase; letter-spacing:1.5px}
.row{display:flex; gap:10px; margin-top:10px}
.btn{
  appearance:none;
  border:1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:600;
}
.btn:hover{filter:brightness(1.08)}
.btn:disabled{opacity:.45; cursor:not-allowed}
.btn.primary{
  border-color:rgba(74,163,255,.45);
  background: linear-gradient(180deg, rgba(74,163,255,.25), rgba(74,163,255,.08));
}
.divider{height:1px; background:var(--line); margin:12px 0}
.error{
  margin-top:10px;
  padding:10px;
  border-radius:12px;
  border:1px solid rgba(255,91,91,.45);
  background: rgba(255,91,91,.10);
  color:#ffd4d4;
  font-size:13px;
}
.hidden{display:none !important}
.roomBox{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  background: rgba(0,0,0,.22);
}

.rankedScenarioVote{margin-top:14px;padding:14px;border:1px solid rgba(224,174,58,.42);border-radius:14px;background:rgba(224,174,58,.08)}
.rankedScenarioVoteTitle{color:#fff;font-size:15px;font-weight:850}
.rankedScenarioOptions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:12px}
.rankedScenarioOption{display:flex;min-height:76px;flex-direction:column;align-items:flex-start;justify-content:space-between;gap:8px;padding:12px;border:1px solid #36566b;border-radius:11px;background:#111d27;color:#eef5f8;text-align:left;cursor:pointer}
.rankedScenarioOption:hover{border-color:#e0ae3a;background:#172937}
.rankedScenarioOption.selected{border-color:#e0ae3a;box-shadow:0 0 0 2px rgba(224,174,58,.2) inset;background:rgba(224,174,58,.13)}
.rankedScenarioOption strong{font-size:13px;line-height:1.25}
.rankedScenarioOption span{color:var(--muted);font-family:var(--mono);font-size:10px}
.roomTop{display:flex; align-items:center; justify-content:space-between; gap:10px}
.lobbyReadyActions{display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap}
.roomCode{
  font-family:var(--mono);
  font-size:18px;
  letter-spacing:2px;
}
.playersList{display:flex; flex-direction:column; gap:8px; margin-top:10px}
.playerRow{display:flex; align-items:center; justify-content:space-between; gap:10px}
.playerTag{display:flex; align-items:center; gap:10px}
.lobbyReadyStatus{margin-left:auto; padding:4px 9px; border:1px solid var(--line); border-radius:999px; font-family:var(--mono); font-size:10px; font-weight:800; letter-spacing:.03em; white-space:nowrap}
.lobbyReadyStatus.ready{color:var(--ok); border-color:rgba(56,210,122,.32); background:rgba(56,210,122,.10)}
.lobbyReadyStatus.waiting{color:var(--muted); background:rgba(255,255,255,.03)}
.badge{width:10px; height:10px; border-radius:999px}
.colorPickerRow{margin-top:8px}
.colorPicker{display:flex; flex-wrap:wrap; gap:8px; margin-top:8px}
.colorChip{
  width:26px; height:26px;
  border-radius:999px;
  border:1px solid var(--line);
  cursor:pointer;
  position:relative;
  box-shadow:0 2px 8px rgba(0,0,0,.25);
}
.colorChip.selected{
  box-shadow:0 0 0 3px rgba(255,255,255,.18), 0 2px 8px rgba(0,0,0,.25);
}
.colorChip.disabled{opacity:.35; cursor:not-allowed; filter:grayscale(.25)}
.colorChip .check{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size:14px;
  font-weight:900;
  user-select:none;
}
.turnInfo{font-size:13px; color:var(--text); line-height:1.35}
.actions{display:flex; gap:10px; flex-wrap:wrap; margin-top:10px}
.hint{margin-top:10px; color:var(--muted); font-size:12px; line-height:1.3}
.resourcesBox{display:flex; flex-direction:column; gap:10px; font-size:13px}
.pRes{border:1px solid var(--line); border-radius:12px; padding:10px; background: rgba(0,0,0,.18)}
.pRes.turnActive{border-color:rgba(74,163,255,.55); box-shadow:0 0 0 3px rgba(74,163,255,.12) inset}
.pResHead{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px}
.pResName{display:flex; align-items:center; gap:10px; font-weight:700}
.pResGrid{display:grid; grid-template-columns: repeat(5, 1fr); gap:8px; font-family:var(--mono); font-size:12px}
.resCell{display:flex; align-items:center; justify-content:flex-start; gap:6px; padding:2px 0}
.resIcon{width:18px; height:18px; object-fit:contain; filter:drop-shadow(0 1px 2px rgba(0,0,0,.35))}
.resVal{font-family:var(--mono); font-size:12px; color:rgba(232,238,246,.96)}
.pPieceGrid{display:grid; grid-template-columns: repeat(4, 1fr); gap:8px; font-family:var(--mono); font-size:12px; margin-top:8px; color:rgba(232,238,246,.92)}
.bankRes{border:1px solid var(--line); border-radius:12px; padding:10px; background: rgba(0,0,0,.18)}
.bankResHead{font-weight:800; color:var(--text); margin-bottom:8px; font-size:12px; letter-spacing:.3px}
.smallNote{margin-top:10px; font-size:11px; color:var(--muted)}
.boardWrap{
  border:1px solid var(--line);
  border-radius:var(--radius);
  overflow:hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
  box-shadow:var(--shadow);
  display:flex; flex-direction:column;
  position:relative;
  height:100%;
  min-height:0;
}
body.in-game .boardWrap{border:none; border-radius:0; box-shadow:none; height:100%; min-height:0; padding-right:var(--right-sidebar-width, 520px);}
body.in-game .boardFooter{display:none;}
#board{
  touch-action:none;
  width:100%;
  flex:1;
  min-width:0;
  min-height:0;
  height:auto;
  display:block;
  background: #5f6f7c; /* ocean backdrop (darker muted grey-blue) */
}
.yourRollBanner{
  position:absolute;
  z-index:24;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  pointer-events:none;
  user-select:none;
  white-space:nowrap;
  color:#ff1f2d;
  font-size:clamp(44px, 8vw, 112px);
  font-weight:1000;
  line-height:1;
  letter-spacing:.08em;
  text-transform:uppercase;
  text-shadow:0 3px 0 rgba(55,0,0,.85), 0 0 12px rgba(255,255,255,.85), 0 0 32px rgba(255,0,25,.75);
}
.extraTurnCenterBanner{position:absolute;z-index:25;left:50%;top:50%;transform:translate(-50%,-50%);display:flex;align-items:center;gap:.18em;pointer-events:none;user-select:none;white-space:nowrap;color:#ff2638;font-size:clamp(44px,8vw,112px);font-weight:1000;line-height:1;letter-spacing:.06em;text-transform:uppercase;text-shadow:0 3px 0 rgba(55,0,0,.85),0 0 12px rgba(255,255,255,.85),0 0 32px rgba(255,0,25,.75);animation:extraTurnCenterPop .34s cubic-bezier(.2,1.25,.45,1)}.extraTurnCenterBanner.hidden{display:none}.extraTurnCenterBanner span{font-size:1.08em;line-height:.7}@keyframes extraTurnCenterPop{from{opacity:0;transform:translate(-50%,-50%) scale(.68)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}
.boardFooter{
  display:flex; justify-content:space-between;
  padding:10px 12px;
  border-top:1px solid var(--line);
  color:var(--muted);
  font-size:12px;
}

/* Resources panel overlay */
.resourcesOverlay{
  position:absolute;
  left:6px;
  top:56px;
  right:auto;
  bottom:auto;
  z-index:13;
  width:min(360px, 34vw);
  max-width:400px;
  padding:12px;
  background: rgba(14,19,28,.78);
  backdrop-filter: blur(6px);
}
.resourcesOverlay h2{margin:0 0 10px 0}
.resourcesOverlay .resourcesBox{gap:8px; font-size:12px}
.resourcesOverlay .pResGrid,
.resourcesOverlay .pPieceGrid{font-size:11px}
.resourcesOverlay > .smallNote{display:none;}

.resSummaryRow{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  background: rgba(0,0,0,.18);
}
.resSummaryRow + .resSummaryRow{margin-top:8px;}
.resSummaryRow.turnActive{border-color:rgba(74,163,255,.5); box-shadow:0 0 0 2px rgba(74,163,255,.16) inset;}
.resSummaryRow.spectatorSelectable{cursor:pointer; transition:border-color .15s ease, background .15s ease;}
.resSummaryRow.spectatorSelectable:hover{border-color:rgba(74,163,255,.75); background:rgba(74,163,255,.08);}
.resSummaryRow.spectatorSelected{border-color:#4aa3ff; box-shadow:0 0 0 2px rgba(74,163,255,.28) inset;}
.historyReplayBar{position:absolute; z-index:35; top:12px; left:50%; transform:translateX(-50%); display:flex; width:min(760px,calc(100% - 32px)); align-items:center; justify-content:center; flex-wrap:wrap; gap:8px; padding:9px 10px; border:1px solid rgba(74,163,255,.55); border-radius:12px; background:rgba(8,16,28,.94); box-shadow:0 12px 32px rgba(0,0,0,.38);}
.historyReplayBar.hidden{display:none!important;}
.historyReplayStatus{display:flex; min-width:0; max-width:520px; flex:1 1 220px; flex-direction:column; gap:2px; color:var(--text);}
.historyReplayStatus span{overflow:hidden; color:var(--muted); font-size:12px; text-overflow:ellipsis; white-space:nowrap;}
.historyReplayTimeline{display:grid; grid-template-columns:auto minmax(100px,1fr) auto; align-items:center; flex:1 0 100%; width:100%; gap:10px; padding:1px 4px 2px;}
.historyReplayTimelineLabel{color:var(--muted); font-family:var(--mono); font-size:10px; font-weight:700; white-space:nowrap;}
.historyReplaySlider{width:100%; min-width:0; height:22px; margin:0; accent-color:var(--accent); cursor:pointer; touch-action:none;}
.historyReplaySlider:disabled{cursor:not-allowed; opacity:.45;}
.historyReplaySlider:focus-visible{outline:2px solid rgba(74,163,255,.8); outline-offset:3px; border-radius:999px;}
.resSummaryMain{display:flex; align-items:center; gap:8px; min-width:0; width:100%;}
.resSummaryName{font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:116px;}
.resSummaryStats{display:flex; align-items:center; gap:8px; flex:1 1 auto; min-width:0; flex-wrap:wrap;}
.resSummaryStat{font-family:var(--mono); font-size:11px; color:#dbe7f5; white-space:nowrap;}
.resSummaryRoad{display:inline-flex; align-items:center; gap:5px;}
.resSummaryRoadSwatch{width:12px; height:6px; border-radius:999px; box-shadow:0 0 0 1px rgba(255,255,255,.16) inset;}
.resSummaryVp{margin-left:auto; display:inline-flex; align-items:center; gap:6px; justify-content:flex-end;}
.resSummaryBadges{font-size:10px; color:var(--muted); letter-spacing:.02em;}

.rightSidebar{
  position:absolute;
  top:0;
  right:0;
  bottom:0;
  width:var(--right-sidebar-width, 520px);
  z-index:12;
  display:flex;
  border-left:1px solid rgba(255,255,255,.08);
  background: rgba(14,19,28,.76);
  backdrop-filter: blur(8px);
  box-shadow:-18px 0 48px rgba(0,0,0,.24);
}
.rightSidebar.hidden{display:none !important;}
.rightSidebarResize{
  width:8px;
  cursor:ew-resize;
  flex:0 0 8px;
  position:relative;
  touch-action:none;
}
.rightSidebarResize::before{
  content:'';
  position:absolute;
  top:50%;
  left:2px;
  width:3px;
  height:72px;
  border-radius:999px;
  transform:translateY(-50%);
  background:rgba(255,255,255,.12);
}
.rightSidebarInner{
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:10px 10px 10px 6px;
  overflow-y:auto;
}
.rightSidebarInner > .card{margin:0;}
.rightSidebarInner > .card.hidden{display:none !important;}
.rightSidebar #resourcesCard{
  position:relative;
  inset:auto;
  flex:0 0 auto;
  width:100%;
  max-width:none;
  padding:0;
  border:0;
  box-shadow:none;
  background:transparent;
}
.rightSidebar #resourcesCard > .panelScaleContent > .smallNote{display:none;}
/* Resources fill the right dock at every text scale; counteract zoom's box sizing. */
.rightSidebar #resourcesCard{width:100%; max-width:none; min-width:0; box-sizing:border-box;}

.rightSidebarInner > #logCard,
.rightSidebarInner > #devCard{flex:1 1 0; min-height:0;}
.rightSidebarResourceDock{
  --tool-ui-scale: 1;
  flex:0 0 auto;
  border-top:1px solid rgba(255,255,255,.08);
  padding-top:10px;
  min-height:0;
}
.rightSidebarResourcesBody{display:flex; flex-direction:column; gap:10px; zoom: var(--tool-ui-scale); transform-origin: top left;}
.rightSidebarBankTitle{font-size:12px; font-weight:800; letter-spacing:.3px; color:var(--text);}
.rightSidebarResStrip,
.rightSidebarPieceStrip{display:grid; gap:10px;}
.rightSidebarResStrip{grid-template-columns:repeat(5, minmax(0, 1fr));}
.rightSidebarPieceStrip{grid-template-columns:repeat(4, minmax(0, 1fr));}
.rightSidebarSeparator{height:1px; background:rgba(255,255,255,.08);}
.rightSidebarMeta{display:flex; flex-wrap:wrap; align-items:center; gap:8px 14px; font-family:var(--mono); font-size:11px; color:#dbe7f5;}
.rightSidebarMetaStrong{font-size:17px; font-weight:900; color:var(--text); letter-spacing:.02em;}
.rightSidebarNote{font-size:11px; color:var(--muted);}
.rightSidebar .logOverlay,
.rightSidebar #devCard.rightSidebarDocked{
  position:relative;
  left:auto;
  right:auto;
  top:auto;
  bottom:auto;
  width:100%;
  max-width:none;
  padding:0;
  background:transparent;
  backdrop-filter:none;
  border:0;
  border-radius:0;
  box-shadow:none;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:0;
}
.rightSidebar .logOverlay .cardTitleRow,
.rightSidebar #devCard.rightSidebarDocked .devHeaderRow{margin-bottom:8px;}
.rightSidebar .logOverlay .logList{max-height:none; flex:1 1 auto; min-height:0;}
.rightSidebar #devCard.rightSidebarDocked .panelScaleContent{display:flex; flex-direction:column; min-height:0; gap:8px;}
.rightSidebar #devCard.rightSidebarDocked .devHand{flex:1 1 auto; min-height:0; overflow:auto; margin-top:0;}
body.in-game .rightHud{right:calc(var(--right-sidebar-width, 520px) + 8px); top:66px;}
body.in-game .hudBar{max-width:calc(100% - var(--right-sidebar-width, 520px) - 12px);}
body.in-game .yourRollBanner{left:calc((100% - var(--right-sidebar-width, 520px)) / 2);}
body.in-game .pausedOverlay{right:var(--right-sidebar-width, 520px);}
body.in-game #errBox{
  position:absolute;
  z-index:40;
  top:72px;
  left:12px;
  max-width:calc(100% - var(--right-sidebar-width, 520px) - 24px);
  margin:0;
  background:rgba(64,22,27,.96);
}

/* Game log overlay (toggleable + draggable) */
.logOverlay{
  position:absolute;
  left:auto;
  top:56px;
  right:6px;
  bottom:auto;
  z-index:14;
  width:min(520px, 56vw);
  max-width:620px;
  padding:12px;
  background: rgba(14,19,28,.78);
  backdrop-filter: blur(6px);
}
.logOverlay .cardTitleRow{margin-bottom:10px}
.logOverlay h2{margin:0}
.logOverlay{ --tool-ui-scale: 1; }
.logOverlay .logScaleHost{ margin-left:auto; display:flex; align-items:center; }
.logOverlay .logScaleHost .toolScaleControl{ padding:3px 5px; gap:4px; }
.logOverlay .logScaleHost .tabScaleBtn{ width:24px; height:24px; border-radius:8px; }
.logOverlay .logScaleHost .tabScaleLabel{ min-width:52px; }
.logOverlay .logList{max-height:320px; zoom: var(--tool-ui-scale)}
.logOverlay #logHideBtn{padding:6px 10px}

/* Board HUD overlays */
.hudBar{
  position:absolute;
  z-index:26;
  padding:10px 12px;
  background: rgba(14,19,28,.78);
  backdrop-filter: blur(6px);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:0 18px 60px rgba(0,0,0,.35);
  max-width:calc(100% - 24px);
}
.hudTopLeft{left:6px; top:6px;}
.hudBottomLeft{left:6px; right:auto; bottom:6px; width:max-content; max-width:calc(100% - 24px);}
.extraTurnBanner,
.placementTurnBanner{
  color:#ff2638;
  font-size:17px;
  font-weight:950;
  letter-spacing:.8px;
  line-height:1;
  text-transform:uppercase;
  text-shadow:0 2px 3px rgba(0,0,0,.95), 0 0 12px rgba(255,38,56,.58);
  pointer-events:none;
  white-space:nowrap;
}
.extraTurnBanner{
  display:inline-flex;
  align-items:center;
  gap:7px;
  font-size:19px;
}
.extraTurnIcon{
  display:inline-block;
  font-size:31px;
  font-weight:1000;
  line-height:.7;
}
.hudBar .extraTurnBanner,
.hudBar .placementTurnBanner{
  position:absolute;
  left:14px;
  bottom:calc(100% + 7px);
  z-index:2;
}
.hudBar.turnIndicatorBelow .extraTurnBanner{
  top:calc(100% + 8px);
  bottom:auto;
}
.hudBar .placementTurnBanner{left:14px}
.dragGrip{
  width:22px;
  height:26px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--line);
  border-radius:12px;
  background: rgba(255,255,255,.03);
  color:var(--muted);
  font-family:var(--mono);
  font-size:12px;
  line-height:1;
  cursor:grab;
  user-select:none;
}
.hudBarRow{
  --tool-ui-scale: 1;
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:nowrap;
  white-space:nowrap;
  overflow-x:auto;
  zoom: var(--tool-ui-scale);
  transform-origin: left center;
}
.hudBarScaleHost{display:flex; align-items:center; margin-left:8px; flex:0 0 auto;}
.hudBarScaleHost .toolScaleControl{padding:3px 5px; gap:4px;}
.hudBarScaleHost .tabScaleBtn{width:24px; height:24px; border-radius:8px;}
.hudBarScaleHost .tabScaleLabel{min-width:52px;}
.hudBarRow::-webkit-scrollbar{height:8px}
.hudBarRow::-webkit-scrollbar-thumb{background:rgba(255,255,255,.10); border-radius:999px}
.hudConn{display:flex; align-items:center; gap:8px}
.hudTurnInfo{display:flex; align-items:center; gap:10px; min-width:0; flex:0 1 auto}
.hudTurnInfo .timerInfo{margin-top:0}
.hudBtns{display:flex; align-items:center; gap:8px; flex-wrap:nowrap}
.btnTiny{padding:8px 10px; border-radius:12px; font-size:12px}
.hudDev{display:flex; align-items:center; gap:8px; margin-left:auto}
#devRemaining{font-family:var(--mono); font-size:11px; color:var(--muted); white-space:nowrap}

.hudDevOverlay{
  position:absolute;
  left:6px;
  top:344px;
  bottom:auto;
  z-index:25;
  width:min(480px, 56vw);
  max-height:45vh;
  overflow:auto;
  padding:12px;
  background: rgba(14,19,28,.78);
  backdrop-filter: blur(6px);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:0 18px 60px rgba(0,0,0,.35);
}
.hudDevOverlay h2{margin:0}
body.in-game .hudDevOverlay .actions{display:none;}

.panelScalable{ --tool-ui-scale: 1; }
.panelScaleContent{ zoom: var(--tool-ui-scale); transform-origin: top left; }
.panelScaleHost{ margin-left:auto; display:flex; align-items:center; }
.panelScaleHost .toolScaleControl{ padding:3px 5px; gap:4px; }
.panelScaleHost .tabScaleBtn{ width:24px; height:24px; border-radius:8px; }
.panelScaleHost .tabScaleLabel{ min-width:52px; }

.resourcesHeaderRow, .devHeaderRow{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.resourcesHeaderRow h2, .devHeaderRow h2{ margin:0; }

.devHeaderRight{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:nowrap;
}
.devHeaderRight .btnTiny{ padding:6px 10px; }
.devDeckInline{ margin:0 !important; white-space:nowrap; }

#resourcesCard .panelScaleContent .smallNote{ margin-top:10px; }
#devCard .panelScaleContent .smallNote{ margin-top:8px; }
#devCard .panelScaleContent .devHand{ margin-top:8px; }

.pieceCell{display:flex; align-items:center; justify-content:flex-start; gap:6px; padding:2px 0}
.pieceLeft{display:flex; align-items:center; gap:8px; min-width:0}
.pieceIcon{
  width:22px;
  height:22px;
  border-radius:8px;
  background-repeat:no-repeat;
  background-size:200% 200%;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.35));
}
.pieceVal{font-family:var(--mono); font-size:12px; color:rgba(232,238,246,.96)}

/* The bottom dock is redundant with the HUD bar; keep it hidden in-game. */
body.in-game .hudRollDock{display:none;}

/* Sticky bottom roll dock (shows at start of your turn) */
.rollDock{
  position:sticky;
  bottom:10px;
  z-index:30;
}
.rollDockInner{
  display:flex;
  gap:10px;
  padding:10px;
  border-radius:18px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.28);
  box-shadow:0 18px 60px rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
}

.pill{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.18);
  color:var(--text);
  font-family:var(--mono);
  font-size:11px;
}

/* Development cards */
.devHand{display:flex; flex-direction:column; gap:10px; font-size:13px}
.devRow{display:flex; align-items:center; justify-content:space-between; gap:10px; padding:8px 10px; border:1px solid var(--line); border-radius:14px; background: rgba(0,0,0,.12)}
.devLeft{display:flex; align-items:center; gap:10px; min-width:0}
.devThumb{width:44px; height:58px; border-radius:8px; border:1px solid var(--line); object-fit:cover; background: rgba(255,255,255,.03)}
.devName{font-weight:700; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.devMeta{color:var(--muted); font-size:12px}
.devRight{display:flex; align-items:center; gap:8px}
.tag{display:inline-block; padding:2px 8px; border-radius:999px; border:1px solid var(--line); background: rgba(255,255,255,.02); color:var(--muted); font-family:var(--mono); font-size:11px}

/* Modal */
.modal{position:fixed; inset:0; z-index:1100; display:flex; align-items:center; justify-content:center}
.modal.hidden{display:none}
.modalBackdrop{position:absolute; inset:0; background: rgba(0,0,0,.55)}
.modalBox{position:relative; width:min(659px, calc(100% - 24px)); border:1px solid var(--line); border-radius:18px; background: linear-gradient(180deg, rgba(14,19,28,.98), rgba(10,14,20,.96)); box-shadow:0 18px 60px rgba(0,0,0,.45); padding:14px}
.modalTitle{font-size:16px; font-weight:800; color:var(--text); margin-bottom:10px}
.modalBody{color:var(--text); font-size:13px; line-height:1.4}
.modalActions{display:flex; flex-wrap:wrap; justify-content:flex-end; gap:10px; margin-top:12px}
.modalImg{width:100%; max-height:70vh; object-fit:contain; border-radius:14px; border:1px solid var(--line); background: rgba(255,255,255,.02)}
.choiceRow{display:flex; flex-wrap:wrap; gap:8px; margin-top:10px}
.choiceBtn{border:1px solid var(--line); background: rgba(0,0,0,.18); color:var(--text); border-radius:999px; padding:6px 10px; font-size:12px; cursor:pointer}
.choiceBtn:hover{filter:brightness(1.1)}

/* Click-to-build context menu */
.buildPopup{position:fixed; z-index:60; border:1px solid var(--line); border-radius:16px; background: linear-gradient(180deg, rgba(14,19,28,.98), rgba(10,14,20,.96)); box-shadow:0 18px 60px rgba(0,0,0,.45); padding:10px; min-width:160px}
.buildPopup.hidden{display:none}
.buildPopupTitle{font-size:12px; font-weight:800; color:var(--text); margin-bottom:8px}
.buildPopupBtns{display:flex; flex-wrap:wrap; gap:8px}
.audioSfxPanel{
  position:fixed;
  right:10px;
  top:64px;
  width:min(360px, calc(100vw - 20px));
  max-height:min(70vh, 640px);
  z-index:62;
  border:1px solid var(--line);
  border-radius:16px;
  background: linear-gradient(180deg, rgba(14,19,28,.98), rgba(10,14,20,.96));
  box-shadow:0 18px 60px rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.audioSfxPanel.hidden{display:none !important}
.audioSfxPanelHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:10px 12px;
  border-bottom:1px solid rgba(255,255,255,.05);
  cursor:grab;
  user-select:none;
  touch-action:none;
}
.audioSfxPanelTitle{font-size:13px; font-weight:800; letter-spacing:.3px}
.audioSfxPanelActions{display:flex; align-items:center; gap:6px}
.audioSfxPanelBody{padding:10px 12px; overflow:auto; display:flex; flex-direction:column; gap:10px}
.audioSfxRow{border:1px solid rgba(255,255,255,.05); border-radius:12px; padding:8px 10px; background:rgba(255,255,255,.02)}
.audioSfxRowHead{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:6px}
.audioSfxLabel{font-size:12px; font-weight:700; color:var(--text)}
.audioSfxPct{font-size:11px; color:var(--muted); font-family:var(--mono)}
.audioSfxSlider{width:100%}
.audioSfxPanelFoot{padding:8px 12px 12px; color:var(--muted); font-size:11px; border-top:1px solid rgba(255,255,255,.04)}


.nodeBuildHover{position:fixed; z-index:58; display:flex; align-items:center; gap:8px; pointer-events:none; border:1px solid rgba(255,255,255,.16); background:rgba(8,12,18,.94); color:var(--text); border-radius:999px; padding:6px 10px; box-shadow:0 10px 24px rgba(0,0,0,.35)}
.nodeBuildHover.hidden{display:none !important}
.nodeBuildHoverIcon{width:22px; height:22px; display:grid; place-items:center; border-radius:999px; background:rgba(255,255,255,.08); font-size:14px}
.nodeBuildHoverText{font-size:12px; font-weight:700; letter-spacing:.02em}

.nodeBuildConfirm{position:fixed; z-index:61; display:grid; grid-template-columns:auto 1fr auto auto; align-items:center; gap:8px; border:1px solid rgba(255,255,255,.18); border-radius:14px; background:linear-gradient(180deg, rgba(14,19,28,.98), rgba(10,14,20,.96)); color:var(--text); padding:8px 10px; box-shadow:0 16px 36px rgba(0,0,0,.42)}
.nodeBuildConfirm.hidden{display:none !important}
.nodeBuildConfirmIcon{width:28px; height:28px; display:grid; place-items:center; border-radius:10px; background:rgba(255,255,255,.08); font-size:16px}
.nodeBuildConfirmLabel{font-size:12px; font-weight:800; white-space:nowrap}
.nodeBuildConfirmOk,.nodeBuildConfirmCancel{border:1px solid var(--line); background:rgba(255,255,255,.04); color:var(--text); width:28px; height:28px; border-radius:10px; cursor:pointer; font-weight:900; line-height:1}
.nodeBuildConfirmOk:hover,.nodeBuildConfirmCancel:hover{filter:brightness(1.15)}

/* Trading */
.tradeWrap{display:flex; flex-direction:column; gap:12px}
.tradeBox{border:1px solid var(--line); border-radius:14px; padding:10px; background: rgba(0,0,0,.14)}
.tradeTitle{font-size:12px; font-weight:800; color:var(--text); letter-spacing:.3px; margin-bottom:8px}
.tradeRow{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.tradeGrids{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:8px}
.tradeGrid{border:1px dashed rgba(255,255,255,.12); border-radius:12px; padding:8px; background: rgba(255,255,255,.02)}
.tradeGridInner{display:grid; grid-template-columns:repeat(2, 1fr); gap:8px; margin-top:6px}
.tradeCell{display:flex; align-items:center; justify-content:space-between; gap:8px}
.tradeCellLab{font-size:11px; color:var(--muted); font-family:var(--mono)}
.tradeDetail{margin-top:10px}
/* Global player trade */
.gTradeRows{display:flex; flex-direction:column; gap:10px; margin-top:6px}
.gTradeRow{display:flex; align-items:center; justify-content:space-between; gap:12px}
.gTradeChips{display:flex; gap:10px; flex-wrap:wrap}
.resChipBtn{display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px 12px; background: rgba(0,0,0,.18); border:1px solid rgba(255,255,255,.12); border-radius:14px; min-width:92px; color:var(--text); cursor:pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.04)}
.resChipBtn:hover{border-color: rgba(255,255,255,.22)}
.resChipBtn:disabled{opacity:.38; cursor:not-allowed; border-color:rgba(255,255,255,.07); filter:grayscale(.65)}
.resChipBtn:disabled:hover{border-color:rgba(255,255,255,.07)}
.resChipBtn img{width:32px; height:32px}
.resChipBtn .delta{font-family:var(--mono); font-size:14px; min-width:32px; text-align:right; color:var(--muted)}
.resChipBtn.pos .delta{color: var(--ok)}
.resChipBtn.neg .delta{color: var(--danger)}
.gTradeArrow{font-size:44px; font-weight:900; line-height:1; padding-right:4px; user-select:none}
.gTradeArrow.ok{color: var(--ok)}
.gTradeArrow.bad{color: var(--danger)}

/* Proposed trade */
.ptHead{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px}
.ptProposer{display:flex; align-items:center; gap:10px}
.ptName{font-weight:700}
.ptChips{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}
.resChip{display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 10px; border-radius:12px; background: rgba(0,0,0,.18); border:1px solid rgba(255,255,255,.10); min-width:74px}
.resChip img{width:26px; height:26px}
.resChip .delta{font-family:var(--mono); font-size:13px; min-width:28px; text-align:right; color:var(--muted)}
.resChip.pos .delta{color: var(--ok)}
.resChip.neg .delta{color: var(--danger)}

.ptGrid{display:grid; grid-template-columns: 1fr 110px 110px; gap:8px; align-items:center; margin-top:8px}
.ptGrid.ptStatusGrid{grid-template-columns:minmax(160px,1fr) minmax(110px,180px)}
.ptCell{min-height:44px; display:flex; align-items:center; justify-content:center}
.ptHeader{color:var(--muted); font-size:12px; font-weight:800; letter-spacing:.3px}
.ptNameCell{justify-content:flex-start; gap:10px; padding-left:6px}
.ptRowName{font-weight:650}
.ptResponseStatus{justify-content:flex-start; padding:5px 10px; border:1px solid var(--line); border-radius:999px; min-height:30px; font-family:var(--mono); font-size:11px; font-weight:800}
.ptResponseStatus.accept{color:var(--ok); border-color:rgba(56,210,122,.3); background:rgba(56,210,122,.1)}
.ptResponseStatus.reject{color:var(--danger); border-color:rgba(255,91,91,.3); background:rgba(255,91,91,.08)}
.ptResponseStatus.pending,.ptResponseStatus.offering{color:var(--muted); background:rgba(255,255,255,.03)}

.modalBox:has(.ptStatusGrid){display:flex; flex-direction:column; max-height:calc(100dvh - 24px)}
.modalBox:has(.ptStatusGrid) .modalBody{min-height:0; overflow:auto}
.modalBox:has(.ptStatusGrid) .modalActions{flex-shrink:0}
@media (max-width:600px){
  .ptHead{flex-direction:column; align-items:stretch}
  .ptChips{display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:5px}
  .ptChips .resChip{min-width:0; flex-direction:column; gap:2px; padding:6px 2px}
  .ptChips .resChip .delta{min-width:0; text-align:center}
  .ptGrid.ptStatusGrid{grid-template-columns:minmax(0,1fr) minmax(88px,110px)}
  .ptNameCell{min-width:0}
  .ptRowName{overflow-wrap:anywhere}
  .modalBox:has(.ptStatusGrid) .modalActions:has(> :nth-child(4)){display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px}
  .modalBox:has(.ptStatusGrid) .modalActions:has(> :nth-child(4)) .btn{min-width:0; padding:8px; font-size:12px; white-space:normal}
}

.voteBtn{width:74px; height:44px; border-radius:12px; border:1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.16); color:var(--text); cursor:pointer; font-size:28px; line-height:1; display:flex; align-items:center; justify-content:center}
.voteBtn:hover{border-color: rgba(255,255,255,.22)}
.voteBtn:disabled{opacity:.6; cursor:default}
.voteBtn.on.ok{background: rgba(56,210,122,.12); border-color: rgba(56,210,122,.25); color: var(--ok)}
.voteBtn.on.bad{background: rgba(255,91,91,.10); border-color: rgba(255,91,91,.25); color: var(--danger)}


/* Turn timer */
.timerInfo{
  margin-top:8px;
  font-family:var(--mono);
  font-size:12px;
  color:var(--muted);
  display:flex;
  align-items:center;
  gap:8px;
}

.timerPill{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.18);
  color:var(--text);
}

/* Discard selector */
.discardGrid{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.discardRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:12px;
  background: rgba(0,0,0,.12);
}
.discardLabel{
  font-family:var(--mono);
  font-size:12px;
  color:var(--text);
}
.discardControls{
  display:flex;
  align-items:center;
  gap:8px;
}
.stepBtn{
  width:34px;
  height:30px;
  border-radius:10px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
  color:var(--text);
  font-weight:800;
  cursor:pointer;
}
.stepBtn:disabled{opacity:.45; cursor:not-allowed}
.countPill{
  min-width:56px;
  text-align:center;
  font-family:var(--mono);
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.18);
}

/* Right-side HUD (countdown + pause) */
.rightHud{
  position:absolute;
  top:6px;
  right:6px;
  z-index:12;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:10px;
  pointer-events:auto;
}
.countdownClock{
  --tool-ui-scale: 1;
  min-width:170px;
  text-align:right;
  padding:8px 10px 10px;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.28);
  box-shadow:0 10px 30px rgba(0,0,0,.35);
}
.clockTopRow{display:flex; align-items:center; gap:8px; margin-bottom:4px;}
.clockTopRow .panelScaleHost{margin-left:auto;}
.clockTopRow .toolScaleControl{padding:2px 4px; gap:3px;}
.clockTopRow .tabScaleBtn{width:22px; height:22px; border-radius:7px;}
.clockTopRow .tabScaleLabel{min-width:48px; font-size:11px;}
.countdownClock .panelScaleContent{text-align:right;}
.countdownClock .panelScaleContent .clockTime,
.clockTime{
  font-family:var(--mono);
  font-size:22px;
  font-weight:900;
  color:var(--text);
  letter-spacing:1px;
}
.countdownClock .panelScaleContent .clockMeta,
.clockMeta{
  margin-top:4px;
  font-size:11px;
  color:var(--muted);
  line-height:1.2;
}
.pausedOverlay{
  position:absolute;
  inset:0;
  z-index:11;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.28);
  color: rgba(232,238,246,.92);
  font-size:36px;
  font-weight:900;
  letter-spacing:6px;
  text-shadow:0 18px 60px rgba(0,0,0,.65);
  pointer-events:none;
}


/* --- Setup / Tools --- */
.label{
  display:block;
  margin-top:10px;
  margin-bottom:4px;
  font-size:12px;
  color: var(--muted);
}
select.input{
  background:#0b0c10;
  color: var(--text);
}

/* --- Modal Tools --- */
.toolWrap{ display:flex; flex-direction:column; gap:10px; }
.toolWrapScaled{ --tool-ui-scale: 1; }
.toolScaleRow{ display:flex; justify-content:flex-end; }
.toolScaleControl{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 6px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:12px;
  background: rgba(255,255,255,.03);
  align-self:flex-end;
}
.toolScaleContent{
  zoom: var(--tool-ui-scale);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.logList, .chatList{
  max-height:360px;
  overflow:auto;
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  background:#0b0c10;
}
.logRow{
  font-size:12px;
  padding:6px 4px;
  border-bottom:1px solid rgba(255,255,255,.08);
  color: var(--text);
}
.logRow:last-child{ border-bottom:none; }

.logTs{color:var(--muted); font-family:var(--mono); margin-right:6px;}
.logAutoIcon{display:inline-flex; align-items:center; justify-content:center; font-size:12px; line-height:1; margin-right:6px; opacity:.95;}
.logPlayerSeg{display:inline-flex; align-items:center; gap:6px; margin-left:10px; margin-right:6px; flex-wrap:wrap;}
.logDot{width:10px; height:10px; border-radius:999px; display:inline-block; border:1px solid rgba(0,0,0,.35)}
.logRes{display:inline-flex; align-items:center; gap:4px; margin-left:6px;}
.logResIcon{width:18px; height:18px; display:inline-block; vertical-align:middle;}
.logResNum{font-family:var(--mono); font-size:12px; color:#bfe2ff;}

.diceTable{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
}
.diceTable th, .diceTable td{
  padding:6px 8px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.diceTable th{
  color: var(--muted);
  font-weight:600;
}
.diceStatsControls{display:flex; gap:10px; align-items:end; flex-wrap:wrap; margin-bottom:10px;}
.diceStatsControl{display:flex; flex-direction:column; gap:4px; min-width:170px; flex:1 1 190px;}
.diceStatsControl .labelTiny{color:var(--muted); font-size:11px;}
.diceStatsDelta.positive{color:#6ee7a1; font-weight:800;}
.diceStatsDelta.negative{color:#ff8792; font-weight:800;}
.diceStatsDelta.neutral{color:var(--muted);}
.diceProbabilityNote{margin:8px 0 10px; line-height:1.4;}
.diceStatsTableWrap{width:100%; overflow-x:auto;}
.diceStatsTableWrap .diceTable{min-width:520px;}
.chatRow{ padding:6px 4px; border-bottom:1px solid rgba(255,255,255,.08); }
.chatRow:last-child{ border-bottom:none; }
.chatMeta{ font-size:11px; color: var(--muted); margin-bottom:2px; }
.chatBody{ font-size:13px; color: var(--text); }
.chatInputRow{ display:flex; gap:8px; align-items:center; }
.chatInputRow .input{ flex:1; }



/* Post-game overlay (victory splash + stats) */
.postgameOverlay{
  position:fixed;
  inset:0;
  z-index: 5000;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.postgameSplash{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  text-align:center;
  padding:24px 26px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background: radial-gradient(1200px 900px at 20% 10%, rgba(74,163,255,.16), transparent 60%),
              radial-gradient(900px 700px at 90% 40%, rgba(56,210,122,.12), transparent 60%),
              rgba(10,12,15,.78);
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
  min-width: min(680px, calc(100vw - 36px));
  max-width: min(920px, calc(100vw - 36px));
}
.postgameSplashTitle{
  font-size: 44px;
  font-weight: 900;
  letter-spacing: .5px;
  text-shadow: 0 10px 24px rgba(0,0,0,.55);
}
.postgameSplashSub{
  font-size: 14px;
  color: var(--muted);
  font-family: var(--mono);
}

.postgamePanel{
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border:0;
  background: rgba(10,12,15,.92);
  box-shadow: none;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.postgameTop{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  gap:12px;
  padding:14px 14px 10px 14px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.postgameTopLeft{display:flex; gap:10px; justify-content:flex-start}
.postgameTopCenter{display:flex; flex-direction:column; align-items:center; gap:2px; min-width:0}
.postgameTopRight{display:flex; gap:10px; justify-content:flex-end}
.postgameWinnerLine{
  font-size: 34px;
  font-weight: 900;
  text-shadow: 0 10px 24px rgba(0,0,0,.55);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 520px;
}
.postgameMetaLine{
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}
.postgameTabs{
  display:grid;
  grid-template-columns:repeat(5, minmax(108px, 1fr));
  gap:8px;
  padding:10px 14px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  overflow-x:auto;
}
.pgTab{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding:9px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .2px;
  min-height:42px;
}
.pgTab.active{
  border-color: rgba(74,163,255,.55);
  background: linear-gradient(180deg, rgba(74,163,255,.20), rgba(74,163,255,.09));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.08), 0 7px 18px rgba(0,0,0,.18);
}
.postgameBody{
  flex:1;
  overflow:auto;
  padding:14px;
}

.pgTable{
  width:100%;
  border-collapse:collapse;
  font-size: 13px;
}
.pgTable th, .pgTable td{
  padding:10px 10px;
  border-bottom:1px solid rgba(255,255,255,.08);
  text-align:left;
  vertical-align:middle;
}
.pgTable th{
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .3px;
  font-family: var(--mono);
  font-weight: 700;
}
.pgName{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.pgBadge{
  width:12px;
  height:12px;
  border-radius:999px;
  box-shadow: 0 0 0 3px rgba(255,255,255,.06) inset;
  flex:0 0 auto;
}
.pgMono{font-family: var(--mono)}
.pgNote{
  margin-top:10px;
  font-size: 12px;
  color: var(--muted);
}

.endVoteCountdown{
  margin:12px 0;
  padding:12px 18px;
  border:1px solid rgba(255,198,60,.65);
  border-radius:12px;
  background:rgba(255,183,25,.09);
  color:#ffd56d;
  font-size:32px;
  font-weight:900;
  font-family:var(--mono);
  text-align:center;
}

/* keep the Show Stats button accessible over the board */
.rightHud #pgShowBtn{
  padding:8px 10px;
  font-size: 12px;
  border-radius: 12px;
  align-self:flex-end;
}

/* Postgame stats helpers */
.pgSection{
  margin-bottom: 16px;
}
.pgSectionHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.pgSectionTitle{
  font-weight: 900;
  font-size: 14px;
  letter-spacing: .2px;
}
.pgControls{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.pgControl{
  display:flex;
  gap:8px;
  align-items:center;
}
.pgControlLabel{
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 700;
}
.pgSelect{
  background: rgba(0,0,0,.25);
  border:1px solid rgba(255,255,255,.14);
  color: var(--text);
  padding:8px 10px;
  border-radius: 12px;
  font-weight: 900;
  font-size: 12px;
  cursor:pointer;
}
.pgSelect:focus{
  outline: none;
  border-color: rgba(74,163,255,.55);
}
.pgSubTabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
}
.pgSubTab{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding:8px 10px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: .2px;
}
.pgSubTab.active{
  border-color: rgba(74,163,255,.55);
  background: rgba(74,163,255,.14);
}

/* Table bar-cells */
.pgBarCell{
  position:relative;
  height:22px;
  min-width: 84px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  overflow:hidden;
  border:1px solid rgba(255,255,255,.06);
}
.pgBarFill{
  position:absolute;
  inset:0;
  width:0;
  border-radius: 10px;
}
.pgBarLabel{
  position:relative;
  z-index:1;
  display:flex;
  align-items:center;
  height:100%;
  padding:0 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(255,255,255,.92);
  text-shadow: 0 2px 10px rgba(0,0,0,.55);
}
.pgBarCell.right .pgBarLabel{
  justify-content:flex-end;
}
.pgBarStack{
  position:absolute;
  inset:0;
  display:flex;
}
.pgBarStackSeg{
  height:100%;
}
.pgBarCell.pgStack .pgBarFill{ display:none; }

/* Legend */
.pgLegend{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin-bottom: 10px;
}
.pgLegendItem{
  display:flex;
  gap:6px;
  align-items:center;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 700;
}
.pgLegendDot{
  width:10px;
  height:10px;
  border-radius:999px;
  box-shadow: 0 0 0 3px rgba(255,255,255,.06) inset;
}

/* Postgame: shared overview-card visual system */
.pgStyledSection > .pgSectionHead{
  min-height:38px;
  padding:0 2px;
}
.pgOverviewPlayerGrid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(210px, 1fr));
  gap:12px;
  align-items:stretch;
}
.pgOverviewPlayerCard{
  position:relative;
  min-width:0;
  display:flex;
  flex-direction:column;
  padding:12px 10px 10px;
  border:1px solid color-mix(in srgb, var(--pg-player-color) 58%, rgba(255,255,255,.08));
  border-radius:18px;
  background:
    radial-gradient(260px 190px at 50% 105%, color-mix(in srgb, var(--pg-player-color) 14%, transparent), transparent 72%),
    rgba(0,0,0,.18);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.025);
  overflow:hidden;
}
.pgOverviewPlayerCard.winner{
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.07),
    0 0 28px color-mix(in srgb, var(--pg-player-color) 13%, transparent);
}
.pgOverviewCardHead{
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  min-height:46px;
  padding:0 48px 9px;
  text-align:center;
}
.pgOverviewHeadline{
  color:color-mix(in srgb, var(--pg-player-color) 68%, #fff);
  font-family:var(--mono);
  font-size:18px;
  font-weight:1000;
  line-height:1.1;
  text-shadow:0 4px 12px rgba(0,0,0,.48);
}
.pgOverviewHeadlineLabel{
  margin-top:3px;
  color:var(--muted);
  font-family:var(--mono);
  font-size:8px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.pgOverviewRibbon{
  position:absolute;
  top:1px;
  right:0;
  padding:4px 6px;
  border:1px solid color-mix(in srgb, var(--pg-player-color) 48%, rgba(255,255,255,.08));
  border-radius:999px;
  background:color-mix(in srgb, var(--pg-player-color) 12%, rgba(0,0,0,.34));
  color:color-mix(in srgb, var(--pg-player-color) 72%, #fff);
  font-family:var(--mono);
  font-size:7px;
  font-weight:900;
  white-space:nowrap;
}
.pgOverviewMetricGrid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:5px;
  align-content:start;
  flex:1;
}
.pgOverviewMetric{
  min-width:0;
  min-height:46px;
  display:flex;
  align-items:center;
  gap:7px;
  padding:6px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:9px;
  background:rgba(255,255,255,.025);
}
.pgOverviewMetric.positive{border-color:rgba(87,221,107,.20); background:rgba(55,155,73,.055);}
.pgOverviewMetric.negative{border-color:rgba(235,92,92,.22); background:rgba(172,48,48,.065);}
.pgOverviewMetric.warning{border-color:rgba(245,190,61,.22); background:rgba(170,119,30,.06);}
.pgOverviewMetricIcon{
  width:30px;
  height:30px;
  flex:0 0 30px;
  display:grid;
  place-items:center;
  border-radius:8px;
  background:color-mix(in srgb, var(--pg-player-color) 11%, rgba(0,0,0,.22));
  color:color-mix(in srgb, var(--pg-player-color) 58%, #fff);
  font-family:var(--mono);
  font-size:14px;
  font-weight:1000;
}
.pgOverviewMetricIcon img{
  width:29px;
  height:29px;
  object-fit:contain;
  filter:drop-shadow(0 2px 4px rgba(0,0,0,.55));
}
.pgOverviewMetricIcon.pieceArt{
  background:transparent;
  overflow:hidden;
}
.pgOverviewPieceArt{
  display:block;
  width:100%;
  height:100%;
  border-radius:inherit;
  background-repeat:no-repeat;
  background-size:200% 200%;
  filter:drop-shadow(0 2px 4px rgba(0,0,0,.55));
}
.pgOverviewMetricCopy{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.pgOverviewMetricLabel{
  overflow:hidden;
  color:var(--muted);
  font-family:var(--mono);
  font-size:7px;
  font-weight:800;
  line-height:1.15;
  text-transform:uppercase;
  text-overflow:ellipsis;
}
.pgOverviewMetricValue{
  overflow:hidden;
  color:rgba(255,255,255,.96);
  font-family:var(--mono);
  font-size:11px;
  font-weight:1000;
  line-height:1.1;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.pgOverviewRatingChange{
  margin-top:10px;
  text-align:center;
  font-size:12px;
  font-weight:850;
  color:var(--muted);
  letter-spacing:.02em;
}
.pgOverviewRatingChange.positive{color:#56d6a4;}
.pgOverviewRatingChange.negative{color:#ff8d82;}
.pgOverviewPlayerFooter{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  min-width:0;
  margin-top:9px;
  padding-top:9px;
  border-top:1px solid rgba(255,255,255,.08);
  color:var(--text);
  font-size:11px;
  font-weight:950;
}
.pgOverviewPlayerFooter span:last-child{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.pgOverviewPlayerSwatch{
  width:11px;
  height:11px;
  flex:0 0 11px;
  border-radius:3px;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.42);
}
.pgMatchHighlights{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px;
  margin:14px 0 4px;
}
.pgMatchHighlight{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height:58px;
  padding:9px 12px;
  border:1px solid rgba(255,255,255,.09);
  border-radius:14px;
  background:rgba(0,0,0,.17);
}
.pgMatchHighlight > span{
  display:grid;
  place-items:center;
  width:34px;
  height:34px;
  flex:0 0 34px;
  border-radius:10px;
  background:rgba(74,163,255,.11);
  color:#87bdff;
  font-size:17px;
}
.pgMatchHighlight div{min-width:0; display:flex; flex-direction:column; gap:2px;}
.pgMatchHighlight small{color:var(--muted); font-family:var(--mono); font-size:10px; text-transform:uppercase;}
.pgMatchHighlight strong{overflow:hidden; font-size:14px; text-overflow:ellipsis; white-space:nowrap;}

/* Summary tab: intentionally larger than the denser Activity and Dev Card views. */
.pgGameOverviewSection .pgSectionTitle{font-size:18px;}
.pgGameOverviewSection .pgOverviewPlayerGrid{
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:16px;
}
.pgGameOverviewSection .pgOverviewPlayerCard{
  padding:16px 14px 14px;
  border-radius:20px;
}
.pgGameOverviewSection .pgOverviewCardHead{
  min-height:62px;
  padding:0 62px 12px;
}
.pgGameOverviewSection .pgOverviewHeadline{font-size:23px;}
.pgGameOverviewSection .pgOverviewHeadlineLabel{font-size:10px; margin-top:5px;}
.pgGameOverviewSection .pgOverviewRibbon{padding:5px 8px; font-size:9px;}
.pgGameOverviewSection .pgOverviewMetricGrid{gap:8px;}
.pgGameOverviewSection .pgOverviewMetric{
  min-height:64px;
  gap:10px;
  padding:9px;
  border-radius:12px;
}
.pgGameOverviewSection .pgOverviewMetricIcon{
  width:40px;
  height:40px;
  flex-basis:40px;
  border-radius:10px;
  font-size:18px;
}
.pgGameOverviewSection .pgOverviewMetricIcon img{width:39px; height:39px;}
.pgGameOverviewSection .pgOverviewMetricCopy{gap:4px;}
.pgGameOverviewSection .pgOverviewMetricLabel{font-size:9px; line-height:1.2;}
.pgGameOverviewSection .pgOverviewMetricValue{font-size:14px;}
.pgGameOverviewSection .pgOverviewPlayerFooter{
  gap:9px;
  margin-top:13px;
  padding-top:12px;
  font-size:14px;
}
.pgGameOverviewSection .pgOverviewPlayerSwatch{
  width:14px;
  height:14px;
  flex-basis:14px;
}
.pgMatchHighlights{gap:14px; margin-top:18px;}
.pgMatchHighlight{gap:13px; min-height:74px; padding:12px 16px; border-radius:17px;}
.pgMatchHighlight > span{
  width:44px;
  height:44px;
  flex-basis:44px;
  border-radius:12px;
  font-size:21px;
}
.pgMatchHighlight div{gap:4px;}

/* Dice overview */
.pgDiceSection > .pgSectionHead{
  flex-direction:column;
  justify-content:center;
  gap:5px;
  margin-bottom:0;
  text-align:center;
}
.pgDiceSection .pgSectionTitle{font-size:13px; color:rgba(255,255,255,.72);}
.pgDiceSection .pgSubTabs{gap:3px;}
.pgDiceSection .pgSubTab{
  padding:7px 8px;
  border-color:transparent;
  border-radius:4px;
  background:transparent;
  color:#b9cad4;
  font-size:12px;
  font-weight:1000;
  text-transform:uppercase;
}
.pgDiceSection .pgSubTab:hover{color:#fff; background:rgba(255,255,255,.035);}
.pgDiceSection .pgSubTab.active{
  border-color:#fff;
  background:rgba(255,255,255,.045);
  color:#fff;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.22);
}
.pgDiceChart{
  width:100%;
  overflow-x:auto;
  padding:8px 0 2px;
}
.pgDiceChartArea{
  position:relative;
  height:clamp(320px, 48vh, 470px);
  min-width:660px;
  margin:16px 8px 30px 36px;
}
.pgDiceChartArea::after{
  content:'';
  position:absolute;
  inset:auto 0 0;
  z-index:1;
  border-top:1px solid rgba(255,255,255,.10);
}
.pgDiceGridline{
  position:absolute;
  left:0;
  right:0;
  z-index:0;
  border-top:1px dashed rgba(255,255,255,.13);
}
.pgDiceGridline span{
  position:absolute;
  right:calc(100% + 8px);
  top:-7px;
  color:rgba(255,255,255,.50);
  font-family:var(--mono);
  font-size:9px;
  font-weight:900;
}
.pgDiceBars{
  position:absolute;
  inset:0;
  z-index:2;
  display:grid;
  grid-template-columns:repeat(11, minmax(38px, 1fr));
  align-items:stretch;
}
.pgDiceBarColumn{
  position:relative;
  min-width:0;
  height:100%;
}
.pgDiceChartBar{
  position:absolute;
  left:1px;
  right:1px;
  bottom:0;
  min-height:0;
  display:flex;
  flex-direction:column-reverse;
  align-items:stretch;
  border:1px solid rgba(255,255,255,.26);
  border-bottom:0;
  overflow:hidden;
}
.pgDiceChartBar.totals{
  background:linear-gradient(180deg, #aaa, #747474);
}
.pgDiceChartBar.totals.seven{background:linear-gradient(180deg, #8e8e8e, #5f5f5f);}
.pgDiceChartBar.players{background:rgba(255,255,255,.025);}
.pgDicePlayerSegment{
  display:block;
  width:100%;
  flex:0 0 auto;
  border-top:1px solid rgba(255,255,255,.44);
  box-shadow:inset 0 1px 0 rgba(0,0,0,.14);
}
.pgDicePlayerSegment.unattributed{background:linear-gradient(180deg, #aaa, #7d7d7d);}
.pgDiceChartBar.prob{
  border-color:rgba(255,255,255,.16);
  background:transparent;
}
.pgDiceProbabilityBase{
  display:block;
  width:100%;
  flex:0 0 auto;
  background:linear-gradient(180deg, #aaa, #747474);
}
.pgDiceChartBar.prob.seven .pgDiceProbabilityBase{background:linear-gradient(180deg, #8e8e8e, #5f5f5f);}
.pgDiceProbabilityDelta{
  display:block;
  width:100%;
  flex:0 0 auto;
  border-top:1px solid #ff7777;
  border-bottom:1px solid rgba(255,105,105,.72);
}
.pgDiceProbabilityDelta.positive{
  background:linear-gradient(180deg, rgba(255,116,116,.96), rgba(220,92,92,.42));
}
.pgDiceProbabilityDelta.negative{
  background:repeating-linear-gradient(135deg, rgba(105,27,27,.12) 0 6px, rgba(238,76,76,.20) 6px 8px);
  border-left:1px dashed rgba(255,101,101,.84);
  border-right:1px dashed rgba(255,101,101,.84);
}
.pgDiceBarValue{
  position:absolute;
  left:50%;
  z-index:4;
  transform:translateX(-50%);
  color:#fff;
  font-family:var(--mono);
  font-size:12px;
  font-weight:1000;
  line-height:1;
  text-shadow:0 2px 5px rgba(0,0,0,.85);
  white-space:nowrap;
}
.pgDiceBarValue.positive{color:#fff;}
.pgDiceBarValue.negative{color:#fff;}
.pgDiceBarValue.hiddenValue{visibility:hidden;}
.pgDiceBarRoll{
  position:absolute;
  top:calc(100% + 8px);
  left:50%;
  transform:translateX(-50%);
  color:rgba(255,255,255,.76);
  font-family:var(--mono);
  font-size:11px;
  font-weight:1000;
}
.pgDiceLegend{justify-content:center; margin:0 0 4px;}

/* Dev-card focus */
.pgDevFocusSection{
  margin-top:20px;
  padding:14px;
  border:1px solid color-mix(in srgb, var(--pg-player-color) 30%, rgba(255,255,255,.08));
  border-radius:18px;
  background:rgba(0,0,0,.16);
}
.pgDevTypeGrid{
  display:grid;
  grid-template-columns:repeat(5, minmax(140px, 1fr));
  gap:9px;
}
.pgDevTypeCard{
  min-width:0;
  display:grid;
  grid-template-columns:52px 1fr;
  grid-template-rows:auto auto;
  align-items:center;
  gap:5px 8px;
  padding:9px;
  border:1px solid rgba(255,255,255,.09);
  border-radius:13px;
  background:rgba(255,255,255,.025);
}
.pgDevTypeCard > img{
  grid-row:1 / 3;
  width:52px;
  height:66px;
  object-fit:contain;
  filter:drop-shadow(0 5px 7px rgba(0,0,0,.48));
}
.pgDevTypeCard > strong{overflow:hidden; font-size:10px; text-overflow:ellipsis; white-space:nowrap;}
.pgDevTypeValues{display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:4px;}
.pgDevTypeValues span{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:4px;
  border-radius:6px;
  background:rgba(0,0,0,.18);
}
.pgDevTypeValues small{color:var(--muted); font-family:var(--mono); font-size:6px; text-transform:uppercase;}
.pgDevTypeValues b{font-family:var(--mono); font-size:11px;}

/* Postgame: Resources per-turn layout */
.pgResCategoryPanel{
  margin-bottom:18px;
  padding:14px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:18px;
  background:rgba(0,0,0,.20);
}
.pgResCategoryHeading{
  display:flex;
  align-items:baseline;
  justify-content:center;
  gap:10px;
  margin-bottom:12px;
  text-align:center;
}
.pgResCategoryTitle{font-weight:900; font-size:14px;}
.pgResCategoryMeta{font-family:var(--mono); color:var(--muted); font-size:10px;}
.pgResCategoryGrid{
  display:grid;
  grid-template-columns:repeat(10, minmax(80px, 1fr));
  gap:8px;
  min-width:840px;
}
.pgResCategoryPanel{overflow-x:auto;}
.pgResCategoryToggle{
  appearance:none;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:7px;
  min-height:112px;
  padding:10px 6px 8px;
  border:1px solid rgba(255,255,255,.11);
  border-radius:15px;
  background:rgba(255,255,255,.035);
  color:rgba(255,255,255,.52);
  cursor:pointer;
  transition:transform .12s ease, border-color .12s ease, background .12s ease, opacity .12s ease;
}
.pgResCategoryToggle:hover{transform:translateY(-2px); border-color:rgba(255,255,255,.28);}
.pgResCategoryToggle:focus-visible{outline:2px solid rgba(74,163,255,.75); outline-offset:2px;}
.pgResCategoryToggle.active.gain{
  color:#8dff9b;
  border-color:rgba(98,218,112,.52);
  background:linear-gradient(180deg, rgba(72,166,80,.23), rgba(72,166,80,.06));
}
.pgResCategoryToggle.active.loss{
  color:#ff9292;
  border-color:rgba(226,91,91,.52);
  background:linear-gradient(180deg, rgba(181,68,68,.23), rgba(181,68,68,.06));
}
.pgResCategoryIcon{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  flex:0 0 38px;
  border-radius:999px;
  border:2px solid currentColor;
  background:rgba(0,0,0,.24);
  color:inherit;
  font-family:var(--mono);
  font-size:19px;
  font-weight:1000;
  line-height:1;
  filter:grayscale(1);
}
.pgResCategoryToggle.active .pgResCategoryIcon{filter:none; box-shadow:0 7px 18px rgba(0,0,0,.30);}
.pgResCategoryLabel{
  font-size:9px;
  line-height:1.22;
  font-weight:850;
  color:rgba(255,255,255,.68);
  text-align:center;
}
.pgResCategoryToggle.active .pgResCategoryLabel{color:rgba(255,255,255,.94);}
.pgResCategoryActions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  min-width:840px;
  padding-top:10px;
}
.pgResCategoryAction{
  appearance:none;
  border:1px solid rgba(255,255,255,.14);
  border-radius:999px;
  background:rgba(255,255,255,.04);
  color:var(--text);
  padding:6px 10px;
  font-family:var(--mono);
  font-size:10px;
  font-weight:800;
  cursor:pointer;
}
.pgResCategoryAction:disabled{opacity:.38; cursor:not-allowed;}
.pgResGoldMode{
  width:fit-content;
  max-width:100%;
  display:grid;
  grid-template-columns:auto 30px minmax(0, auto);
  align-items:center;
  gap:8px;
  margin:10px 0 0;
  padding:6px 9px;
  border:1px solid rgba(255,196,43,.24);
  border-radius:10px;
  background:rgba(255,190,22,.055);
  color:rgba(255,255,255,.88);
  cursor:pointer;
}
.pgResGoldMode input{width:15px; height:15px; margin:0; accent-color:#f4ba18; cursor:pointer;}
.pgResGoldMode img{
  width:30px;
  height:30px;
  object-fit:cover;
  border-radius:6px;
  box-shadow:0 3px 9px rgba(0,0,0,.34);
}
.pgResGoldMode span{display:flex; flex-direction:column; gap:2px; min-width:0; font-size:10px; line-height:1.2;}
.pgResGoldMode strong{color:#ffd65c; font-size:10px;}
.pgResGoldMode small{color:var(--muted); font-family:var(--mono); font-size:8px;}

.pgResOverviewGrid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));
  gap:12px;
  align-items:stretch;
  padding:8px 0 4px;
}
.pgResPlayerColumn{
  min-height:calc(var(--pg-res-stack-ceiling, 520px) + 128px);
  display:grid;
  grid-template-rows:auto minmax(calc(var(--pg-res-stack-ceiling, 520px) + 38px), 1fr) auto;
  align-items:end;
  padding:13px 9px 11px;
  border:1px solid color-mix(in srgb, var(--pg-player-color) 42%, rgba(255,255,255,.10));
  border-radius:18px;
  background:
    radial-gradient(260px 180px at 50% 100%, color-mix(in srgb, var(--pg-player-color) 13%, transparent), transparent 70%),
    rgba(0,0,0,.17);
  overflow:hidden;
}
.pgResPlayerNet{
  align-self:start;
  text-align:center;
  font-family:var(--mono);
  font-size:14px;
  line-height:1;
  font-weight:1000;
  text-shadow:0 4px 12px rgba(0,0,0,.45);
}
.pgResPlayerNet.positive{color:#72ff86;}
.pgResPlayerNet.negative{color:#ff6e6e;}
.pgResPlayerNet.zero{color:rgba(255,255,255,.55);}
.pgResPlayerLanes{
  min-height:calc(var(--pg-res-stack-ceiling, 520px) + 38px);
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:8px;
  align-self:stretch;
  padding-top:10px;
}
.pgResPlayerLane{
  min-width:0;
  display:grid;
  grid-template-rows:auto minmax(var(--pg-res-stack-ceiling, 520px), 1fr);
  border:1px solid rgba(255,255,255,.08);
  border-radius:11px;
  background:rgba(0,0,0,.13);
  overflow:hidden;
}
.pgResPlayerLane.gain{border-color:rgba(98,218,112,.22);}
.pgResPlayerLane.loss{border-color:rgba(226,91,91,.24);}
.pgResPlayerLaneHeading{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:4px;
  padding:7px 7px 5px;
  border-bottom:1px solid rgba(255,255,255,.07);
  font-family:var(--mono);
  font-size:8px;
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.pgResPlayerLaneHeading strong{font-size:11px; letter-spacing:0;}
.pgResPlayerLane.gain .pgResPlayerLaneHeading{color:#72ff86;}
.pgResPlayerLane.loss .pgResPlayerLaneHeading{color:#ff7979;}
.pgResPlayerLane.gain .pgResPlayerLaneHeading{background:rgba(72,166,80,.08);}
.pgResPlayerLane.loss .pgResPlayerLaneHeading{background:rgba(181,68,68,.08);}
.pgResPlayerLane .pgResPlayerStack{
  min-height:0;
}
.pgResPlayerStack{
  display:flex;
  flex-direction:column-reverse;
  justify-content:flex-start;
  align-items:center;
  align-self:end;
  width:100%;
  max-height:var(--pg-res-stack-ceiling, 520px);
  gap:3px;
}
.pgResPlayerStack.empty{
  height:100%;
  max-height:none;
}
.pgResStackBlock{
  position:relative;
  isolation:isolate;
  width:calc(100% - 8px);
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:1px solid rgba(255,255,255,.52);
  border-radius:7px;
  color:#fff;
  font-family:var(--mono);
  font-size:12px;
  font-weight:1000;
  text-shadow:0 2px 4px rgba(0,0,0,.72);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.16), 0 4px 10px rgba(0,0,0,.20);
  overflow:hidden;
}
.pgResStackBlock.lumber{background:#466d26;}
.pgResStackBlock.brick{background:#c8582c;}
.pgResStackBlock.wool{background:#6f9f00;}
.pgResStackBlock.grain{background:#c9ad00;}
.pgResStackBlock.ore{background:#747566;}
.pgResStackBlock.gold{background:linear-gradient(155deg, #6f4300, #d68d00 48%, #704000);}
.pgResStackBlock.loss{border-color:rgba(255,119,119,.95);}
.pgResStackBlock.loss::after{
  content:'';
  position:absolute;
  inset:0;
  z-index:-1;
  background:repeating-linear-gradient(135deg, rgba(102,0,0,.24) 0 7px, rgba(0,0,0,.08) 7px 14px);
}
.pgResStackBlock img{
  width:26px;
  height:26px;
  object-fit:contain;
  filter:drop-shadow(0 2px 3px rgba(0,0,0,.55));
}
.pgResStackBlock.compact{
  gap:4px;
  font-size:10px;
}
.pgResStackBlock.compact img{
  width:18px;
  height:18px;
}
.pgResStackBlock.micro img,
.pgResStackBlock.micro span{
  display:none;
}
.pgResStackEmpty{
  margin:auto 0;
  max-width:110px;
  color:rgba(255,255,255,.38);
  font-family:var(--mono);
  font-size:10px;
  line-height:1.35;
  text-align:center;
}
.pgResPlayerFooter{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  min-width:0;
  padding-top:10px;
  border-top:1px solid rgba(255,255,255,.09);
  color:var(--text);
  font-size:12px;
  font-weight:950;
}
.pgResPlayerFooter span:last-child{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.pgResPlayerSwatch{
  width:12px;
  height:12px;
  flex:0 0 12px;
  border-radius:3px;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.45);
}

.pgThPlayer{
  display:flex;
  align-items:center;
  gap:8px;
  min-width: 0;
}

.pgResTurnTable{
  border-collapse: separate;
  border-spacing: 0 10px;
}
.pgResTurnTable th, .pgResTurnTable td{
  border-bottom: none;
  vertical-align: top;
  padding: 8px 10px;
}

.pgTurnCell, .pgRollCell{
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(255,255,255,.92);
  white-space: nowrap;
}
.pgRollCell{ color: rgba(255,255,255,.82); }

.pgResTurnCard{
  display:flex;
  gap:14px;
  align-items:flex-end;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow:
    0 12px 30px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.06);
  min-width: 280px;
}

.pgResSlot{
  display:flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 46px;
}

.pgResIcon{
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.45));
}

.pgResNums{
  margin-top: 6px;
  display:flex;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
}

.pgResTotal{ color: rgba(255,255,255,.92); }
.pgResDelta{ font-weight: 800; }
.pgResDelta.pos{ color: #57ff9a; }
.pgResDelta.neg{ color: #ff6a6a; }
.pgResDelta.zero{ color: rgba(255,255,255,.58); }




.pgReplayControls{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-bottom:12px;
}
.pgReplayNav{display:flex; gap:8px; align-items:center; flex-wrap:wrap;}
.pgReplayMeta{font-family:var(--mono); color:var(--muted); font-size:11px; font-weight:700;}
.pgReplayText{font-size:12px; color:rgba(255,255,255,.9);}
.pgReplayPlayers{display:flex; gap:8px; flex-wrap:wrap;}
.pgReplayPlayerChip{
  border:1px solid rgba(255,255,255,.2);
  background:rgba(0,0,0,.18);
  color:var(--text);
  border-radius:999px;
  padding:6px 10px;
  font-size:11px;
  font-weight:800;
  cursor:pointer;
}
.pgReplayPlayerChip.active{background:rgba(74,163,255,.2);}
.pgCurrentPlayerBadge{
  margin:8px 0 0 auto;
  width:fit-content;
  border:1px solid rgba(255,255,255,.25);
  border-radius:999px;
  padding:6px 10px;
  font-size:11px;
  font-family:var(--mono);
  font-weight:800;
}

@media (max-width: 760px){
  .pgResCategoryHeading{align-items:center; flex-direction:column; gap:3px;}
  .pgResOverviewGrid{grid-template-columns:1fr;}
  .pgResPlayerColumn{min-height:calc(var(--pg-res-stack-ceiling, 520px) + 128px);}
  .pgOverviewPlayerGrid{grid-template-columns:1fr;}
  .pgGameOverviewSection .pgOverviewPlayerGrid{grid-template-columns:1fr;}
  .pgMatchHighlights{grid-template-columns:1fr;}
  .pgDiceChartArea{height:330px; min-width:620px;}
  .pgDevTypeGrid{grid-template-columns:repeat(2, minmax(0, 1fr));}
  .pgDevTypeCard{grid-template-columns:44px 1fr;}
  .pgDevTypeCard > img{width:44px; height:58px;}
}

/* User-adjustable scaling for tabbed overlays (Postgame + History) */
.postgameTabs,
.postgameBody,
.historyTabs,
.historyBody{
  zoom: var(--tab-ui-scale);
}

.tabScaleControl{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 6px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:12px;
  background: rgba(255,255,255,.03);
}
.tabScaleBtn{
  appearance:none;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  color: var(--text);
  width:26px;
  height:26px;
  border-radius:10px;
  cursor:pointer;
  font-weight:900;
  line-height:1;
  padding:0;
}
.tabScaleBtn:hover{ filter:brightness(1.12); }
.tabScaleBtn:disabled{ opacity:.5; cursor:not-allowed; }
.tabScaleLabel{
  min-width:58px;
  text-align:center;
  font-family: var(--mono);
  font-size:11px;
  color: var(--muted);
  user-select:none;
}

/* History + Player Stats overlay */
.historyOverlay{
  position:fixed;
  inset:0;
  z-index: 4800;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.historyOverlay.hidden{ display:none; }

.historyPanel{
  width: min(1100px, calc(100vw - 24px));
  height: min(760px, calc(100vh - 24px));
  border:1px solid rgba(255,255,255,.10);
  border-radius:18px;
  background: rgba(10,12,15,.92);
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.historyTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border-bottom:1px solid rgba(255,255,255,.08);
}

.historyTopCenter{ display:flex; flex-direction:column; align-items:center; gap:2px; min-width:0; flex:1; }
.historyTitle{ font-size:16px; font-weight:900; letter-spacing:.2px; }
.historySub{ font-size:12px; color: var(--muted); font-family: var(--mono); }

.historyTabs{
  display:flex;
  gap:8px;
  padding:10px 12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.12);
}
.leaderboardSubTabs{display:flex;justify-content:center;gap:8px;margin:0 0 14px;flex-wrap:wrap}

.hTab{
  padding:8px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor:pointer;
  font-weight:800;
  font-size:12px;
}
.hTab.active{
  background: rgba(74,163,255,.18);
  border-color: rgba(74,163,255,.32);
}

.historyBody{
  flex:1;
  overflow:auto;
  padding:12px;
}

.historyList{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.historyCard{
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(0,0,0,.18);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.historyMeta{ display:flex; flex-direction:column; gap:4px; min-width:0; }
.historyLine1{ font-weight:900; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.historyLine2{ font-family: var(--mono); font-size:11px; color: var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.historyActions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }

.standingsTable{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}
.standingsTable th, .standingsTable td{
  padding:8px 10px;
  border-bottom:1px solid rgba(255,255,255,.08);
  font-size:12px;
  white-space:nowrap;
}
.standingsTable th{
  position:sticky;
  top:0;
  background: rgba(10,12,15,.96);
  z-index:2;
  text-align:left;
  cursor:pointer;
  user-select:none;
}
.standingsTable th.sortAsc::after{ content:" ▲"; font-size:10px; color: var(--muted); }
.standingsTable th.sortDesc::after{ content:" ▼"; font-size:10px; color: var(--muted); }

.standName{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}
.standDot{
  width:10px; height:10px; border-radius:50%;
  flex:0 0 auto;
  background: #777;
  box-shadow:0 0 0 2px rgba(255,255,255,.10);
}
.standNameText{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.resourcesOverlay .panelScaleContent{ display:flex; flex-direction:column; gap:8px; }
.hudDevOverlay .panelScaleContent{ display:flex; flex-direction:column; gap:8px; }

/* Lobby rules handbook */
.lobbyPrimaryActions .btn{flex:1;}
body.rules-page-open{overflow:hidden;}
.rulesPage{
  position:fixed;
  inset:0;
  z-index:6000;
  padding:calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background:
    radial-gradient(1000px 700px at 12% 0%, rgba(74,163,255,.16), transparent 58%),
    radial-gradient(900px 700px at 100% 80%, rgba(56,210,122,.10), transparent 58%),
    rgba(8,12,17,.98);
}
.rulesPageShell{
  width:min(1400px, 100%);
  height:100%;
  margin:0 auto;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.12);
  border-radius:20px;
  background:rgba(15,20,26,.98);
  box-shadow:0 30px 90px rgba(0,0,0,.55);
}
.rulesPageHeader{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:24px;
  padding:20px 24px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.01));
}
.rulesPageHeading{min-width:0;}
.rulesPageEyebrow{
  color:var(--accent);
  font-size:11px;
  font-weight:900;
  letter-spacing:1.3px;
  text-transform:uppercase;
}
.rulesPageHeading h1{margin:5px 0 3px; font-size:clamp(22px, 3vw, 34px); line-height:1.1;}
.rulesPageHeading p{margin:0; color:var(--muted); font-size:13px;}
.rulesPageCloseBtn{flex:0 0 auto; min-width:130px;}
.rulesPageLayout{
  flex:1 1 auto;
  min-height:0;
  display:grid;
  grid-template-columns:240px minmax(0, 1fr);
}
.rulesPageNav{
  min-height:0;
  overflow-y:auto;
  padding:20px 14px;
  border-right:1px solid var(--line);
  background:rgba(0,0,0,.16);
}
.rulesPageNavTitle{
  margin:0 8px 10px;
  color:var(--muted);
  font-size:10px;
  font-weight:900;
  letter-spacing:1.15px;
  text-transform:uppercase;
}
.rulesPageNavList{display:flex; flex-direction:column; gap:4px;}
.rulesPageNavLink{
  display:block;
  padding:9px 10px;
  border:1px solid transparent;
  border-radius:10px;
  color:var(--muted);
  font-size:12px;
  font-weight:750;
  line-height:1.25;
  text-decoration:none;
}
.rulesPageNavLink:hover,
.rulesPageNavLink:focus-visible{
  color:var(--text);
  border-color:rgba(74,163,255,.28);
  background:rgba(74,163,255,.10);
  outline:none;
}
.rulesPageContent{
  min-width:0;
  min-height:0;
  overflow-y:auto;
  scroll-behavior:smooth;
  padding:28px clamp(22px, 4vw, 58px) 80px;
}
.rulesGuideSection{
  width:min(980px, 100%);
  margin:0 auto;
  padding:0 0 32px;
  scroll-margin-top:22px;
}
.rulesGuideSection + .rulesGuideSection{
  padding-top:32px;
  border-top:1px solid rgba(255,255,255,.09);
}
.rulesGuideSection h2{margin:0 0 9px; font-size:clamp(19px, 2.2vw, 25px); line-height:1.2;}
.rulesGuideSection h3{margin:22px 0 6px; font-size:14px;}
.rulesGuideLead{margin:0 0 16px; color:var(--muted); font-size:14px; line-height:1.6;}
.rulesGuideList{margin:12px 0 0; padding-left:22px; color:rgba(232,238,246,.94);}
.rulesGuideList li{padding-left:4px; margin:8px 0; font-size:13px; line-height:1.58;}
.rulesGuideList li::marker{color:var(--accent); font-weight:800;}
.rulesGuideStats{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:10px;
  margin-top:18px;
}
.rulesGuideStat{
  min-width:0;
  padding:13px 14px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:13px;
  background:rgba(0,0,0,.18);
}
.rulesGuideStatLabel{color:var(--muted); font-size:10px; font-weight:800; letter-spacing:.65px; text-transform:uppercase;}
.rulesGuideStatValue{margin-top:5px; font-size:13px; font-weight:850; line-height:1.35; overflow-wrap:anywhere;}
.rulesGuideCallout{
  margin-top:18px;
  padding:14px 16px;
  border:1px solid rgba(56,210,122,.28);
  border-radius:13px;
  background:rgba(56,210,122,.07);
}
.rulesGuideCallout.accent{border-color:rgba(74,163,255,.30); background:rgba(74,163,255,.08);}
.rulesGuideCalloutTitle{font-size:12px; font-weight:900;}
.rulesGuideCalloutText{margin-top:4px; color:rgba(232,238,246,.88); font-size:12px; line-height:1.55;}
.rulesGuideCosts{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px;
  margin:17px 0 18px;
}
.rulesGuideCost{
  min-width:0;
  padding:14px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:13px;
  background:linear-gradient(180deg, rgba(255,255,255,.035), rgba(0,0,0,.10));
}
.rulesGuideCost h3{margin:0 0 7px; font-size:13px;}
.rulesGuideCostValue{color:#b8d9ff; font-family:var(--mono); font-size:11px; line-height:1.45;}
.rulesGuideCostNote{margin-top:8px; color:var(--muted); font-size:11px; line-height:1.45;}
.rulesGuideSubheading{color:var(--text);}

@media (max-width: 900px){
  .rulesPage{padding:0;}
  .rulesPageShell{border:0; border-radius:0;}
  .rulesPageHeader{padding:calc(14px + var(--safe-top)) calc(14px + var(--safe-right)) 14px calc(14px + var(--safe-left)); gap:12px;}
  .rulesPageHeading h1{font-size:21px;}
  .rulesPageHeading p{font-size:11px;}
  .rulesPageCloseBtn{min-width:0; padding:9px 10px; font-size:12px;}
  .rulesPageLayout{display:flex; flex-direction:column;}
  .rulesPageNav{
    flex:0 0 auto;
    overflow-x:auto;
    overflow-y:hidden;
    padding:8px calc(10px + var(--safe-right)) 8px calc(10px + var(--safe-left));
    border-right:0;
    border-bottom:1px solid var(--line);
  }
  .rulesPageNavTitle{display:none;}
  .rulesPageNavList{width:max-content; flex-direction:row; gap:5px;}
  .rulesPageNavLink{padding:7px 9px; white-space:nowrap; font-size:11px;}
  .rulesPageContent{padding:22px calc(16px + var(--safe-right)) calc(60px + var(--safe-bottom)) calc(16px + var(--safe-left));}
  .rulesGuideStats{grid-template-columns:repeat(2, minmax(0, 1fr));}
  .rulesGuideCosts{grid-template-columns:repeat(2, minmax(0, 1fr));}
}

@media (max-width: 520px){
  .rulesPageEyebrow{font-size:9px;}
  .rulesPageHeading h1{font-size:18px;}
  .rulesPageHeading p{max-width:230px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
  .rulesGuideStats,
  .rulesGuideCosts{grid-template-columns:1fr;}
  .rulesGuideSection{padding-bottom:26px;}
  .rulesGuideSection + .rulesGuideSection{padding-top:26px;}
}


/* Mobile / tablet playability (no desktop view needed) */
@media (hover:none) and (pointer:coarse), (max-width: 980px) {
  .layout{
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(300px, 44vh);
    gap:10px;
    padding:10px;
  }
  .panel{
    height:auto;
    max-height:56vh;
    padding-right:0;
    padding-bottom:8px;
  }
  .boardWrap{min-height:34vh;}
  .topbar{padding:10px 12px; flex-wrap:wrap; gap:8px;}
  .brand .title{font-size:17px;}
  .brand .subtitle, .status{font-size:12px;}
  .row{flex-wrap:wrap;}
  .btn, .input, select, button{font-size:16px;}
  .btn{padding:12px 14px;}
  .input{padding:12px 12px;}
  .hudTopLeft, .hudBottomLeft{left:4px;}
  .rightHud{top:4px; right:4px; gap:6px;}
  .resourcesOverlay{left:4px; top:48px; width:min(92vw, 360px); max-width:none;}
  .logOverlay{right:4px; top:48px; width:min(96vw, 560px); max-width:none;}
  .hudBar{padding:8px 10px; border-radius:14px; max-width:calc(100% - 8px);}
  .nodeBuildConfirm{max-width:calc(100vw - 12px);}
  .buildPopup{max-width:min(92vw, 320px);}
  .audioSfxPanel{right:4px; top:48px; width:min(96vw, 380px);}
  #cartographerDraftPanel{max-width:min(96vw, 380px) !important;}
}

@media (max-width: 640px) {
  .layout{grid-template-rows:auto minmax(260px, 38vh); padding:8px; gap:8px;}
  .card{padding:10px;}
  .roomCode{font-size:16px; letter-spacing:1px;}
  .resourcesOverlay, .logOverlay{top:auto; bottom:4px; width:min(96vw, 420px);}
  .logOverlay .logList{max-height:180px;}
  .rightHud .countdownClock{min-width:132px;}
  .clockTime{font-size:18px;}
}


/* S24 Ultra / tall portrait phone pass */
@media (hover:none) and (pointer:coarse) and (orientation: portrait) and (max-width: 460px) {
  body{overflow:hidden;}
  #app{height:100dvh;}
  .topbar{
    padding:calc(8px + var(--safe-top)) calc(10px + var(--safe-right)) 8px calc(10px + var(--safe-left));
    gap:6px;
  }
  .brand .title{font-size:16px;}
  .brand .subtitle{display:none;}
  .status{font-size:11px; gap:6px; flex-wrap:wrap;}
  .layout{
    padding:6px;
    gap:6px;
    grid-template-rows:auto minmax(240px, 40dvh);
  }
  .card{padding:10px;}
  .panel{max-height:52dvh; padding-bottom:6px;}
  .boardWrap{border-radius:12px;}

  body.in-game .layout{padding:0; gap:0;}
  body.in-game .boardWrap{border-radius:0;}
  body.in-game .topbar,
  body.in-game .topbar *{max-width:100%;}

  .hudBar{
    padding:6px 8px;
    border-radius:12px;
    max-width:calc(100% - 8px - var(--safe-left) - var(--safe-right));
  }
  .hudTopLeft{left:calc(4px + var(--safe-left)); top:4px;}
  .hudBottomLeft{left:calc(4px + var(--safe-left)); bottom:calc(4px + var(--safe-bottom));}
  .hudBar .extraTurnBanner,
  .hudBar .placementTurnBanner{left:10px; bottom:calc(100% + 5px); font-size:15px;}
  .hudBarRow{gap:6px;}
  .hudBtns{gap:6px;}
  .btnTiny{padding:7px 9px; font-size:11px; border-radius:10px;}
  .hudTurnInfo{gap:8px;}
  .hudTurnInfo .turnInfo,
  .hudTurnInfo .timerInfo{font-size:11px; line-height:1.2;}

  .rightHud{right:calc(4px + var(--safe-right)); top:4px; gap:6px;}
  .countdownClock{min-width:124px; padding:6px 8px 8px; border-radius:12px;}
  .clockTime{font-size:17px; letter-spacing:.5px;}
  .clockMeta{font-size:10px;}
  .clockTopRow{gap:6px; margin-bottom:2px;}

  .resourcesOverlay{
    left:calc(4px + var(--safe-left));
    top:44px;
    width:min(calc(100vw - 8px - var(--safe-left) - var(--safe-right)), 360px);
    padding:10px;
  }
  .logOverlay{
    right:calc(4px + var(--safe-right));
    left:auto;
    top:auto;
    bottom:calc(4px + var(--safe-bottom));
    width:min(calc(100vw - 8px - var(--safe-left) - var(--safe-right)), 388px);
    padding:10px;
  }
  .logOverlay .logList{max-height:28dvh;}
  .hudDevOverlay{
    left:calc(4px + var(--safe-left));
    width:min(calc(100vw - 8px - var(--safe-left) - var(--safe-right)), 388px);
    max-height:42dvh;
    top:104px;
    padding:10px;
  }
  .audioSfxPanel{
    right:calc(4px + var(--safe-right));
    top:44px;
    width:min(calc(100vw - 8px - var(--safe-left) - var(--safe-right)), 388px);
  }
  #cartographerDraftPanel{
    left:calc(4px + var(--safe-left)) !important;
    right:auto !important;
    bottom:calc(4px + var(--safe-bottom)) !important;
    width:min(calc(100vw - 8px - var(--safe-left) - var(--safe-right)), 388px) !important;
    max-width:min(calc(100vw - 8px - var(--safe-left) - var(--safe-right)), 388px) !important;
  }

  /* tighter modal controls while keeping touch targets usable */
  .btn, .input, select, button{font-size:15px;}
  .btn{padding:11px 12px;}
  .input{padding:11px 11px;}
}

@media (hover:none) and (pointer:coarse) and (orientation: portrait) and (max-width: 430px) {
  .resourcesOverlay .pResGrid,
  .resourcesOverlay .pPieceGrid{font-size:10px;}
  .resourcesOverlay .resIcon{width:16px; height:16px;}
  .resourcesOverlay .resVal{font-size:11px;}
  .hudBarScaleHost .tabScaleLabel,
  .panelScaleHost .tabScaleLabel{min-width:46px;}
}

@media (max-width: 1180px){
  :root{--right-sidebar-width: min(420px, 40vw);}
  body.in-game .boardWrap{padding-right:var(--right-sidebar-width, 420px);}
}

@media (max-width: 900px){
  :root{--right-sidebar-width: min(340px, 44vw);}
  .rightSidebarResize{flex-basis:6px; width:6px;}
  body.in-game .rightHud{right:calc(var(--right-sidebar-width, 340px) + 6px);}
}

/* Keep the board usable on phones; the player panels scroll beneath it. */
@media (max-width: 900px){
  body.in-game .boardWrap{padding-right:0;}
  body.in-game .rightSidebar{
    position:relative;
    flex:0 0 36%;
    width:100% !important;
    min-height:0;
    border-left:0;
    border-top:1px solid var(--line);
  }
  body.in-game .rightSidebarResize{display:none;}
  body.in-game .rightSidebarInner{overflow-y:auto; padding:10px;}
  body.in-game .rightSidebarInner > #logCard,
  body.in-game .rightSidebarInner > #devCard{flex:0 0 auto;}
  body.in-game .rightSidebar .devHand,
  body.in-game .rightSidebar .logList{max-height:180px; overflow-y:auto;}
  body.in-game .rightHud{right:6px; top:60px;}
  body.in-game .hudBottomLeft{bottom:calc(36% + 6px);}
  body.in-game .hudBar{padding:6px; max-width:calc(100% - 8px);}
  body.in-game .hudBar .btn{font-size:12px; padding:8px 10px;}
  body.in-game .hudTurnInfo{display:none;}
  body.in-game #errBox{top:160px; max-width:calc(100% - 24px);}
  body.in-game .hudBarRow{gap:6px;}
  body.in-game .pausedOverlay{right:0; bottom:36%;}
  body.in-game .yourRollBanner,body.in-game .extraTurnCenterBanner{left:50%; top:32%; font-size:clamp(30px, 8vw, 60px);}
}

/* Administrator user management */
.userManagementPanel{display:flex; flex-direction:column; gap:10px; max-height:min(72vh,760px)}
.userManagementIntro{color:var(--muted); line-height:1.45}
.userManagementSearch{width:100%}
.userManagementCount{margin-top:2px}
.userManagementList{display:flex; flex-direction:column; gap:10px; overflow:auto; padding-right:4px}
.userManagementRow{display:grid; grid-template-columns:minmax(0,1fr) minmax(250px,.85fr); gap:12px; padding:12px; border:1px solid var(--line); border-radius:14px; background:rgba(0,0,0,.16)}
.userManagementIdentity{min-width:0}
.userManagementTitle{display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-family:var(--mono); font-size:13px; font-weight:900; color:var(--text); word-break:break-word}
.userManagementBadge{padding:2px 7px; border-radius:999px; border:1px solid rgba(255,190,70,.55); background:rgba(255,172,35,.12); color:#ffd37b; font-size:10px; text-transform:uppercase; letter-spacing:.06em}
.userManagementPlayerName{margin-top:5px; color:var(--text); font-size:12px}
.userManagementMeta{margin-top:5px; color:var(--muted); font-size:11px; line-height:1.4}
.userManagementControls{display:grid; grid-template-columns:minmax(0,1fr) auto; align-content:start; gap:8px}
.userManagementPassword{min-width:0}
.userManagementStatus{grid-column:1 / -1; min-height:16px; color:var(--muted); font-size:11px}
.userManagementStatus.success{color:#72ee9b}
.userManagementStatus.error,.userManagementError{color:#ff7b82}
.btn.danger{border-color:rgba(255,90,100,.45); color:#ff9ca3; background:rgba(120,20,28,.22)}
.btn.danger:hover{background:rgba(150,26,36,.32)}
@media (max-width:720px){
  .userManagementRow{grid-template-columns:1fr}
  .userManagementControls{grid-template-columns:1fr}
  .userManagementControls .btn{width:100%}
}

/* Self-service account and email recovery */
.btn.subtle{background:rgba(255,255,255,.035); color:var(--muted)}
.btn.subtle:hover{background:rgba(255,255,255,.075); color:var(--text)}
.userManagementWarning{padding:10px 12px; border:1px solid rgba(255,179,71,.42); border-radius:10px; background:rgba(118,72,10,.18); color:#ffd99a; font-size:12px; line-height:1.45}
.userManagementNotice{padding:10px 12px; border:1px solid rgba(78,166,255,.38); border-radius:10px; background:rgba(20,76,128,.18); color:#b9ddff; font-size:12px; line-height:1.45}
.userManagementRow.self{border-color:rgba(70,178,255,.38); box-shadow:0 0 0 1px rgba(70,178,255,.08) inset}
.userManagementBadge.selfBadge{border-color:rgba(77,190,255,.55); background:rgba(40,130,190,.14); color:#9edcff}
.userManagementEmailLine{margin-top:6px; color:#b9c8d4; font-size:11px; line-height:1.4; word-break:break-word}
.userManagementPending{margin-top:4px; color:#ffd37b; font-size:11px; line-height:1.4; word-break:break-word}
.userManagementControls{display:flex; flex-direction:column; gap:10px; min-width:0}
.userManagementSection{display:flex; flex-direction:column; gap:8px; padding:10px; border:1px solid rgba(255,255,255,.09); border-radius:11px; background:rgba(0,0,0,.13); min-width:0}
.userManagementSection .btn{align-self:flex-start}
.userManagementEmailButtons{gap:8px; flex-wrap:wrap}
.passwordRecoveryPanel{display:flex; flex-direction:column; gap:10px; min-width:min(440px,72vw)}
.passwordRecoveryPanel .btn{align-self:flex-start}
@media (max-width:720px){
  .passwordRecoveryPanel{min-width:0}
  .userManagementSection .btn{align-self:stretch; width:100%}
  .userManagementEmailButtons{display:grid; grid-template-columns:1fr}
}
.portalScreen{position:fixed;inset:0;z-index:900;display:grid;place-items:center;padding:24px;overflow:auto;background:#081019}.portalScreen.hidden{display:none}.portalBackdrop{position:absolute;inset:0;background:radial-gradient(circle at 50% 15%,rgba(214,161,43,.2),transparent 35%),linear-gradient(145deg,rgba(8,16,25,.94),rgba(11,25,36,.98)),url('/texture-pack/favicon.png');pointer-events:none}.portalCard{position:relative;z-index:1;width:min(520px,100%);padding:34px;border:1px solid rgba(123,174,205,.38);border-radius:24px;background:rgba(14,25,35,.96);box-shadow:0 30px 90px rgba(0,0,0,.55);color:#eef5f8}.authPortalCard{text-align:center}.portalLogo{display:block;width:230px;max-width:65%;height:auto;margin:-10px auto 12px;filter:drop-shadow(0 12px 20px rgba(0,0,0,.4))}.modeLogo{width:150px}.portalCard h1,.portalCard h2{margin:0 0 10px;color:#fff}.portalLead{color:#aebfca;line-height:1.55}.portalForm{text-align:left;margin:25px auto 0;max-width:370px}.portalPrimary{width:100%;justify-content:center;margin-top:16px;padding:13px}.portalTextBtn{display:block;margin:14px auto 0;border:0;background:none;color:#87bce0;cursor:pointer}.portalEyebrow{margin:0 0 8px;color:#e0ae3a;text-transform:uppercase;letter-spacing:.16em;font-size:11px;font-weight:800}.modePortalCard{width:min(760px,100%);text-align:center}.modeChoices{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin-top:28px}.modeChoice{padding:28px 22px;border:1px solid #36566b;border-radius:18px;background:#111d27;color:#fff;text-align:left;cursor:pointer;transition:.18s}.modeChoice:hover{transform:translateY(-3px);border-color:#e0ae3a;background:#162735}.modeChoice strong{display:block;font-size:22px;margin-bottom:10px}.modeChoice span{color:#aebfca;line-height:1.5}.accountOrb{position:fixed;right:18px;top:18px;z-index:850;width:46px;height:46px;border-radius:50%;border:2px solid #d9a62e;background:#152737;color:#fff;font-weight:900;font-size:18px;box-shadow:0 7px 24px rgba(0,0,0,.4);cursor:pointer}.accountMenu{position:fixed;right:18px;top:72px;z-index:860;width:230px;padding:10px;border:1px solid #35546a;border-radius:14px;background:#101a23;box-shadow:0 18px 50px rgba(0,0,0,.55)}.accountMenuName{padding:10px 12px 13px;color:#fff;font-weight:800;border-bottom:1px solid #263b49}.accountMenuItem{display:block;width:100%;padding:11px 12px;border:0;background:none;color:#d9e4eb;text-align:left;border-radius:8px;cursor:pointer}.accountMenuItem:hover{background:#1a2a36}.dangerText{color:#ff8274}.friendBadge{float:right;padding:1px 6px;border-radius:99px;background:#e85d45;color:#fff}.portalOverlay{position:fixed;inset:0;z-index:950;display:grid;place-items:center;padding:20px;background:rgba(3,8,12,.82);overflow:auto}.portalOverlay.hidden{display:none}.registerCard{width:min(470px,100%);text-align:left}.overlayClose{position:absolute;right:18px;top:14px;border:0;background:none;color:#aebfca;font-size:28px;cursor:pointer}.rankedCard{width:min(520px,100%)}.rankSummary{margin:18px 0;padding:14px;border:1px solid #5c4c22;border-radius:12px;background:rgba(217,166,46,.09);color:#f0c75d;font-weight:800}.friendsList{display:grid;gap:10px;max-height:55vh;overflow:auto}.friendRow{padding:12px;border:1px solid #294252;border-radius:10px}.friendRequestToast{position:fixed;right:18px;bottom:18px;z-index:980;padding:16px 18px;border:1px solid #d9a62e;border-radius:12px;background:#14232e;color:#fff;box-shadow:0 15px 45px rgba(0,0,0,.5)}
.passwordRevealField{position:relative}.passwordRevealField .input{width:100%;padding-right:68px}.passwordRevealBtn{position:absolute;right:7px;top:50%;transform:translateY(-50%);min-width:52px;padding:6px 8px;border:1px solid #39576b;border-radius:8px;background:#162633;color:#cfe1ec;font-size:12px;font-weight:800;cursor:pointer;user-select:none;touch-action:none}.passwordRevealBtn:active,.passwordRevealBtn.revealing{border-color:#d9a62e;color:#fff;background:#26351e}
.loginSupport{position:fixed;z-index:3;right:max(18px,env(safe-area-inset-right));bottom:max(18px,env(safe-area-inset-bottom));display:flex}.loginSupport a{display:inline-flex;border-radius:8px;filter:drop-shadow(0 8px 18px rgba(0,0,0,.48));transition:transform .16s,filter .16s}.loginSupport a:hover,.loginSupport a:focus-visible{transform:translateY(-2px);filter:brightness(1.08) drop-shadow(0 9px 20px rgba(0,0,0,.55));outline:2px solid rgba(217,166,46,.7);outline-offset:3px}.loginSupport img{display:block;height:36px;width:auto;border:0}@media(max-width:560px){.loginSupport{right:max(10px,env(safe-area-inset-right));bottom:max(10px,env(safe-area-inset-bottom))}.loginSupport img{height:32px}}
.playerProfileLink{cursor:pointer;border-radius:9px;padding:4px 6px;margin:-4px -6px;transition:background .16s,transform .16s}.playerProfileLink:hover,.playerProfileLink:focus-visible{background:rgba(93,167,210,.13);outline:1px solid rgba(93,167,210,.45);transform:translateY(-1px)}.friendProfileLink{border:0;background:none;color:#dceaf2;font:inherit;font-weight:800;padding:3px 4px;cursor:pointer}.friendProfileLink:hover{text-decoration:underline;color:#fff}.friendRowProfile{width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;background:#101b24;color:#dceaf2;text-align:left;cursor:pointer}.friendRowProfile:hover{border-color:#d9a62e;background:#152633}.friendRowProfile span:first-child{display:grid;gap:2px}.friendRowProfile small{color:#8399a7}.friendPresence{font-size:11px;color:#8399a7}.friendPresence.online{color:#61d995}.playerProfileCard{min-width:min(500px,78vw);overflow:hidden}.playerProfileHero{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:15px;padding:18px;border:1px solid rgba(217,166,46,.35);border-radius:16px;background:radial-gradient(circle at 0 0,rgba(217,166,46,.16),transparent 45%),linear-gradient(145deg,#152735,#0e1821)}.playerProfileAvatar{display:grid;place-items:center;width:64px;height:64px;border:2px solid #d9a62e;border-radius:50%;background:#1d3445;color:#fff;font-size:27px;font-weight:950;box-shadow:0 8px 24px rgba(0,0,0,.35)}.playerProfileName{color:#fff;font-size:22px;font-weight:900}.playerProfileUsername{margin-top:3px;color:#91a8b7}.playerProfileRating{display:grid;justify-items:end;color:#f0c75d}.playerProfileRating span{font-size:9px;letter-spacing:.13em;font-weight:900}.playerProfileRating strong{font-size:25px}.playerProfileStats{display:grid;grid-template-columns:repeat(3,1fr);gap:9px;margin-top:12px}.playerProfileStat{display:grid;place-items:center;padding:13px 8px;border:1px solid #293f4e;border-radius:12px;background:rgba(12,22,30,.72)}.playerProfileStat strong{color:#fff;font-size:20px}.playerProfileStat span{margin-top:3px;color:#8fa4b2;font-size:10px;text-transform:uppercase;letter-spacing:.08em}.playerProfileFooter{margin-top:12px;color:#8298a6;text-align:center;font-size:11px}@media(max-width:540px){.playerProfileCard{min-width:0}.playerProfileHero{grid-template-columns:auto 1fr}.playerProfileRating{grid-column:1/-1;justify-items:center}.playerProfileStats{grid-template-columns:repeat(2,1fr)}}
@media(max-width:650px){.modeChoices{grid-template-columns:1fr}.portalScreen{padding:12px}.portalCard{padding:26px 20px}.portalLogo{width:185px}}
@media(max-width:650px){.rankedScenarioOptions{grid-template-columns:1fr}.rankedScenarioOption{min-height:58px}}
.accountOrb{z-index:990}.accountMenu{z-index:1000}
.portalBackdrop{background:radial-gradient(circle at 50% 15%,rgba(214,161,43,.2),transparent 35%),linear-gradient(145deg,#081019,#0b1924)}

/* November: anchor the account button immediately LEFT of the resizeable game sidebar. */
body.in-game .accountOrb{
  top:12px;
  right:calc(var(--right-sidebar-width, 520px) + 8px);
}
body.in-game .accountMenu{
  top:68px;
  right:calc(var(--right-sidebar-width, 520px) + 8px);
}
/* Allow the admin console to show both long member labels and their Kick actions. */
.modalBox:has(.serverManagementPanel){
  width:min(1010px, calc(100vw - 32px));
  max-height:calc(100dvh - 28px);
  display:flex;
  flex-direction:column;
}
.modalBox:has(.serverManagementPanel) .modalBody{min-height:0;overflow:auto;}
.serverManagementPanel{width:100%;max-height:min(70dvh,780px);overflow:auto;}
.serverManagementMember{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:16px;
  padding:5px 0;
}
.serverManagementMemberName{min-width:0;overflow-wrap:anywhere;}
.serverManagementMember .btn{flex-shrink:0;min-width:65px;}
@media(max-width:520px){
  body.in-game .accountMenu{right:10px;max-width:calc(100vw - 20px);}
  .serverManagementMember{gap:8px;}
}

/* v14: Center both prompts in the visible board canvas, not the whole window. */
body.in-game .yourRollBanner,
body.in-game .extraTurnCenterBanner{
  left:calc((100% - var(--right-sidebar-width, 520px)) / 2);
  top:50%;
  font-size:clamp(34px, 6vw, 92px);
}

/* Administrator rating studio: keyboard and touch accessible without horizontal scrolling. */
.modalBox:has(.ratingManagementPanel){width:min(960px,calc(100vw - 24px));max-height:calc(100dvh - 24px);display:flex;flex-direction:column;}
.modalBox:has(.ratingManagementPanel) .modalBody{overflow:auto;min-height:0;overscroll-behavior:contain;}
.ratingManagementPanel{display:flex;flex-direction:column;gap:12px;width:100%;padding:0 2px;}
.ratingManagementPanel h3{font-size:15px;margin:10px 0 0;color:#f5d58c;}
.ratingManagementFields{display:grid;grid-template-columns:repeat(auto-fit,minmax(225px,1fr));gap:10px;}
.ratingManagementField{display:flex;flex-direction:column;gap:6px;border:1px solid var(--line);padding:10px;border-radius:12px;background:rgba(0,0,0,.13);color:var(--text);font-size:12px;}
.ratingManagementField .input{font-size:16px;min-height:44px;}
.ratingManagementActions{display:flex;gap:10px;flex-wrap:wrap;}
.ratingManagementActions .btn{min-height:44px;}
.ratingConfirm{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:12px;color:var(--muted);}
.ratingConfirm .input{width:200px;max-width:100%;}
.ratingPreviewResults{max-height:320px;overflow:auto;border:1px solid var(--line);border-radius:12px;}
.ratingPreviewTable{border-collapse:collapse;width:100%;font-size:12px;}
.ratingPreviewTable th,.ratingPreviewTable td{padding:9px 12px;text-align:left;border-bottom:1px solid var(--line);white-space:nowrap;}
.ratingPreviewTable th{position:sticky;top:0;background:#1a2b3b;}
.mobileGameControls,.mobilePanelTitle{display:none;}

/* Phone and tablet gameplay: prioritize the touch board. Drawer is closed by default. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px){
  body.in-game .boardWrap{padding-right:0 !important;min-height:0;position:relative;}
  body.in-game .rightSidebar{
    position:absolute !important;left:0;right:0;top:auto;bottom:0;
    width:100% !important;height:min(62dvh,620px);max-height:calc(100dvh - 70px);
    flex:none;min-height:0;border-left:0;border-top:1px solid rgba(123,174,205,.45);
    border-radius:18px 18px 0 0;z-index:30;
    box-shadow:0 -16px 60px rgba(0,0,0,.7);
    transform:translateY(105%);visibility:hidden;pointer-events:none;
    transition:transform .2s ease,visibility .2s ease;
  }
  body.in-game.mobilePanelsOpen .rightSidebar{transform:translateY(0);visibility:visible;pointer-events:auto;}
  body.in-game .rightSidebarInner{padding:10px 14px calc(76px + var(--safe-bottom));overflow-y:auto;overscroll-behavior:contain;}
  body.in-game .rightSidebarResize{display:none;}
  body.in-game .rightSidebar #resourcesCard{position:relative;}
  body.in-game .rightSidebar .logList{max-height:220px;}
  body.in-game .rightSidebar .devHand{max-height:200px;}
  body.in-game .yourRollBanner,body.in-game .extraTurnCenterBanner{
    left:50%;top:50%;font-size:clamp(30px,7.5vw,66px);max-width:95%;
  }
  body.in-game .pausedOverlay{right:0;bottom:0;}
  body.in-game #errBox{top:95px;max-width:calc(100% - 24px);}
  body.in-game .hudBottomLeft{bottom:calc(60px + var(--safe-bottom));left:6px;right:6px;width:auto;max-width:calc(100% - 12px);}
  body.in-game .hudBar{max-width:calc(100% - 12px);}
  body.in-game .hudBottomLeft .hudBarRow{display:flex;align-items:center;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin;}
  body.in-game .hudBottomLeft .hudBtns{flex-wrap:nowrap;width:max-content;}
  body.in-game .hudBottomLeft .btn{min-height:44px;min-width:44px;white-space:nowrap;touch-action:manipulation;font-size:12px;padding:9px 12px;}
  body.in-game .hudBottomLeft .hudTurnInfo{display:none;}
  body.in-game .hudTopLeft{
    display:none;position:absolute !important;top:calc(72px + var(--safe-top)) !important;left:6px !important;right:6px !important;bottom:auto !important;
    width:auto !important;max-width:calc(100% - 12px);max-height:55dvh;overflow:auto;z-index:32;
  }
  body.in-game.mobileActionsOpen .hudTopLeft{display:block;}
  body.in-game .hudTopLeft .hudBtns{display:flex;flex-wrap:wrap;}
  body.in-game .hudTopLeft .btn{min-height:44px;min-width:44px;}
  body.in-game.mobilePanelsOpen .hudBottomLeft{visibility:hidden;pointer-events:none;}
  body.in-game .rightHud{right:calc(6px + var(--safe-right));top:calc(65px + var(--safe-top));gap:5px;}
  body.in-game .rightHud .btn{min-height:40px;min-width:44px;padding:7px 10px;}
  body.in-game .accountOrb{top:calc(8px + var(--safe-top));right:calc(8px + var(--safe-right));width:44px;height:44px;}
  body.in-game .accountMenu{top:calc(59px + var(--safe-top));right:calc(8px + var(--safe-right));}
  body.in-game .hudBar .extraTurnBanner{font-size:15px;}
  body.in-game .mobileGameControls{
    position:absolute;display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;
    left:calc(6px + var(--safe-left));right:calc(6px + var(--safe-right));bottom:calc(5px + var(--safe-bottom));z-index:34;
  }
  .mobileControlBtn{
    min-height:46px;min-width:0;padding:9px 8px;border:1px solid #4f718b;border-radius:12px;
    background:rgba(12,26,38,.95);color:#f3f8ff;font-size:13px;font-weight:800;
    box-shadow:0 4px 16px rgba(0,0,0,.4);touch-action:manipulation;
  }
  body.in-game .mobilePanelTitle{
    display:flex;justify-content:space-between;align-items:center;gap:10px;
    padding:10px 14px 7px;border-bottom:1px solid var(--line);font-size:15px;
  }
  .mobilePanelTitle .mobileControlBtn{min-height:40px;}
  .mobileGameControls .mobileControlBtn[aria-expanded="true"]{border-color:#edc15d;background:#263b4c;}
  .modalBox,.portalCard{max-width:calc(100vw - 16px);}
  .ratingManagementFields{grid-template-columns:repeat(auto-fit,minmax(180px,1fr));}
}
@media(max-width:480px){
  body.in-game .rightHud{top:calc(58px + var(--safe-top));}
  body.in-game .hudBottomLeft{bottom:calc(58px + var(--safe-bottom));}
  .ratingManagementFields{grid-template-columns:1fr 1fr;gap:6px;}
  .ratingManagementField{padding:7px;font-size:11px;}
  .ratingManagementActions{display:grid;grid-template-columns:1fr;}
  .ratingManagementActions .btn{width:100%;}
}
@media(prefers-reduced-motion:reduce){body.in-game .rightSidebar{transition:none;}}
/* Mobile positions override saved desktop drag coordinates (otherwise controls can disappear). */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px){
  body.in-game .hudBottomLeft{
    position:absolute !important;top:auto !important;left:6px !important;right:6px !important;
    bottom:calc(60px + var(--safe-bottom)) !important;
  }
  body.in-game .rightHud{
    position:absolute !important;top:calc(65px + var(--safe-top)) !important;
    left:auto !important;bottom:auto !important;right:calc(6px + var(--safe-right)) !important;
  }
}
@media(max-width:480px){
  body.in-game .rightHud{top:calc(58px + var(--safe-top)) !important;}
}

/* Ranked lobby: full-screen ballot, no private-lobby setup controls or board. */
body.ranked-lobby .layout{display:block;height:100%;min-height:0;overflow:hidden;padding:14px;}
body.ranked-lobby .layout>.boardWrap{display:none!important;}
body.ranked-lobby .layout>.panel{width:100%;max-width:none;height:100%;max-height:none;overflow-y:auto;padding:0 0 24px;}
body.ranked-lobby #lobbyCard{width:100%;min-height:calc(100% - 4px);padding:clamp(16px,2.8vw,38px);}
body.ranked-lobby #lobbyCard>h2{font-size:22px;letter-spacing:.6px;margin-bottom:16px;}
body.ranked-lobby #lobbyCard .ranked-unavailable,
body.ranked-lobby #createBtn{display:none!important;}
body.ranked-lobby #lobbyRulesBtn{flex:0 1 180px;}
body.ranked-lobby #roomCode{display:none;}
.rankedRoomHeader{display:none;font-size:13px;letter-spacing:2px;font-weight:800;color:#ffd67e;}
body.ranked-lobby .rankedRoomHeader{display:block;}
body.ranked-lobby #roomBox{background:transparent;border:0;padding:0;}
body.ranked-lobby #rankedScenarioVote{margin-top:24px;}
body.ranked-lobby #texturePackRow{margin-top:20px;}
body.ranked-lobby .lobbyPlayersHeading{font-weight:750;font-size:13px;margin-top:22px;}
body.ranked-lobby #playersList{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;}
body.ranked-lobby #playersList .playerRow{border:1px solid rgba(255,255,255,.09);background:rgba(9,16,25,.65);border-radius:12px;padding:12px;}
.rankedScenarioVote{padding:clamp(18px,2vw,32px);border:2px solid #e6b94e;border-radius:20px;background:linear-gradient(155deg,rgba(222,167,49,.16),rgba(48,83,99,.09) 60%,rgba(222,167,49,.04));box-shadow:0 0 34px rgba(218,157,42,.12),inset 0 1px rgba(255,238,170,.16);}
.rankedScenarioVoteHeading{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;}
.rankedScenarioVoteTitle{font-size:clamp(19px,2.6vw,34px);font-weight:900;letter-spacing:.9px;color:#ffdb84;text-shadow:0 0 18px rgba(227,172,62,.22);}
.rankedScenarioCountdown{font-size:clamp(24px,3.5vw,42px);font-family:var(--mono);font-weight:900;color:#fff1b6;font-variant-numeric:tabular-nums;line-height:1;}
.rankedScenarioCountdown.expiring{color:#ff8b75;}
.rankedScenarioVoteInstructions{margin:10px 0 18px;font-size:13px;line-height:1.5;color:#e3d7b6;}
.rankedScenarioOptions{gap:clamp(10px,1.5vw,20px);margin-top:0;}
.rankedScenarioOption{min-height:255px;padding:12px;gap:12px;border:2px solid #395468;border-radius:16px;background:linear-gradient(180deg,#142635,#0c1823);box-shadow:0 10px 22px rgba(0,0,0,.2);transition:border-color .12s,transform .12s,box-shadow .12s;}
.rankedScenarioOption:hover{transform:translateY(-2px);border-color:#f1c15a;box-shadow:0 12px 26px rgba(0,0,0,.35);}
.rankedScenarioOption.selected{border-color:#ffce69;background:linear-gradient(180deg,#29392c,#201e19);box-shadow:0 0 0 2px rgba(224,174,58,.2) inset,0 0 26px rgba(240,176,45,.2);}
.rankedScenarioMapPreview{width:100%;height:auto;aspect-ratio:3/2;object-fit:contain;border-radius:10px;background:radial-gradient(ellipse,#1b3546,#091722);}
.rankedScenarioOptionInfo{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;flex-wrap:wrap;}
.rankedScenarioOptionInfo strong{font-size:clamp(14px,1.5vw,19px);}
.rankedScenarioOptionInfo span{font-size:12px;}
.rankedScenarioSelectedMark{font-size:11px!important;color:#f2c962!important;font-weight:800;letter-spacing:1.2px!important;}
@media (max-width:780px){
  body.ranked-lobby .layout{padding:6px;}
  body.ranked-lobby #lobbyCard{padding:12px;}
  .rankedScenarioOptions{grid-template-columns:1fr;}
  .rankedScenarioOption{min-height:0;}
  .rankedScenarioMapPreview{max-height:235px;}
  body.ranked-lobby #playersList{grid-template-columns:repeat(2,minmax(0,1fr));}
}
@media (max-width:430px){body.ranked-lobby #playersList{grid-template-columns:1fr;}}

body.ranked-lobby #app .layout>.panel>.card:not(#lobbyCard){display:none!important;}
.rankedScenarioOption:disabled{cursor:default;opacity:.79;}
.rankedScenarioOption:disabled:hover{transform:none;}


/* v18 ranked lobby: viewport-first density without clipping controls or text.
   On touch/small viewports scrolling is a deliberate accessibility fallback. */
body.ranked-lobby .layout{
  display:block; height:100%; min-height:0; overflow:hidden;
  padding:clamp(6px,1.1vh,12px);
}
body.ranked-lobby .layout>.panel{
  display:block; width:100%; max-width:none; height:100%; max-height:none;
  overflow-x:hidden; overflow-y:hidden; padding:0;
}
body.ranked-lobby #lobbyCard{
  position:relative; width:100%; height:100%; min-height:0;
  overflow:hidden; padding:clamp(10px,1.5vh,16px) clamp(12px,1.45vw,22px);
  display:flex; flex-direction:column; gap:0;
}
body.ranked-lobby #lobbyCard>h2{display:none;}
body.ranked-lobby .lobbyPrimaryActions{
  position:absolute; right:clamp(78px,5.2vw,94px); top:clamp(8px,1.3vh,14px);
  margin:0; z-index:2;
}
body.ranked-lobby #lobbyRulesBtn{width:auto; min-width:92px; flex:none; padding:5px 12px; font-size:12px;}
body.ranked-lobby #roomBox{
  flex:1 1 auto; min-height:0; width:100%; display:grid;
  grid-template-columns:minmax(0,3fr) minmax(180px,1fr);
  grid-template-rows:auto minmax(0,auto) auto auto auto auto auto;
  align-content:start; align-items:start; column-gap:clamp(10px,1.3vw,18px); row-gap:clamp(3px,.6vh,8px);
  border:0; border-radius:0; background:none; padding:0;
}
body.ranked-lobby #roomBox>.roomTop{grid-column:1/-1; padding-right:202px; min-height:25px; margin:0;}
body.ranked-lobby .rankedRoomHeader{font-size:clamp(12px,1.5vh,15px); line-height:1.4; letter-spacing:1.3px;}
body.ranked-lobby #rankedScenarioVote{
  grid-column:1/-1; margin:0; padding:clamp(8px,1.2vh,14px) clamp(10px,1.2vw,18px);
  border-width:1px; border-radius:14px;
}
body.ranked-lobby .rankedScenarioVoteHeading{gap:8px; flex-wrap:nowrap; align-items:center;}
body.ranked-lobby .rankedScenarioVoteTitle{
  font-size:clamp(17px,2.3vh,25px); line-height:1.2; letter-spacing:.35px;
  min-width:0; overflow-wrap:anywhere;
}
body.ranked-lobby .rankedScenarioCountdown{font-size:clamp(21px,3.1vh,35px); flex:none;}
body.ranked-lobby .rankedScenarioVoteInstructions{
  margin:4px 0 clamp(6px,.95vh,10px); font-size:clamp(10px,1.4vh,12px);
  line-height:1.35; overflow-wrap:anywhere;
}
body.ranked-lobby .rankedScenarioOptions{gap:clamp(8px,1.15vw,16px);}
body.ranked-lobby .rankedScenarioOption{
  min-width:0; min-height:0; padding:clamp(6px,.8vw,10px); gap:clamp(4px,.65vh,8px);
  border-width:1px; border-radius:12px;
}
body.ranked-lobby .rankedScenarioMapPreview{
  width:100%; height:clamp(170px,calc((100dvh - 475px)*.52 + 160px),315px);
  min-height:0; aspect-ratio:auto; object-fit:contain; flex:none;
  border-radius:8px;
}
body.ranked-lobby .rankedScenarioOptionInfo{
  display:flex; flex-wrap:nowrap; align-items:flex-start; justify-content:space-between;
  width:100%; min-width:0; gap:5px;
}
body.ranked-lobby .rankedScenarioOptionInfo strong{
  flex:1 1 auto; min-width:0; font-size:clamp(12px,1.6vh,16px);
  line-height:1.2; overflow-wrap:anywhere; word-break:normal;
}
body.ranked-lobby .rankedScenarioOptionInfo span{
  flex:none; white-space:nowrap; font-size:10px;
}
body.ranked-lobby .rankedScenarioSelectedMark{font-size:10px!important; line-height:1.3;}
body.ranked-lobby #roomBox>.roomShareControls{
  grid-column:1; margin:0!important; min-width:0;
}
body.ranked-lobby #roomBox>.roomAccountControls{
  grid-column:2; margin:0!important; min-width:0; align-self:end;
}
body.ranked-lobby #roomShareLabel,body.ranked-lobby .roomAccountControls .labelTiny{
  margin:0 0 3px; font-size:10px; line-height:1.2;
}
body.ranked-lobby .roomShareControls>.row{margin:0!important; gap:6px!important; flex-wrap:nowrap!important;}
body.ranked-lobby .roomShareControls .input{min-width:0!important; padding:7px 9px; height:32px; font-size:10px!important;}
body.ranked-lobby .roomShareControls .btn{padding:6px 10px; white-space:nowrap; font-size:11px;}
body.ranked-lobby #myAccountLabel{white-space:nowrap; overflow:hidden; text-overflow:ellipsis; word-break:normal!important;}
body.ranked-lobby #texturePackRow{
  grid-column:1/-1; margin:0!important; min-width:0;
}
body.ranked-lobby #texturePackRow>.labelTiny{margin:0 0 3px; line-height:1.2; font-size:10px;}
body.ranked-lobby #texturePackRow>.row{margin:0; gap:6px!important; flex-wrap:nowrap!important;}
body.ranked-lobby #texturePackSelect{min-width:0!important; height:30px; padding:4px 8px; font-size:12px;}
body.ranked-lobby #texturePackRow .btn{padding:5px 9px; white-space:nowrap; font-size:11px;}
body.ranked-lobby #texturePackStatus{display:none;}
body.ranked-lobby #roomBox>.lobbyPlayersHeading{
  grid-column:1/-1; margin:0!important; line-height:1.2; font-size:11px; min-width:0;
}
body.ranked-lobby #playersList{
  grid-column:1/-1; margin:0; gap:clamp(6px,.7vw,10px);
  grid-template-columns:repeat(4,minmax(0,1fr)); min-width:0;
}
body.ranked-lobby #playersList .playerRow{
  padding:clamp(6px,.65vw,9px); min-width:0; gap:5px;
}
body.ranked-lobby #playersList .playerTag{min-width:0; gap:7px;}
body.ranked-lobby #playersList .playerTag>div:last-child{min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
body.ranked-lobby #playersList .btn{padding:5px 6px; font-size:10px;}
body.ranked-lobby #playersList .lobbyReadyStatus{padding:3px 6px; font-size:9px;}
body.ranked-lobby #colorPickerRow{grid-column:1/-1; margin:0; min-width:0;}
body.ranked-lobby #colorPickerRow>.labelTiny{margin:0 0 4px!important; font-size:10px;}
body.ranked-lobby #colorPicker{margin:0; gap:7px;}
body.ranked-lobby #colorPicker .colorChip{width:23px; height:23px;}
body.ranked-lobby #colorPickerRow>.smallNote{display:none;}
body.ranked-lobby #aiFillRow{grid-column:1/-1;}
body.ranked-lobby #errBox{flex:none; padding:6px 8px; margin:3px 0 0;}

/* Compact controls in short desktop windows; long names wrap inside cards, not across borders. */
@media (min-width:781px) and (max-height:760px){
  body.ranked-lobby .layout{padding:5px;}
  body.ranked-lobby #lobbyCard{padding:8px 12px;}
  body.ranked-lobby .lobbyPrimaryActions{top:7px;right:78px;}
  body.ranked-lobby #roomBox{row-gap:3px;}
  body.ranked-lobby #rankedScenarioVote{padding:7px 10px;}
  body.ranked-lobby .rankedScenarioVoteInstructions{margin:2px 0 5px;}
  body.ranked-lobby .rankedScenarioOption{padding:5px;gap:3px;}
  body.ranked-lobby .rankedScenarioMapPreview{height:clamp(150px,calc((100dvh - 475px)*.5 + 145px),240px);}
  body.ranked-lobby #playersList .playerRow{padding:5px 6px;}
  body.ranked-lobby #colorPicker .colorChip{height:21px;width:21px;}
}
@media (max-width:780px), (max-height:580px){
  /* On very small viewports keep every action reachable instead of cropping it. */
  body.ranked-lobby .layout>.panel{overflow-y:auto; overscroll-behavior:contain;}
  body.ranked-lobby #lobbyCard{height:auto;min-height:100%;overflow:visible;}
  body.ranked-lobby #roomBox{grid-template-columns:minmax(0,1fr);}
  body.ranked-lobby #roomBox>.roomShareControls,
  body.ranked-lobby #roomBox>.roomAccountControls{grid-column:1;}
  body.ranked-lobby .rankedScenarioOptions{grid-template-columns:1fr;}
  body.ranked-lobby .rankedScenarioMapPreview{height:160px;max-height:35vh;}
  body.ranked-lobby #playersList{grid-template-columns:repeat(2,minmax(0,1fr));}
  body.ranked-lobby #texturePackRow>.row{flex-wrap:wrap!important;}
}
@media (max-width:430px){
  body.ranked-lobby #playersList{grid-template-columns:1fr;}
  body.ranked-lobby .rankedRoomHeader{font-size:10px;letter-spacing:.5px;}
  body.ranked-lobby #roomBox>.roomTop{padding-right:165px;}
  body.ranked-lobby #lobbyRulesBtn{min-width:70px;padding:5px 7px;}
}

/* Legal links on both entry screens, with an in-app document viewer. */
.portalLegalLinks{
  position:fixed; z-index:4; left:max(16px,env(safe-area-inset-left));
  bottom:max(18px,env(safe-area-inset-bottom));
  display:flex; align-items:center; gap:11px; flex-wrap:wrap;
  max-width:calc(100% - 170px);
}
.portalLegalLink{
  border:0; background:rgba(10,22,31,.72); padding:6px 8px; border-radius:7px;
  color:#a9c4d5; font:600 12px var(--sans); cursor:pointer;
  text-decoration:underline; text-decoration-color:rgba(169,196,213,.45); text-underline-offset:3px;
}
.portalLegalLink:hover,.portalLegalLink:focus-visible{color:#ffe09b;background:#203341;outline:2px solid #d9a62e;outline-offset:2px;}
.portalLegalSeparator{color:#8195a2;}
.legalOverlay{z-index:1100; padding:clamp(8px,2vw,22px);}
.legalDialog{
  display:flex; flex-direction:column; width:min(920px,100%);
  height:min(84dvh,820px); min-height:280px; padding:0;
  overflow:hidden; border:1px solid #60798a;
}
.legalDialogHeader{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:14px 19px; border-bottom:1px solid #344c5c; flex:none;
}
.legalDialogHeader h2{margin:0;font-size:clamp(17px,2vw,23px);line-height:1.3;}
.legalCloseBtn{
  display:inline-flex; align-items:center; gap:7px; flex:none; border:1px solid #446073;
  border-radius:10px; background:#223744; color:#e8f1f7;
  padding:6px 11px; font-size:20px; cursor:pointer;
}
.legalCloseBtn span{font-size:12px;font-weight:700;}
.legalCloseBtn:hover,.legalCloseBtn:focus-visible{border-color:#e0ae3a;outline:2px solid #e0ae3a;}
.legalDocumentFrame{display:block; width:100%; flex:1 1 auto; min-height:0; border:0; background:#111c27;}
.legalDialogFooter{flex:none;padding:10px 19px 13px;border-top:1px solid #344c5c;font-size:12px;}
.legalDialogFooter a{color:#8fc6ed;}
@media(max-width:560px){
  .portalLegalLinks{left:max(8px,env(safe-area-inset-left));bottom:max(8px,env(safe-area-inset-bottom));gap:2px;max-width:calc(100% - 120px);}
  .portalLegalLink{font-size:10px;padding:5px;}
  .loginSupport img{height:28px;}
  .legalDialog{height:92dvh;}
  .legalDialogHeader{padding:10px 12px;}
  .legalDialogFooter{padding:8px 12px;}
}


/* v19: scale the resources' text/controls, not their dock or content width. */
.rightSidebar #resourcesCard{width:100% !important; min-width:0; max-width:100%;}
.rightSidebar #resourcesCard > .panelScaleContent{
  width:100%; max-width:100%; min-width:0; box-sizing:border-box;
}
.rightSidebarResourceDock{width:100%; min-width:0; max-width:100%; overflow-x:clip;}
.rightSidebarResourcesBody{width:100%; max-width:100%; min-width:0;box-sizing:border-box;}

/* v19: Mobile game tools remain visible at the TOP of the board. The Actions
   button still expands the bar for browsing every option. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px){
  body.in-game .hudTopLeft,
  body.in-game:not(.mobileActionsOpen) .hudTopLeft{
    display:block !important;
    position:absolute !important;
    top:calc(4px + var(--safe-top)) !important;
    left:calc(6px + var(--safe-left)) !important;
    right:calc(6px + var(--safe-right)) !important;
    bottom:auto !important;
    width:auto !important;
    max-width:none;
    max-height:57px;
    padding:5px 7px;
    overflow:hidden;
    z-index:32;
  }
  body.in-game .hudTopLeft .hudBarRow{
    display:flex;align-items:center;gap:6px;
    width:100%;min-width:0;
  }
  body.in-game .hudTopLeft .dragGrip{display:none;}
  body.in-game .hudTopLeft .hudConn{flex:0 0 auto;min-width:0;}
  body.in-game .hudTopLeft .hudBtns{
    display:flex;flex:1 1 auto;min-width:0;
    flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;
    scrollbar-width:thin;scrollbar-color:#547089 transparent;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-x;
  }
  body.in-game .hudTopLeft .hudBtns .btn{flex:0 0 auto;white-space:nowrap;}
  body.in-game .hudTopLeft .hudBarScaleHost{flex:0 0 auto;}
  body.in-game.mobileActionsOpen .hudTopLeft{
    max-height:min(56dvh,420px);
    overflow-y:auto;
    overflow-x:hidden;
  }
  body.in-game.mobileActionsOpen .hudTopLeft .hudBarRow{align-items:flex-start;flex-wrap:wrap;}
  body.in-game.mobileActionsOpen .hudTopLeft .hudBtns{
    flex:1 1 100%;order:2;flex-wrap:wrap;
    max-height:min(44dvh,320px);overflow-y:auto;overflow-x:hidden;
  }
  body.in-game .rightHud{top:calc(67px + var(--safe-top)) !important;}
}
@media (max-width:480px){
  body.in-game .hudTopLeft .hudConn .connText{display:none;}
  body.in-game .rightHud{top:calc(67px + var(--safe-top)) !important;}
}

/* v20: room closures return to the game-type selection with an explanation. */
.playModeNotice {
  max-width: 610px; margin: 12px auto; padding: 10px 14px;
  border: 1px solid rgba(245, 190, 79, .48); border-radius: 9px;
  background: rgba(61, 44, 20, .6); color: #f5daa6;
  font-size: .91rem; text-align: center;
}


/* v21: Mobile gameplay is a persistent vertical split (board above, fully
   scrollable game sidebar below). The handle is touch- and keyboard-resizable.
   Desktop's existing side-by-side dock/width control are unchanged. */
.mobileGameSplitter{display:none;}
@media (max-width:900px), (pointer:coarse) and (max-width:1180px){
  body.in-game .boardWrap{
    --mobile-sidebar-height:40dvh;
    --mobile-divider-height:28px;
    display:flex;flex-direction:column;min-height:0;overflow:hidden;
    padding-right:0 !important;
  }
  body.in-game #board{flex:1 1 0;min-height:0;width:100%;height:auto;min-width:0;touch-action:none;}
  body.in-game .mobileGameSplitter{
    display:flex;flex:0 0 var(--mobile-divider-height);height:var(--mobile-divider-height);
    position:relative;z-index:31;align-items:center;justify-content:center;
    cursor:row-resize;touch-action:none;user-select:none;-webkit-user-select:none;
    background:linear-gradient(180deg,#1d3445,#122432);
    border-top:1px solid #42657a;border-bottom:1px solid #42657a;
  }
  body.in-game .mobileGameSplitter::before{
    content:'';height:5px;width:72px;border-radius:999px;
    background:#9ab6cb;box-shadow:0 0 0 1px rgba(255,255,255,.13),0 1px 7px rgba(0,0,0,.5);
  }
  body.in-game .mobileGameSplitter::after{
    content:'Drag to resize';position:absolute;right:10px;top:50%;transform:translateY(-50%);
    color:#9fbacc;font-size:10px;pointer-events:none;
  }
  body.in-game .mobileGameSplitter:focus-visible{outline:3px solid #f5c463;outline-offset:-3px;}
  body.in-game .mobileGameSplitter.isDragging{background:#34566b;}
  body.in-game .rightSidebar,
  body.in-game.mobilePanelsOpen .rightSidebar{
    position:relative !important;left:auto !important;right:auto !important;
    top:auto !important;bottom:auto !important;
    display:flex;flex-direction:column;
    flex:0 0 var(--mobile-sidebar-height) !important;
    height:var(--mobile-sidebar-height) !important;
    max-height:none !important;width:100% !important;min-width:0;min-height:0;
    transform:none !important;visibility:visible !important;pointer-events:auto !important;
    transition:none !important;box-shadow:none;
    border-top:0;border-left:0;border-radius:0;overflow:hidden;
    background:#111d28;z-index:12;
  }
  body.in-game .rightSidebarInner{
    flex:1 1 auto;min-height:0;height:100%;max-height:100%;
    overflow-y:auto !important;overflow-x:hidden !important;
    overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
    padding:10px 12px calc(18px + var(--safe-bottom)) !important;
    touch-action:pan-y;
  }
  body.in-game .rightSidebarInner > #logCard,
  body.in-game .rightSidebarInner > #devCard{flex:0 0 auto !important;min-height:min-content;overflow:visible;}
  body.in-game .rightSidebar .logOverlay,
  body.in-game .rightSidebar #devCard.rightSidebarDocked{overflow:visible;}
  body.in-game .rightSidebar .logList,
  body.in-game .rightSidebar .devHand{max-height:none !important;overflow:visible !important;}
  body.in-game .mobilePanelTitle{
    display:flex;flex:0 0 auto;align-items:center;justify-content:space-between;
    min-height:32px;padding:5px 12px;border-bottom:1px solid var(--line);
    font-size:12px;letter-spacing:.03em;
  }
  body.in-game .mobilePanelTitle strong::after{
    content:'  ·  Scroll to see all controls';color:#9bb6cb;font-weight:500;font-size:11px;
  }
  body.in-game #mobilePanelsClose{display:none !important;}
  body.in-game .mobileGameControls{
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 6px + var(--safe-bottom)) !important;
  }
  body.in-game .hudBottomLeft{
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 60px + var(--safe-bottom)) !important;
    visibility:visible !important;pointer-events:auto !important;
  }
  body.in-game .yourRollBanner,
  body.in-game .extraTurnCenterBanner{
    top:calc((100% - var(--mobile-sidebar-height) - var(--mobile-divider-height)) / 2) !important;
  }
  body.in-game .pausedOverlay{
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height)) !important;
  }
  body.in-game .rightSidebarResize{display:none !important;}
}


/* v22: Mobile postgame header. The former three-column layout forced the
   winner heading, navigation and text-size controls to occupy the same row.
   Give each group a dedicated row while preserving the independently
   scrollable summary below it. These rules also cover touch tablets. */
@media (max-width: 800px), (pointer: coarse) and (max-width: 1180px) {
  .postgamePanel {
    width: 100%;
    height: 100dvh;
    min-height: 0;
  }
  .postgameTop {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "result result"
      "navigation navigation"
      "type-size hide";
    align-items: center;
    gap: 8px 10px;
    padding: calc(10px + env(safe-area-inset-top, 0px))
             calc(12px + env(safe-area-inset-right, 0px))
             10px calc(12px + env(safe-area-inset-left, 0px));
  }
  .postgameTopCenter {
    grid-area: result;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    justify-self: center;
    text-align: center;
  }
  .postgameWinnerLine {
    max-width: 100%;
    font-size: clamp(21px, 5vw, 30px);
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
    overflow: visible;
  }
  .postgameMetaLine {
    width: 100%;
    max-width: 100%;
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
  }
  .postgameTopLeft {
    grid-area: navigation;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 8px;
  }
  /* Flatten the tools wrapper so the scale controls and Hide Stats get their
     own grid cells, rather than pushing across the result heading. */
  .postgameTopRight { display: contents; }
  .postgameTopRight > .tabScaleControl {
    grid-area: type-size;
    justify-self: start;
    min-width: 0;
    max-width: 100%;
    gap: 4px;
  }
  .postgameTopRight > #pgHideBtn {
    grid-area: hide;
    justify-self: end;
  }
  .postgameTop .btn {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }
  .postgameTop .tabScaleLabel { min-width: 45px; }
  .postgameTabs {
    flex: 0 0 auto;
    gap: 6px;
    padding: 7px 10px;
    grid-template-columns: repeat(5, minmax(88px, 1fr));
  }
  .postgameBody {
    min-height: 0;
    padding: 10px calc(10px + env(safe-area-inset-right, 0px))
             calc(14px + env(safe-area-inset-bottom, 0px))
             calc(10px + env(safe-area-inset-left, 0px));
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* v23 — single-width, anchored game HUD, independent action buttons. */
body.in-game .hudTopLeft,
body.in-game .hudBottomLeft {
  position:absolute !important;
  left:0 !important;
  right:var(--right-sidebar-width,520px) !important;
  width:auto !important;
  max-width:none !important;
  border-radius:0 !important;
  background:rgba(9,18,28,.96) !important;
  backdrop-filter:blur(11px);
  border-left:0; border-right:0;
  box-sizing:border-box;
  transform:none !important;
  margin:0;
}
body.in-game .hudTopLeft {top:0 !important;bottom:auto !important;z-index:39 !important;padding:5px 58px 5px 10px;}
body.in-game .hudBottomLeft {top:auto !important;bottom:59px !important;z-index:29 !important;padding:6px 12px;}
body.in-game .hudTopLeft .dragGrip,
body.in-game .hudBottomLeft .dragGrip{display:none!important;}
body.in-game .hudBarRow{width:100%;max-width:100%;min-width:0;box-sizing:border-box;}
body.in-game .hudTopLeft .hudBtns{flex:1 1 auto;min-width:0;overflow-x:auto;scrollbar-width:thin;}
body.in-game .hudBottomLeft .hudBtns{width:100%;min-width:0;display:flex;flex-wrap:nowrap;overflow-x:auto;}
body.in-game .hudTopLeft .inGameOrb{
  display:grid!important;place-items:center;
  position:absolute!important;left:auto!important;right:7px!important;top:4px!important;bottom:auto!important;
  width:39px!important;height:39px!important;
  margin:0;flex:0 0 auto;z-index:50;
}
body.in-game .accountMenu{top:54px;right:calc(var(--right-sidebar-width,520px) + 8px);}
body.in-game .hudTopLeft .hudBarRow{padding-right:0;}
body.in-game .hudTopLeft .hudConn{flex:0 0 auto;}
body.in-game .hudBarScaleHost{flex:0 0 auto;}
body.in-game .hudBottomLeft .hudTurnInfo{display:none !important;}
body.in-game .rollDock{
  display:block;
  position:absolute!important;
  left:0!important;
  right:var(--right-sidebar-width,520px)!important;
  bottom:5px!important;
  top:auto!important;
  z-index:34!important;
  width:auto!important;
  pointer-events:none;
}
body.in-game .rollDock.hidden{display:none!important;}
body.in-game .rollDockInner{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 9px;background:transparent;border:0;box-shadow:none;backdrop-filter:none;}
body.in-game #rollDockBtn,body.in-game #endDockBtn{
  pointer-events:auto;min-width:112px;min-height:46px;padding:10px 14px;
  font-size:clamp(12px,1.2vw,17px);font-weight:900;border-radius:13px;
  box-shadow:0 6px 20px rgba(0,0,0,.65);white-space:nowrap;
}
body.in-game #endDockBtn{border-color:#9f7244;background:#302519;color:#ffdfac;}
body.in-game #endDockBtn:disabled,body.in-game #rollDockBtn:disabled{opacity:.5;}
body.in-game .countdownClock{
  background:rgba(8,16,27,.97)!important;
  border:1px solid #486579;
  padding:10px;
  min-width:190px;
}
body.in-game .clockActionInfo{
  margin-top:8px;padding-top:8px;
  border-top:1px solid rgba(161,190,212,.27);
  white-space:normal;overflow-wrap:anywhere;text-align:left;
}
body.in-game .clockActionInfo .turnInfo{font-weight:850;font-size:clamp(11px,1vw,15px);line-height:1.3;}
body.in-game .clockActionInfo .timerInfo{display:none!important;}
body.in-game .rightHud{top:59px!important;}
body.in-game #logHideBtn{display:none!important;}
body.gamePanelsCollapsed.in-game .boardWrap{padding-right:0!important;}
body.gamePanelsCollapsed.in-game .rightSidebar{display:none!important;}
body.gamePanelsCollapsed.in-game .hudTopLeft,
body.gamePanelsCollapsed.in-game .hudBottomLeft,
body.gamePanelsCollapsed.in-game .rollDock{right:0!important;}
body.gamePanelsCollapsed.in-game .rightHud{right:8px!important;}
body.gamePanelsCollapsed.in-game .accountMenu{right:8px!important;}
body.gamePanelsCollapsed.in-game .inGameOrb{right:8px!important;}
.mobilePanelTabs{display:none;}
.settingsTemplateEditor{display:flex;flex-direction:column;gap:11px;max-height:65dvh;overflow-y:auto;padding:4px;}
.settingsTemplateEditor .label{display:flex;flex-direction:column;gap:6px;}
.settingsTemplateEditor .smallNote{margin:0;line-height:1.5;}
.settingsTemplateFields{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:7px;}
.settingsTemplateField{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto auto;align-items:center;gap:4px 10px;padding:10px 11px;border:1px solid #304759;border-radius:10px;background:#0d1b28;color:#eaf3f9;cursor:pointer;}
.settingsTemplateField input{grid-row:1/3;width:19px;height:19px;accent-color:#e6b64b;}
.settingsTemplateField span{font-weight:800;font-size:13px;}
.settingsTemplateField small{min-width:0;overflow-wrap:anywhere;color:#afc2d0;font-size:11px;}
.settingsTemplateSelectAll{display:flex;align-items:center;gap:10px;border-top:1px solid #3b4e5c;padding:13px 5px 4px;font-size:13px;font-weight:850;cursor:pointer;}
.settingsTemplateSelectAll input{width:20px;height:20px;accent-color:#e6b64b;}
.settingsTemplateSaved{display:grid;gap:6px;}
.settingsTemplateSavedRow{display:flex;align-items:center;gap:9px;flex-wrap:wrap;padding:9px;border:1px solid #324b5c;border-radius:10px;}
.settingsTemplateSavedRow span{flex:1;min-width:120px;font-weight:750;overflow-wrap:anywhere;}
#settingsAutosaveStatus{display:inline-flex;align-items:center;}

@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.in-game .boardWrap{--mobile-action-height:113px;}
  body.in-game .hudTopLeft,
  body.in-game:not(.mobileActionsOpen) .hudTopLeft{
    top:0!important;bottom:auto!important;left:0!important;right:0!important;
    height:47px!important;min-height:47px!important;max-height:47px!important;
    padding:4px 52px 4px 6px!important;overflow:visible!important;
  }
  body.in-game .hudTopLeft .hudBtns{overflow-x:auto;overflow-y:hidden;flex-wrap:nowrap!important;}
  body.in-game .hudTopLeft .hudBtns .btn{min-height:37px;min-width:0;font-size:clamp(10px,2.7vw,13px);padding:6px 10px;}
  body.in-game .hudTopLeft .inGameOrb{
    top:4px!important;right:5px!important;left:auto!important;bottom:auto!important;
    width:38px!important;height:38px!important;
  }
  body.in-game .accountMenu{right:5px!important;top:49px!important;}
  body.in-game .hudTopLeft .toolScaleControl,
  body.in-game .hudBottomLeft .toolScaleControl,
  body.in-game .rightHud .toolScaleControl,
  body.in-game .rightSidebar .toolScaleControl{display:none!important;}
  body.in-game .hudBottomLeft{
    display:block!important;position:absolute!important;
    top:auto!important;left:0!important;right:0!important;
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 52px + var(--safe-bottom))!important;
    width:100%!important;max-width:none!important;
    padding:5px 7px!important;overflow:visible!important;
    background:rgba(8,17,28,.98)!important;z-index:35!important;
  }
  body.in-game .hudBottomLeft .hudBarRow{display:block!important;width:100%;zoom:1!important;overflow:visible!important;}
  body.in-game .hudBottomLeft .hudBtns{
    width:100%!important;display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(2, minmax(38px,auto));
    gap:5px!important;white-space:normal;overflow:visible!important;
  }
  body.in-game .hudBottomLeft .hudBtns .btn{
    width:100%;min-width:0!important;min-height:38px!important;
    padding:5px 3px!important;font-size:clamp(10px,2.65vw,13px)!important;
    white-space:normal!important;line-height:1.15;overflow-wrap:anywhere;
  }
  body.in-game .hudBottomLeft .hudBtns #buyDevBtn{grid-column:1;grid-row:1;}
  body.in-game .hudBottomLeft .hudBtns #bankTradeBtn{grid-column:2;grid-row:1;}
  body.in-game .hudBottomLeft .hudBtns #playerTradeBtn{grid-column:3;grid-row:1;}
  body.in-game .hudBottomLeft .hudBtns #backTurnBtn{grid-column:1;grid-row:2;}
  body.in-game .hudBottomLeft .hudBtns #pauseBtn{grid-column:2;grid-row:2;}
  body.in-game .hudBottomLeft .hudBtns #playBtn{grid-column:3;grid-row:2;}
  body.in-game .hudBottomLeft .hudBtns :is(#buildRoadBtn,#buildShipBtn,#moveShipBtn,#buildSettlementBtn,#buildCityBtn){display:none!important;}
  body.in-game .rollDock{
    display:block;position:absolute!important;
    top:auto!important;left:0!important;right:0!important;
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 5px + var(--safe-bottom))!important;
    width:100%!important;z-index:36!important;
  }
  body.in-game .rollDockInner{padding:0 7px;}
  body.in-game #rollDockBtn,body.in-game #endDockBtn{min-width:100px;min-height:43px;font-size:13px;padding:8px 12px;}
  body.in-game .mobileGameControls{display:none!important;}
  body.in-game .rightHud{top:53px!important;right:5px!important;}
  body.in-game .countdownClock{min-width:0;width:min(195px,54vw);max-width:54vw;padding:6px 8px!important;}
  body.in-game .countdownClock .clockTime{font-size:clamp(15px,4vw,21px);}
  body.in-game .clockActionInfo{margin-top:4px;padding-top:4px;max-height:70px;overflow-y:auto;}
  body.in-game .clockActionInfo .turnInfo{font-size:clamp(10px,2.65vw,12px);}
  body.in-game .rightSidebar{--mobile-fixed-resource-height:auto;}
  body.in-game .rightSidebarResourceDock{
    order:0;flex:0 0 auto!important;
    padding:5px 9px!important;margin:0!important;
    max-height:min(25dvh,190px)!important;overflow-y:auto!important;overflow-x:hidden;
    background:#10202d;border-top:0;border-bottom:1px solid #3c596f;
  }
  body.in-game .rightSidebarResourcesBody{zoom:1!important;display:flex;flex-direction:column;gap:3px!important;}
  body.in-game .rightSidebarBankRow,
  body.in-game .rightSidebarPlayerRow{display:flex;flex-wrap:wrap;align-items:center;gap:5px 10px;min-width:0;}
  body.in-game .rightSidebarBankTitle{font-size:10px;flex:0 0 auto;}
  body.in-game .rightSidebarResStrip{flex:1 1 195px;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px!important;}
  body.in-game .rightSidebarResStrip .resCell{gap:2px;justify-content:center;}
  body.in-game .rightSidebarResStrip .resIcon{width:16px;height:16px;}
  body.in-game .rightSidebarResStrip .resVal{font-size:11px;}
  body.in-game .rightSidebarMeta{font-size:10px;gap:5px 9px;flex:1 1 100%;}
  body.in-game .rightSidebarMetaStrong{font-size:11px;}
  body.in-game .rightSidebarPlayerRow .rightSidebarPieceStrip{display:none;}
  body.in-game .rightSidebarResourceDock .rightSidebarSeparator,
  body.in-game .rightSidebarResourceDock .rightSidebarNote{display:none;}
  body.in-game .mobilePanelTitle{display:none!important;}
  body.in-game .mobilePanelTabs{
    display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
    order:1;gap:4px;padding:5px 8px 6px;flex:0 0 auto;
    border-bottom:1px solid #344b5d;background:#111e2b;
  }
  body.in-game .mobilePanelTab{
    background:#142b3d;border:1px solid #39556a;border-radius:8px;
    color:#cee1ec;font-size:clamp(11px,2.8vw,14px);font-weight:800;
    min-height:37px;padding:5px 2px;touch-action:manipulation;
  }
  body.in-game .mobilePanelTab.active{color:#fff;background:#275075;border-color:#e0ae3a;}
  body.in-game .rightSidebarInner{order:2;padding:7px 9px calc(10px + var(--safe-bottom))!important;overflow-y:auto!important;}
  body.in-game .rightSidebarInner > :is(#resourcesCard,#logCard,#devCard){display:none!important;}
  body.in-game .rightSidebar[data-active-panel="resources"] #resourcesCard{display:flex!important;}
  body.in-game .rightSidebar[data-active-panel="log"] #logCard{display:flex!important;}
  body.in-game .rightSidebar[data-active-panel="dev"] #devCard{display:flex!important;}
  body.in-game .rightSidebar #resourcesCard .panelScaleContent,
  body.in-game .rightSidebar #logCard .logList,
  body.in-game .rightSidebar #devCard .panelScaleContent{zoom:1!important;}
  body.in-game .rightSidebar #logCard .logList{min-height:100px;}
  body.gamePanelsCollapsed.in-game .rightSidebar,
  body.gamePanelsCollapsed.in-game .mobileGameSplitter{display:none!important;height:0!important;flex-basis:0!important;}
  body.gamePanelsCollapsed.in-game .boardWrap{--mobile-sidebar-height:0px!important;--mobile-divider-height:0px!important;}
  body.gamePanelsCollapsed.in-game #board{flex:1 1 auto!important;}
}
@media(max-height:550px) and (max-width:900px){
  body.in-game .hudTopLeft{height:41px!important;min-height:41px!important;max-height:41px!important;}
  body.in-game .hudBottomLeft .hudBtns{grid-template-rows:repeat(2,34px);gap:3px!important;}
  body.in-game .hudBottomLeft .hudBtns .btn{min-height:34px!important;font-size:10px!important;}
  body.in-game .hudBottomLeft{bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 46px + var(--safe-bottom))!important;}
  body.in-game .rollDock{bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 3px + var(--safe-bottom))!important;}
  body.in-game #rollDockBtn,body.in-game #endDockBtn{min-height:39px;}
  body.in-game .rightHud{top:44px!important;}
}

/* v23 refinement: true viewport-width top/bottom bars on desktop. The quick
   turn controls sit above the lower bar, attached to the board's corners. */
@media (min-width:901px) and (pointer:fine), (min-width:1181px){
  body.in-game .hudTopLeft,body.in-game .hudBottomLeft{right:0!important;}
  body.in-game .hudTopLeft{padding-right:58px!important;}
  body.in-game .hudTopLeft .inGameOrb{right:7px!important;}
  body.in-game .hudBottomLeft{bottom:0!important;}
  body.in-game .rollDock{right:var(--right-sidebar-width,520px)!important;bottom:54px!important;}
  body.in-game .rightSidebarInner{padding-top:54px;padding-bottom:59px;}
  body.in-game .rightHud{right:calc(var(--right-sidebar-width,520px) + 8px)!important;}
  body.in-game .accountMenu{right:8px!important;top:50px;}
}
@media (max-width:900px), (pointer:coarse) and (max-width:1180px){
  body.in-game .hudTopLeft .hudBarRow{zoom:1!important;}
  body.in-game .countdownClock .panelScaleContent{zoom:1!important;}
  body.in-game .hudTopLeft .hudBtns #logBtn{order:-2;}
  body.in-game .hudBottomLeft{
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + var(--safe-bottom))!important;
  }
  body.in-game .rollDock{
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 93px + var(--safe-bottom))!important;
  }
  body.in-game .rightSidebarInner{padding-bottom:calc(12px + var(--safe-bottom))!important;}
  body.in-game .hudBottomLeft .extraTurnBanner{bottom:calc(100% + 48px)!important;}
  .postgamePanel .tabScaleControl{display:none!important;}
}
@media (max-height:550px) and (max-width:900px){
  body.in-game .rollDock{
    bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + 76px + var(--safe-bottom))!important;
  }
  body.in-game .hudBottomLeft{bottom:calc(var(--mobile-sidebar-height) + var(--mobile-divider-height) + var(--safe-bottom))!important;}
}


/* v24 — Desktop HUD stops precisely at the game-panels boundary. */
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game:not(.gamePanelsCollapsed) .hudTopLeft,
  body.in-game:not(.gamePanelsCollapsed) .hudBottomLeft {
    right:var(--right-sidebar-width,520px)!important;
  }
  body.in-game:not(.gamePanelsCollapsed) .hudTopLeft .inGameOrb {
    right:7px!important;
  }
  body.in-game:not(.gamePanelsCollapsed) .accountMenu {
    right:calc(var(--right-sidebar-width,520px) + 8px)!important;
  }
  body.in-game.gamePanelsCollapsed .hudTopLeft,
  body.in-game.gamePanelsCollapsed .hudBottomLeft {right:0!important;}
  body.in-game.gamePanelsCollapsed .accountMenu {right:8px!important;}
}
/* The canvas and its surrounding board always have the same background.
   In particular the PAUSED dimmer must extend into space vacated by panels. */
body.in-game .boardWrap {background:#5f6f7c;}
body.in-game.gamePanelsCollapsed .pausedOverlay {right:0!important;}
body.in-game.gamePanelsCollapsed .yourRollBanner,
body.in-game.gamePanelsCollapsed .extraTurnCenterBanner {left:50%!important;}
/* The timer itself is draggable, without a separate grab icon. */
.mobilePinnedResources{display:none;}
/* Phones/touch tablets: real flex rows for the controls and resource strip.
   They take up space, so the Android navigation area cannot cover buttons. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.in-game .boardWrap {
    --mobile-resource-height:auto;
    display:flex!important;flex-direction:column!important;
    background:#5f6f7c;
  }
  body.in-game #board {order:0;flex:1 1 0!important;min-height:0!important;}
  body.in-game .rollDock {
    order:1;position:relative!important;flex:0 0 auto!important;
    left:auto!important;right:auto!important;top:auto!important;bottom:auto!important;
    width:100%!important;min-height:42px;
    padding:2px 0 3px!important;margin:0!important;
    background:#12202c;
  }
  body.in-game .hudBottomLeft {
    order:2;position:relative!important;flex:0 0 auto!important;
    left:auto!important;right:auto!important;top:auto!important;bottom:auto!important;
    width:100%!important;max-width:100%!important;
    padding:5px 7px calc(5px + var(--safe-bottom))!important;
    margin:0!important;
    box-sizing:border-box;
  }
  body.in-game .mobilePinnedResources {
    order:3;display:block;flex:0 0 auto;min-height:0;max-height:min(26dvh,164px);
    overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;
    width:100%;background:#10202d;
    border-top:1px solid #3c596f;border-bottom:1px solid #3c596f;
  }
  body.in-game .mobilePinnedResources .rightSidebarResourceDock {
    display:block!important;border:0!important;margin:0!important;padding:6px 9px!important;
    max-height:none!important;overflow:visible!important;
  }
  body.in-game .mobileGameSplitter{order:4;}
  body.in-game .rightSidebar{order:5;}
  body.gamePanelsCollapsed.in-game .mobilePinnedResources {display:block!important;}
  body.gamePanelsCollapsed.in-game .mobileGameSplitter,
  body.gamePanelsCollapsed.in-game .rightSidebar {display:none!important;}
  /* The board stays interactive when lower tabs are collapsed; resources
     never follow them out of the layout. */
  body.gamePanelsCollapsed.in-game #board {flex:1 1 0!important;}
  body.in-game .rightSidebarInner {padding-bottom:12px!important;}
  body.in-game .hudBottomLeft .hudBtns {grid-template-rows:repeat(2,minmax(38px,auto))!important;}
  body.in-game .rightHud {z-index:38;}
}
@media (max-height:550px) and (max-width:900px) {
  body.in-game .hudBottomLeft .hudBtns {grid-template-rows:repeat(2,34px)!important;}
  body.in-game .rollDock {min-height:38px;}
}
/* With bars no longer over the desktop sidebar, allow its cards to use
   its full height instead of reserving the old 54px/59px HUD gutters. */
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game .rightSidebarInner {padding-top:10px!important;padding-bottom:10px!important;}
}
/* Android Chrome's dynamic viewport can be shorter than the legacy 100vh
   minimum. Never let that minimum push the bottom action row under system UI. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  html:has(body.in-game), body.in-game {height:100dvh!important;min-height:0!important;}
  body.in-game #app {height:100dvh!important;min-height:0!important;max-height:100dvh!important;}
}

/* v25: side-by-side ranked and cumulative unranked ratings */
.playerProfileRatings{display:flex;align-items:center;justify-content:flex-end;gap:14px;flex-wrap:wrap}
.playerProfileRatings .playerProfileRating{min-width:90px;justify-items:center;gap:3px}
.playerProfileRatings .playerProfileRating:last-child{color:#85d2c1}
@media(max-width:650px){.playerProfileHero{grid-template-columns:auto 1fr}.playerProfileRatings{grid-column:1/-1;justify-content:space-around;width:100%;gap:12px}.playerProfileRatings .playerProfileRating{grid-column:auto}}

/* v26 — Turn buttons track the ACTUAL action-bar height, including custom
   scale settings. Bar scaling never consumes the orb or scale-controller slots. */
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game .rollDock {
    bottom:calc(var(--hud-bottom-bar-height, 54px) + 8px)!important;
  }
  body.in-game .hudBottomLeft {
    bottom:0!important;
  }
  body.in-game .hudTopLeft {
    overflow:hidden!important;
    padding-right:56px!important;
  }
  body.in-game .hudTopLeft .hudBarRow {
    zoom:1!important;
    overflow:visible!important;
    width:100%!important; min-width:0!important;
    max-width:100%!important;
  }
  body.in-game .hudTopLeft .hudBtns {
    flex:1 1 0!important;
    min-width:0!important;
    max-width:100%!important;
    zoom:var(--tool-ui-scale, 1);
    overflow-x:auto!important;
    overflow-y:hidden!important;
    scrollbar-width:thin;
  }
  body.in-game .hudTopLeft .hudBtns .btn{flex:0 0 auto;white-space:nowrap;}
  body.in-game .hudTopLeft .hudBarScaleHost {flex:0 0 auto!important;z-index:2;}
  body.in-game .hudTopLeft .inGameOrb {right:6px!important;}
}
/* Clock surface is the drag handle on both mobile and desktop. The game
   computes bounds from the tools bar and turn-button dock at drag time. */
body.in-game .countdownClock {cursor:grab;touch-action:none;}
body.in-game .countdownClock:active {cursor:grabbing;}
body.in-game .countdownClock button {cursor:pointer;touch-action:manipulation;}
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.in-game .rightHud {max-width:calc(100vw - 12px);}
  body.in-game .countdownClock {touch-action:none;}
}

/* Short landscape phones: prioritize a usable board and movable timer. The
   lower panels retain their scrollable content but receive less initial room. */
@media (max-width:900px) and (max-height:550px) and (orientation:landscape) {
  body.in-game .boardWrap {--mobile-divider-height:20px;}
  body.in-game .mobilePinnedResources {max-height:44px!important;}
  body.in-game .mobilePinnedResources .rightSidebarResourceDock {padding:3px 7px!important;}
  body.in-game .hudBottomLeft {padding:3px 6px!important;}
  body.in-game .hudBottomLeft .hudBtns {grid-template-rows:repeat(2,31px)!important;gap:3px!important;}
  body.in-game .hudBottomLeft .hudBtns .btn {min-height:31px!important;padding:2px 3px!important;}
  body.in-game .rollDock {min-height:35px!important;padding:1px 0!important;}
  body.in-game #rollDockBtn,body.in-game #endDockBtn {min-height:33px!important;padding:5px 10px!important;}
  body.in-game .countdownClock {width:min(170px,40vw);max-width:40vw;padding:3px 7px!important;}
  body.in-game .countdownClock .clockTopRow {margin-bottom:0;}
  body.in-game .countdownClock .clockMeta {font-size:9px;line-height:1.1;}
  body.in-game .clockActionInfo {margin-top:2px!important;padding-top:2px!important;max-height:30px!important;}
  body.in-game .clockActionInfo .turnInfo {font-size:10px;line-height:1.1;}
}

/* v27 — Mobile timer: no dead header row, no corner-only drag affordance.
   On desktop the row continues to hold its scale controls; on mobile scale
   controls are unnecessary and the clock time starts at the panel's top. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.in-game .countdownClock .clockTopRow {display:none!important;}
  body.in-game .countdownClock .panelScaleContent {margin-top:0!important;padding-top:0!important;}
  body.in-game .countdownClock {cursor:grab;touch-action:none!important;}
  body.in-game .countdownClock .clockTime,
  body.in-game .countdownClock .clockMeta,
  body.in-game .countdownClock .clockActionInfo {touch-action:none!important;}
}

/* v28 — Keep the profile orb entirely inside its own top HUD. Its diameter
   follows the measured bar height, not a fixed pixel size or button scale. */
body.in-game .hudTopLeft {
  --hud-orb-size:clamp(25px,calc(var(--hud-top-bar-height,43px) - 8px),52px);
  padding-right:calc(var(--hud-orb-size) + 17px)!important;
}
body.in-game .hudTopLeft .inGameOrb {
  position:absolute!important;
  left:auto!important;right:7px!important;
  top:50%!important;bottom:auto!important;
  width:var(--hud-orb-size)!important;
  height:var(--hud-orb-size)!important;
  min-width:0!important;min-height:0!important;
  max-width:100%!important;max-height:100%!important;
  padding:0!important;margin:0!important;
  transform:translateY(-50%)!important;
  font-size:calc(var(--hud-orb-size) * .43)!important;
  line-height:1!important;
  display:grid!important;place-items:center;
  box-sizing:border-box;
}
/* Development-card controls must wrap *within* the resizable right panel.
   The deck count gets a second row; the scaler owns the right-hand column. */
body.in-game .rightSidebar #devCard .devHeaderRow {
  display:grid!important;
  grid-template-columns:minmax(0,1fr) max-content;
  grid-template-rows:auto auto;
  align-items:center;
  column-gap:6px;row-gap:2px;
  width:100%;min-width:0;max-width:100%;
  box-sizing:border-box;
}
body.in-game .rightSidebar #devCard .devHeaderRow > h2 {
  grid-column:1;grid-row:1;
  min-width:0;max-width:100%;
  overflow-wrap:break-word;
  font-size:clamp(11px,1vw,14px);
  line-height:1.15;
}
body.in-game .rightSidebar #devCard .devHeaderRight {
  grid-column:1;grid-row:2;
  justify-self:start;align-self:start;
  margin-left:0;min-width:0;max-width:100%;
  flex-wrap:wrap;
}
body.in-game .rightSidebar #devCard .devHeaderRow > .panelScaleHost {
  grid-column:2;grid-row:1 / span 2;
  justify-self:end;align-self:center;
  margin:0!important;min-width:0;max-width:100%;
  flex:0 0 auto;
}
body.in-game .rightSidebar #devCard .panelScaleHost .toolScaleControl {
  box-sizing:border-box;min-width:0;
  gap:3px;padding:2px 3px;
}
body.in-game .rightSidebar #devCard .panelScaleHost .tabScaleBtn {
  flex:0 0 22px;width:22px;height:22px;
}
body.in-game .rightSidebar #devCard .panelScaleHost .tabScaleLabel {
  min-width:38px;font-size:10px;
}


/* v29 — Resource counts overlay larger art in high-contrast, round badges.
   Applies to both the desktop Resources panel and the mobile pinned strip. */
body.in-game .resCell {
  position:relative;
  display:grid;
  place-items:center;
  justify-content:center;
  width:100%;
  min-width:0;
  min-height:36px;
  padding:3px 0;
  isolation:isolate;
}
body.in-game .resCell .resIcon,
body.in-game .rightSidebarResStrip .resIcon,
body.in-game .resourcesOverlay .resIcon {
  display:block;
  grid-area:1 / 1;
  width:clamp(38px, 3.6vw, 48px);
  height:clamp(38px, 3.6vw, 48px);
  min-width:0;
  max-width:100%;
  object-fit:contain;
  filter:drop-shadow(0 2px 3px rgba(0,0,0,.65));
}
body.in-game .resCell .resVal,
body.in-game .rightSidebarResStrip .resVal,
body.in-game .resourcesOverlay .resVal {
  grid-area:1 / 1;
  position:relative;
  z-index:2;
  display:grid;
  place-items:center;
  width:max-content;
  min-width:21px;
  min-height:21px;
  padding:1px 3px;
  box-sizing:border-box;
  margin:0;
  border-radius:999px;
  border:1px solid rgba(218,237,255,.85);
  background:rgba(6,15,25,.92);
  color:#fff;
  font-family:var(--mono);
  font-size:clamp(11px, 1vw, 14px);
  font-weight:900;
  font-variant-numeric:tabular-nums;
  line-height:1;
  text-align:center;
  text-shadow:0 1px 2px #000;
  box-shadow:0 1px 5px rgba(0,0,0,.85);
  pointer-events:none;
}
body.in-game .rightSidebarResStrip {gap:4px; min-width:0;}
/* Compact mobile strips retain five icons per line without unreadable counts. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.in-game .rightSidebarResStrip .resIcon {width:clamp(38px, 10vw, 44px);height:clamp(38px, 10vw, 44px);}
  body.in-game .rightSidebarResStrip .resVal {font-size:clamp(11px, 2.7vw, 13px);min-width:20px;min-height:20px;}
  body.in-game .rightSidebarResourcesBody {gap:5px!important;}
  body.in-game .rightSidebarResourceDock .resCell{min-height:31px;padding:1px 0;}
}

/* Desktop: hiding the right panels releases a draggable Resources window.
   It contains the existing, live player summaries and bank/hand resources. */
.floatingResourcesPanel {display:none;}
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game.gamePanelsCollapsed .floatingResourcesPanel:not(.hidden) {
    position:absolute;
    display:flex;
    flex-direction:column;
    top:clamp(172px, 25vh, 275px);
    right:12px;
    width:clamp(295px, 27vw, 420px);
    max-width:calc(100vw - 24px);
    max-height:min(62dvh, 550px);
    min-height:0;
    box-sizing:border-box;
    z-index:37;
    overflow:hidden;
    border:1px solid #486b82;
    border-radius:15px;
    background:rgba(10,20,31,.96);
    box-shadow:0 15px 42px rgba(0,0,0,.55);
  }
  .floatingResourcesHeader {
    flex:0 0 auto;
    padding:9px 13px;
    font-weight:900;
    font-size:14px;
    color:#f2f7fb;
    border-bottom:1px solid #39556a;
    background:#182c3e;
    cursor:grab;
    user-select:none;
    touch-action:none;
  }
  .floatingResourcesHeader:active {cursor:grabbing;}
  .floatingResourcesContent {
    display:flex;flex-direction:column;
    min-height:0;
    overflow-y:auto;overflow-x:hidden;
    padding:10px;
    gap:12px;
    overscroll-behavior:contain;
    scrollbar-width:thin;
  }
  .floatingResourcesPanel #resourcesCard {
    position:relative!important;
    inset:auto!important;
    display:block;
    flex:none;
    padding:0!important;
    margin:0;
    width:100%!important;
    max-width:100%!important;
    min-width:0;
    border:0!important;
    background:transparent!important;
    box-shadow:none!important;
    overflow:visible;
  }
  .floatingResourcesPanel #resourcesCard .resourcesHeaderRow {display:none;}
  .floatingResourcesPanel #resourcesCard > h2{display:none;}
  .floatingResourcesPanel #resourcesCard .resourcesBox{display:flex;flex-direction:column;gap:6px;}
  .floatingResourcesPanel .rightSidebarResourceDock {
    flex:none;
    width:100%;
    max-width:100%;
    padding:9px 0 0;
    overflow:visible;
  }
  .floatingResourcesPanel .rightSidebarResourcesBody {zoom:1!important;gap:7px;}
  .floatingResourcesPanel .rightSidebarResStrip {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:5px;}
  .floatingResourcesPanel .rightSidebarBankRow,
  .floatingResourcesPanel .rightSidebarPlayerRow {display:flex;flex-direction:column;gap:6px;align-items:stretch;}
  .floatingResourcesPanel .rightSidebarMeta {font-size:10px;gap:4px 8px;}
  .floatingResourcesPanel .rightSidebarMetaStrong {font-size:11px;}
  .floatingResourcesPanel .rightSidebarPieceStrip,
  .floatingResourcesPanel .rightSidebarNote {display:none;}
}

/* The bottom action-bar scale also sizes the freestanding dice/turn buttons. */
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game .rollDock #rollDockBtn,
  body.in-game .rollDock #endDockBtn {
    min-width:calc(112px * var(--turn-button-scale, 1))!important;
    min-height:calc(46px * var(--turn-button-scale, 1))!important;
    padding:calc(10px * var(--turn-button-scale, 1)) calc(14px * var(--turn-button-scale, 1))!important;
    font-size:calc(clamp(12px, 1.2vw, 17px) * var(--turn-button-scale, 1))!important;
    border-radius:calc(13px * var(--turn-button-scale, 1))!important;
    line-height:1.1;
    transition:font-size .12s ease,min-height .12s ease;
  }
}


/* v30 — Friends: username requests and contextual in-lobby invitations. */
.friendsCard{display:flex;flex-direction:column;gap:12px;max-height:min(90dvh,700px);overflow:hidden;}
.friendRequestForm{display:flex;flex-direction:column;gap:7px;flex:none;}
.friendRequestForm .label{margin:0;}
.friendRequestFormRow{display:flex;align-items:center;gap:8px;min-width:0;}
.friendRequestFormRow .input{flex:1 1 auto;min-width:0;}
.friendRequestFormRow .btn{flex:0 0 auto;min-height:42px;}
.friendRequestStatus{font-size:12px;font-weight:750;color:#b9e6c6;}
.friendsCard .friendsList{flex:1 1 auto;min-height:0;max-height:none;overscroll-behavior:contain;}
.friendRowWithActions{display:flex;align-items:center;gap:8px;min-width:0;}
.friendRowWithActions .friendProfileButton{width:auto;display:flex;align-items:center;justify-content:space-between;gap:10px;flex:1 1 auto;min-width:0;border:0;background:none;color:inherit;cursor:pointer;padding:2px;text-align:left;}
.friendRowWithActions .friendProfileButton span:first-child{display:flex;flex-direction:column;min-width:0;gap:3px;}
.friendRowWithActions .friendProfileButton strong,.friendRowWithActions .friendProfileButton small{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.friendRowWithActions .friendInviteBtn{flex:0 0 auto;padding:9px 10px;font-size:12px;white-space:nowrap;}
.lobbyInviteToast{max-width:min(365px,calc(100vw - 24px));}
.lobbyInviteActions{display:flex;gap:8px;margin-top:10px;}
.lobbyInviteActions .btn{flex:1;min-width:0;}

/* v30 — The mobile unranked lobby is a scrollable full-height panel, not a
   half-height panel above a dead canvas. The map is an optional bottom drawer. */
.mobileLobbyMapToggle,.mobileLobbyMapClose{display:none;}
@media (max-width:980px), (pointer:coarse) {
  html,body,#app{height:100dvh;min-height:0;max-height:100dvh;}
  body:not(.in-game) .layout{display:block;height:100%;min-height:0;padding:8px;overflow:hidden;}
  body:not(.in-game) .layout>.panel{display:flex;height:100%;max-height:none;min-height:0;padding-right:0;padding-bottom:calc(10px + var(--safe-bottom));overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;}
  body:not(.in-game) .layout>.panel>#lobbyCard{flex:0 0 auto;}
  body:not(.in-game) .layout>.boardWrap{display:none!important;}
  body.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby) .mobileLobbyMapToggle{
    display:flex;position:fixed;z-index:58;right:calc(14px + var(--safe-right));bottom:calc(16px + var(--safe-bottom));
    align-items:center;justify-content:center;gap:6px;padding:12px 15px;min-height:50px;
    border:1px solid #d4a434;border-radius:999px;background:#142a3c;color:#f2e5b9;
    font-size:13px;font-weight:850;box-shadow:0 7px 28px rgba(0,0,0,.65);touch-action:manipulation;
  }
  body.mobileLobbyMapOpen:not(.in-game):not(.ranked-lobby) .layout>.boardWrap{
    display:flex!important;position:fixed;z-index:59;left:calc(6px + var(--safe-left));right:calc(6px + var(--safe-right));
    bottom:calc(8px + var(--safe-bottom));top:auto;width:auto;height:min(56dvh,490px);min-height:220px;
    border:1px solid #51728b;border-radius:17px;overflow:hidden;
    background:#5f6f7c;box-shadow:0 -16px 50px rgba(0,0,0,.7);
  }
  body.mobileLobbyMapOpen:not(.in-game) .mobileLobbyMapClose{
    display:block;position:absolute;z-index:5;right:10px;top:10px;min-height:42px;
    padding:8px 13px;border:1px solid #6b8fac;border-radius:11px;
    color:#fff;background:rgba(9,20,33,.95);font-weight:800;touch-action:manipulation;
  }
  body.mobileLobbyMapOpen:not(.in-game) .mobileLobbyMapToggle{display:none;}
  body.mobileLobbyMapOpen:not(.in-game) .layout>.boardWrap #board{display:block;flex:1 1 auto;min-height:0;max-width:100%;}
  .friendsCard{width:min(460px,calc(100vw - 16px));padding:22px 14px;}
  .friendRowWithActions{flex-wrap:wrap;}
  .friendRowWithActions .friendProfileButton{min-width:min(100%,160px);}
}

/* The ranked ballot is an actual 420x280 canvas. Its CSS aspect ratio must
   match that intrinsic size, even in short/tall phones and narrow vote cards. */
body.ranked-lobby .rankedScenarioMapPreview{
  display:block;width:100%;height:auto!important;aspect-ratio:3 / 2!important;
  max-height:none!important;min-height:0!important;object-fit:contain;
}
body.ranked-lobby .rankedScenarioOption{min-width:0;overflow:hidden;}
body.ranked-lobby .rankedScenarioOptions{align-items:start;}
body.ranked-lobby .rankedScenarioOptionInfo{min-width:0;}
body.ranked-lobby .layout>.boardWrap{display:none!important;}

/* Turn indicators share the Roll Dice row; none float over the dice button. */
body.in-game .rollDockInner{justify-content:flex-start;}
body.in-game .rollDockTurnBadges{display:flex;flex:0 1 auto;align-items:center;justify-content:flex-start;min-width:0;gap:8px;pointer-events:none;}
body.in-game .rollDockTurnBadges .extraTurnBanner,
body.in-game .rollDockTurnBadges .placementTurnBanner{
  display:inline-flex;position:static!important;inset:auto!important;transform:none!important;
  align-items:center;gap:5px;max-width:100%;min-width:0;
  line-height:1.05;font-size:clamp(11px,2.5vw,16px);letter-spacing:.15px;
  white-space:nowrap;overflow:visible;pointer-events:none;
}
body.in-game .rollDockTurnBadges .hidden{display:none!important;}
body.in-game .rollDockTurnBadges .extraTurnIcon{font-size:clamp(18px,4vw,26px);}
body.in-game #endDockBtn{margin-left:auto;}
/* Prevent the old forced second grid row from leaving blank space when
   Back/Pause/Play are hidden, especially for ranked matches. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px){
  body.in-game .hudBottomLeft .hudBtns:not(:has(#backTurnBtn:not(.hidden),#pauseBtn:not(.hidden),#playBtn:not(.hidden))){
    grid-template-rows:minmax(38px,auto)!important;
  }
  body.in-game .hudBottomLeft .hudBtns:not(:has(#backTurnBtn:not(.hidden),#pauseBtn:not(.hidden),#playBtn:not(.hidden))) :is(#buyDevBtn,#bankTradeBtn,#playerTradeBtn){grid-row:1!important;}
  body.in-game .rollDockInner{gap:8px;padding:0 7px;}
  body.in-game .rollDockTurnBadges .placementTurnBanner,body.in-game .rollDockTurnBadges .extraTurnBanner{font-size:clamp(10px,2.7vw,14px);}
  body.in-game #rollDockBtn,body.in-game #endDockBtn{min-width:clamp(87px,24vw,112px)!important;padding:7px 9px!important;}
  body.in-game .hudBottomLeft{padding-bottom:calc(5px + var(--safe-bottom))!important;}
  body.in-game .rightSidebarInner{padding-bottom:calc(12px + var(--safe-bottom))!important;}
}
/* A clipped, contained canvas layer eliminates overscroll artifacts at the
   lower game controls without changing the interactive map coordinates. */
body.in-game .boardWrap{isolation:isolate;}
body.in-game #board{contain:paint;}


/* v31 — Mobile Resources should occupy the full width of the selected tab.
   Previously #resourcesCard was forced into a flex row, leaving a redundant
   heading next to a narrow column of player summaries. */
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.in-game .rightSidebar[data-active-panel="resources"] #resourcesCard {
    display:block!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    padding:0!important;
  }
  body.in-game .rightSidebar #resourcesCard .resourcesHeaderRow,
  body.in-game .rightSidebar #resourcesCard > h2 {display:none!important;}
  body.in-game .rightSidebar #resourcesCard .panelScaleContent {
    display:block!important;
    box-sizing:border-box;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin:0!important;
    padding:0!important;
  }
  body.in-game .rightSidebar #resourcesCard .resourcesBox,
  body.in-game .rightSidebar #resourcesCard .resSummaryRow {
    width:100%!important;
    max-width:100%!important;
    min-width:0;
    box-sizing:border-box;
  }
}

/* v31 — Desktop Game Log / Dev Cards horizontal drag handle. The Dev card
   list is top-anchored directly beneath its cost text: as the log grows the
   list gets clipped at the bottom, never pushed away from its cost note. */
.sidebarLogDevSplitter {display:none;}
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner {
    overflow:hidden;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #logCard {
    flex:0 0 auto;
    min-height:0;
    overflow:hidden;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #logCard .logList {
    flex:1 1 auto;
    min-height:0;
    max-height:none;
    overflow-y:auto;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #devCard {
    flex:1 1 0;
    min-height:0;
    overflow:hidden;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebar #devCard .devHeaderRow {
    flex:0 0 auto;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebar #devCard .panelScaleContent {
    display:flex;
    flex:1 1 auto;
    flex-direction:column;
    min-height:0;
    overflow:hidden;
    align-items:stretch;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebar #devCard .panelScaleContent > .smallNote {
    flex:0 0 auto;
    margin:0 0 5px;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebar #devCard .panelScaleContent > .devHand {
    display:flex;
    flex:1 1 auto;
    flex-direction:column;
    justify-content:flex-start;
    min-height:0;
    max-height:none;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;
    margin-top:0;
    padding-bottom:4px;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebar #devCard .devRow {
    flex:0 0 auto;
  }
  body.in-game:not(.gamePanelsCollapsed) .sidebarLogDevSplitter {
    display:grid;
    flex:0 0 16px;
    height:16px;
    width:100%;
    min-width:0;
    place-items:center;
    position:relative;
    cursor:ns-resize;
    touch-action:none;
    user-select:none;
    border-radius:9px;
    background:rgba(27,49,65,.7);
    border:1px solid rgba(112,153,179,.34);
    box-sizing:border-box;
  }
  body.in-game:not(.gamePanelsCollapsed) .sidebarLogDevSplitter::after {
    content:'';
    width:68px;
    max-width:40%;
    height:5px;
    border-radius:999px;
    background:#83a8bb;
    box-shadow:0 0 0 1px rgba(3,12,20,.55);
  }
  body.in-game:not(.gamePanelsCollapsed) .sidebarLogDevSplitter:hover,
  body.in-game:not(.gamePanelsCollapsed) .sidebarLogDevSplitter.dragging,
  body.in-game:not(.gamePanelsCollapsed) .sidebarLogDevSplitter:focus-visible {
    border-color:#e5b94c;
    background:#2a475c;
    outline:2px solid rgba(229,185,76,.38);
  }
}

/* Resource images scale together with their numeric badges. Do not clamp
   their physical size to the width of a grid cell after the panel zooms. At
   300%, each resource row may scroll horizontally instead of hiding art. */
body.in-game .resCell .resIcon,
body.in-game .rightSidebarResStrip .resIcon,
body.in-game .resourcesOverlay .resIcon {
  max-width:none;
  max-height:none;
  flex-shrink:0;
}
body.in-game .rightSidebarResStrip,
body.in-game .pResGrid {
  grid-template-columns:repeat(5,minmax(42px,1fr));
  min-width:0;
  overflow-x:auto;
  scrollbar-width:thin;
  scrollbar-color:rgba(137,177,203,.55) transparent;
}
body.in-game .rightSidebarResStrip .resCell,
body.in-game .pResGrid .resCell {min-width:42px;}

/* v32 — A player who is not in a room must never see the empty canvas.
   Use the uncreated lobby as a real, centered entry page instead. */
.uncreatedLobbyIntro{display:none;}
body.uncreated-lobby:not(.in-game):not(.ranked-lobby) .layout{
  display:flex;align-items:flex-start;justify-content:center;overflow:hidden;
  padding:clamp(12px,3vw,38px);
}
body.uncreated-lobby:not(.in-game):not(.ranked-lobby) .layout>.boardWrap,
body.uncreated-lobby:not(.in-game):not(.ranked-lobby) .mobileLobbyMapToggle{display:none!important;}
body.uncreated-lobby:not(.in-game):not(.ranked-lobby) .layout>.panel{
  width:min(100%,650px);max-width:650px;height:100%;min-height:0;max-height:none;
  overflow-y:auto;overflow-x:hidden;padding:0 4px calc(20px + var(--safe-bottom));
}
body.uncreated-lobby:not(.in-game):not(.ranked-lobby) .layout>.panel>:not(#lobbyCard):not(#uncreatedLobbyIntro){display:none!important;}
body.uncreated-lobby:not(.in-game):not(.ranked-lobby) #uncreatedLobbyIntro{
  display:block;text-align:center;padding:30px 12px 8px;
}
.uncreatedLobbyNavigation{display:flex;justify-content:flex-start;margin:0 0 12px;}
.uncreatedLobbyBackBtn{font-size:13px;text-align:left;min-height:36px;}
.uncreatedLobbyEyebrow{font-size:11px;font-weight:800;letter-spacing:.17em;color:#d7ac55;}
.uncreatedLobbyIntro h1{font-size:clamp(22px,3vw,34px);line-height:1.2;margin:10px 0;}
.uncreatedLobbyIntro p{font-size:14px;line-height:1.5;color:var(--muted);margin:0 auto 14px;max-width:430px;}
body.uncreated-lobby #lobbyCard{padding:clamp(15px,2vw,25px);}
body.uncreated-lobby #lobbyCard>.divider:first-of-type{display:none;}
@media(max-width:980px),(pointer:coarse){
  body.uncreated-lobby:not(.in-game) .layout{padding:8px!important;}
  body.uncreated-lobby:not(.in-game) .layout>.panel{padding:0 0 calc(16px + var(--safe-bottom))!important;}
  body.uncreated-lobby:not(.in-game) #uncreatedLobbyIntro{padding:22px 8px 4px;}
}

/* v34: adjustable lobby settings / preview split. In-game and ranked layouts unchanged. */
body:not(.in-game):not(.ranked-lobby) .layout{grid-template-columns:minmax(280px,var(--lobby-sidebar-width,360px)) 10px minmax(0,1fr);column-gap:7px}
.lobbyPanelSplitter{display:block;align-self:stretch;width:10px;min-height:0;border-radius:6px;cursor:col-resize;touch-action:none;background:linear-gradient(90deg,transparent 30%,#45647c 30%,#45647c 70%,transparent 70%);opacity:.8}
.lobbyPanelSplitter:hover,.lobbyPanelSplitter:focus-visible,.lobbyPanelSplitter.dragging{background:linear-gradient(90deg,transparent 25%,var(--accent) 25%,var(--accent) 75%,transparent 75%);opacity:1;outline:0}
body.in-game .lobbyPanelSplitter,body.ranked-lobby .lobbyPanelSplitter{display:none!important}
body.casual-mode .uncreatedLobbyIntro .uncreatedLobbyEyebrow{color:#f0ce8a}
.historyToolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;padding:10px 16px;border-bottom:1px solid var(--line)}
.historyToolbar .checkRow{display:flex;align-items:center;gap:7px;white-space:nowrap;margin:0}
.historyReplayTools,.logReplayTools{display:flex;gap:7px;flex-wrap:wrap;align-items:center}
.logReplayTools .btn{font-size:11px;padding:6px 8px}
.historyGameSelect{display:flex;align-items:center;gap:5px;margin-right:8px;cursor:pointer}
.historySavedSection{margin:8px 0;color:var(--accent);font-size:12px;font-weight:750;letter-spacing:.04em}
.historyCard .historyActions{flex-wrap:wrap}
@media (max-width:980px),(pointer:coarse){
 body:not(.in-game) .layout{display:block;grid-template-columns:none}
 .lobbyPanelSplitter{display:none!important}
 .historyToolbar{padding:7px 12px}
 .historyReplayTools .btn{font-size:11px;padding:8px}
}


/* v35: Desktop game types are side-by-side. On phones, compact the portal
   with the Hex Settlers emblem tucked into its top-left corner. */
@media (min-width: 761px) {
  .modePortalCard {width:min(1140px,calc(100vw - 58px));}
  .modeChoices {grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;}
  .modeChoice {height:100%;min-width:0;}
  .modeChoice strong {font-size:clamp(18px,1.55vw,23px);}
}
@media (max-width: 760px) {
  #playModeScreen.portalScreen {align-items:start;padding:8px 10px calc(58px + var(--safe-bottom));}
  #playModeScreen .modePortalCard {width:100%;max-width:500px;padding:12px 14px 16px;margin:0 auto;}
  #playModeScreen .modeLogo {position:absolute;left:12px;top:11px;width:78px;max-width:none;height:auto;margin:0;}
  #playModeScreen .portalEyebrow {margin:9px 0 5px 88px;text-align:left;font-size:10px;letter-spacing:.12em;}
  #playModeScreen .modePortalCard h1 {margin:0 0 12px 88px;text-align:left;font-size:clamp(19px,5.6vw,25px);line-height:1.15;min-height:48px;}
  #playModeScreen .modeChoices {grid-template-columns:1fr;gap:10px;margin-top:6px;}
  #playModeScreen .modeChoice {padding:13px 17px;border-radius:14px;min-height:91px;}
  #playModeScreen .modeChoice strong {font-size:19px;line-height:1.2;margin:0 0 4px;}
  #playModeScreen .modeChoice span {font-size:12px;line-height:1.35;}
  #playModeScreen .portalLegalLinks {bottom:max(8px,var(--safe-bottom));}
  #playModeScreen .gameTypeSupport {bottom:calc(7px + var(--safe-bottom));}
}
@media (max-width: 350px) {
  #playModeScreen .modeLogo {width:64px;}
  #playModeScreen .portalEyebrow, #playModeScreen .modePortalCard h1 {margin-left:72px;}
  #playModeScreen .modeChoice {padding:10px 12px;min-height:84px;}
}
/* The pre-lobby entry page has no game board to resize. */
body.uncreated-lobby:not(.in-game) .lobbyPanelSplitter {display:none!important;}
body.casual-mode:not(.in-game) #roomCodeLabel,
body.casual-mode:not(.in-game) .lobbyJoinDivider {display:none!important;}
/* Keep the two named template actions adjacent, and wrap on smaller widths. */
#saveRulesBtn, #loadRulesBtn {flex:1 1 calc(50% - 6px);min-width:0;padding:9px 6px;font-size:12px;white-space:normal;}
.settingsTemplateActions {flex-wrap:wrap;align-items:center;}
.settingsTemplateActions #settingsAutosaveStatus {flex:1 1 100%;margin-top:0;}
/* The replay toolbar must clear the top game HUD, regardless of HUD scaling. */
body.in-game .historyReplayBar {
  top:var(--replay-controls-top,94px);
  z-index:42;
  max-height:calc(100% - var(--replay-controls-top,94px) - 10px);
  overflow-y:auto;
}
@media (max-width:760px) {
  body.in-game .historyReplayBar {
    width:calc(100% - 18px);
    padding:7px;
    gap:5px;
    top:var(--replay-controls-top,70px);
  }
  body.in-game .historyReplayBar .btn {padding:7px 8px;font-size:11px;}
  body.in-game .historyReplayStatus {flex-basis:110px;}
}

/* v36: Keep the mobile heading clear of the fixed account orb. The title
   wraps within the space remaining to its left instead of drawing beneath it. */
@media (max-width: 760px) {
  #playModeScreen .modePortalCard h1 {
    padding-right:clamp(45px,15vw,73px);
    min-height:73px;
    line-height:1.2;
  }
  #playModeScreen .modePortalCard .portalEyebrow {
    padding-right:clamp(45px,15vw,73px);
  }
}

/* v45 — Size the turn clock to its actual time, turn, and action text.
   The former fixed 190px/176px/150px heights left a large dead area under
   short action messages. Keep long notices scrollable without obscuring the board. */
body.in-game .countdownClock {
  box-sizing:border-box;
  display:flex;
  flex-direction:column;
  width:clamp(190px,19vw,250px)!important;
  min-width:190px!important;
  max-width:min(250px,calc(100vw - 12px))!important;
  height:auto!important;
  min-height:0!important;
  max-height:min(65dvh,340px)!important;
  overflow:hidden;
}
body.in-game .countdownClock .clockTopRow,
body.in-game .countdownClock .panelScaleContent {flex:0 0 auto;min-width:0;max-width:100%;}
body.in-game .countdownClock .clockMeta {
  white-space:normal;
  overflow-wrap:anywhere;
  font-size:10px;
  line-height:1.2;
}
body.in-game .countdownClock .clockActionInfo {
  box-sizing:border-box;
  flex:0 1 auto;
  min-height:0;
  max-height:min(34dvh,180px)!important;
  width:100%;
  margin-top:6px!important;
  padding-top:6px!important;
  padding-bottom:0!important;
  overflow-x:hidden;
  overflow-y:auto;
  white-space:normal!important;
  overflow-wrap:anywhere;
  word-break:normal;
  text-align:left;
  scrollbar-width:thin;
}
body.in-game .countdownClock .clockActionInfo .turnInfo {
  display:block;
  width:100%;
  min-width:0;
  font-size:11px!important;
  font-weight:800;
  line-height:1.28;
  white-space:normal!important;
  overflow-wrap:anywhere;
  word-break:normal;
}
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.in-game .countdownClock {
    width:min(190px,calc(100vw - 12px))!important;
    min-width:0!important;
    max-width:min(190px,calc(100vw - 12px))!important;
    height:auto!important;
    min-height:0!important;
    max-height:min(60dvh,290px)!important;
  }
  body.in-game .countdownClock .clockActionInfo {
    margin-top:4px!important;
    padding-top:4px!important;
    max-height:min(36dvh,180px)!important;
  }
}
@media (max-width:900px) and (max-height:550px) and (orientation:landscape) {
  body.in-game .countdownClock {
    height:auto!important;
    min-height:0!important;
    max-height:min(64dvh,220px)!important;
  }
  body.in-game .countdownClock .clockActionInfo {max-height:min(34dvh,120px)!important;}
}

/* v38 — Casual rules browser and unified administrator console */
.rulesCategoryTabs,.rulesScenarioTabs{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 20px;background:#111a23;border-bottom:1px solid var(--line);}
.rulesScenarioTabs{background:#10171e;padding-top:8px;padding-bottom:8px;}
.rulesCategoryTabs.hidden,.rulesScenarioTabs.hidden{display:none!important;}
.rulesTab{border:1px solid #334857;border-radius:10px;background:#17232d;padding:9px 14px;color:#d2e2eb;cursor:pointer;font-weight:750;font-size:12px;white-space:nowrap;}
.rulesTab.active{border-color:#4b9bdd;background:#234160;color:#fff;box-shadow:inset 0 0 0 1px rgba(100,180,255,.2);}
.rulesTab:hover{background:#263a4a;}
.adminDashboard{width:100%;max-width:100%;min-width:0;color:var(--text);}
.modalBox:has(.adminDashboard){width:min(1160px,96vw);max-width:1160px;max-height:min(94vh,1040px);}
.modalBox:has(.adminDashboard) .modalBody{overflow:auto;min-height:0;max-height:calc(94vh - 145px);}
.adminTabs{display:flex;gap:7px;flex-wrap:wrap;border-bottom:1px solid var(--line);padding:0 0 12px;margin-bottom:16px;}
.adminTab{border:1px solid #395265;background:#152533;color:#c7dbe9;border-radius:9px;padding:10px 12px;cursor:pointer;font-weight:750;font-size:12px;}
.adminTab.active{background:#274764;color:#fff;border-color:#66b2f4;}
.adminDashboardContent{min-height:180px;min-width:0;}
.adminActionBar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:10px 0 16px;}
.adminHistoryList{max-height:48vh;overflow:auto;display:grid;gap:5px;margin:12px 0;}
.adminHistoryItem{display:flex;gap:10px;align-items:flex-start;padding:10px 12px;border:1px solid #344454;border-radius:9px;background:#111c24;font-size:12px;line-height:1.5;cursor:pointer;}
.adminHistoryItem input{margin-top:3px;flex:none;}
.adminInlineStatus{color:#aed0e9;margin:8px 0;font-size:12px;}
.adminDangerPanel{padding:16px;border:1px solid #945453;border-radius:12px;background:rgba(155,55,55,.09);margin:20px 0;display:grid;gap:11px;}
.adminDangerPanel h3{margin:0;color:#ffaea4;}
.adminHistoryConfirm{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:1.5;cursor:pointer;}
.adminHistoryConfirm input{margin-top:3px;}
.adminHealthGrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:9px;margin:15px 0;}
.adminHealthMetric{min-width:0;padding:13px;background:#101c26;border:1px solid #334658;border-radius:10px;}
.adminHealthMetric strong{display:block;margin-top:8px;font-size:14px;line-height:1.4;overflow-wrap:anywhere;}
.adminHealthFile{font-family:var(--mono);font-size:11px;line-height:1.55;margin:7px 0;padding:8px;border-bottom:1px solid rgba(255,255,255,.07);overflow-wrap:anywhere;}
@media (max-width:900px){.rulesCategoryTabs,.rulesScenarioTabs{overflow-x:auto;flex-wrap:nowrap;scrollbar-width:thin;padding:9px 12px;}.modalBox:has(.adminDashboard){width:100%;max-width:100%;max-height:95dvh;}.modalBox:has(.adminDashboard) .modalBody{max-height:calc(95dvh - 125px);}.adminTab{padding:8px;font-size:11px;}.adminHealthGrid{grid-template-columns:repeat(2,minmax(0,1fr));}}


/* v39: App version is visible on both entry screens and stays centered
   independently of the legal links and the support button. */
#authLanding .appVersion, #playModeScreen .appVersion {
  position:fixed;
  left:50%;
  bottom:max(19px,env(safe-area-inset-bottom));
  transform:translateX(-50%);
  z-index:5;
  color:#91a9ba;
  font:700 12px var(--sans);
  letter-spacing:.08em;
  pointer-events:none;
  white-space:nowrap;
  text-shadow:0 1px 4px #071019;
}
@media(max-width:560px) {
  #authLanding .appVersion, #playModeScreen .appVersion {
    bottom:calc(47px + env(safe-area-inset-bottom));
    font-size:11px;
  }
}

/* Readiness is visible before and after lobby readiness changes. */
#readyBtn.readyYes {background:linear-gradient(180deg,#127441,#07532e);border-color:#56e69a;color:#fff;box-shadow:0 0 0 1px rgba(56,210,122,.35)}
#readyBtn.readyNo {background:linear-gradient(180deg,#942d38,#671c2a);border-color:#f27889;color:#fff;box-shadow:0 0 0 1px rgba(255,91,91,.3)}
.portalLanguageButton {position:absolute;top:max(18px,env(safe-area-inset-top,0px));left:50%;transform:translateX(-50%);z-index:50;white-space:nowrap;}
.languagePage {position:fixed;inset:0;z-index:5000;background:#0f141a;overflow-y:auto;padding:clamp(18px,4vw,50px);color:var(--text)}
.languagePageInner {max-width:850px;margin:0 auto}
.languagePageHeader {display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:26px;flex-wrap:wrap}
.languageGrid {display:grid;grid-template-columns:repeat(auto-fit,minmax(165px,1fr));gap:12px}
.languageChoice {display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:64px;text-align:left}
.languageChoice.selected {border-color:var(--ok);box-shadow:inset 0 0 0 1px var(--ok)}

.lobbyReadyStatus.waiting {color:#ffc9ce;border-color:rgba(255,91,91,.55);background:rgba(255,91,91,.12)}

/* v51: browser-only map toggle and two-column lobby/settings layout.
   Existing mobile map drawer, ranked ballot and in-game HUD are unchanged. */
.lobbyCardHeading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px;}
.lobbyCardHeading h2{margin:0;}
.desktopLobbyMapToggle{display:none;flex:0 0 auto;padding:7px 12px;font-size:12px;}
.copyValueButton,.copyLinkValue{cursor:pointer;touch-action:manipulation;transition:border-color .14s,background .14s;}
.copyValueButton:disabled,.copyLinkValue:disabled{cursor:default;opacity:.65;}
.copyValueButton{display:inline-block;max-width:100%;margin:0;padding:3px 5px;border:1px solid transparent;border-radius:7px;background:transparent;color:var(--text);text-align:left;font:inherit;font-family:var(--mono);font-size:18px;letter-spacing:2px;}
.copyLinkValue{display:block;width:100%;min-width:0;height:auto;min-height:38px;margin-top:6px;padding:9px 11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left;font-family:var(--mono);font-size:11px;color:var(--text);}
.copyHint{margin:3px 0 0;font-size:10px;line-height:1.3;color:var(--muted);}
.copyValueButton:not(:disabled):hover,.copyLinkValue:not(:disabled):hover{border-color:var(--accent);background:rgba(224,174,58,.07);}
.copyValueButton:focus-visible,.copyLinkValue:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
body.ranked-lobby .roomTop .copyHint{display:none!important;}
body.ranked-lobby .copyLinkValue{height:32px;min-height:32px;margin-top:0;padding:7px 9px;font-size:10px;}
@media(min-width:981px) and (pointer:fine){
  body.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby):not(.uncreated-lobby) .desktopLobbyMapToggle{display:inline-flex;align-items:center;justify-content:center;}
  body.desktopLobbyMapHidden.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby):not(.uncreated-lobby) .layout{grid-template-columns:minmax(0,1fr);column-gap:0;}
  body.desktopLobbyMapHidden.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby):not(.uncreated-lobby) .lobbyPanelSplitter{display:none!important;}
  body.desktopLobbyMapHidden.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby):not(.uncreated-lobby) .layout>.boardWrap{display:none!important;}
  body.desktopLobbyMapHidden.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby):not(.uncreated-lobby) .layout>.panel{
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(0,1fr);
    align-items:stretch;gap:16px;min-width:0;min-height:0;overflow:hidden;padding:0;
  }
  body.desktopLobbyMapHidden.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby):not(.uncreated-lobby) .layout>.panel>#lobbyCard,
  body.desktopLobbyMapHidden.hasLobbyMapPreview:not(.in-game):not(.ranked-lobby):not(.uncreated-lobby) .layout>.panel>#setupCard{
    min-width:0;min-height:0;height:100%;max-height:none;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;
  }
}

/* v53: Journey hub, guided first game, and server-enforced lobby access. */
#journeyScreen {z-index:35; overflow:auto;align-items:center;justify-content:center;padding:34px 12px}
#roomNotFoundScreen {z-index:50}
.journeyCard {width:min(900px,96vw); max-height:calc(100dvh - 55px);overflow-y:auto;position:relative;padding:clamp(20px,3.7vw,40px)}
.journeyCard .journeyBack {position:absolute;left:18px;top:16px}
.journeyCard .portalEyebrow,.journeyCard h1,.journeyCard>.portalLead {text-align:center}
.journeyOptions {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:15px;margin:24px 0}
.journeyOptions .modeChoice {text-align:left;min-height:170px}
.journeyOptions .modeChoice:disabled {opacity:.55;cursor:not-allowed}
.journeyPanel {margin:20px 0 8px}
.journeyActions {display:flex;gap:10px;flex-wrap:wrap;margin-bottom:15px}
.publicLobbyList {display:flex;flex-direction:column;gap:8px;min-height:100px;max-height:min(390px,48vh);overflow:auto}
.publicLobbyItem {display:flex;align-items:center;justify-content:space-between;gap:15px;background:rgba(20,41,55,.76);border:1px solid var(--line);border-radius:12px;padding:11px 14px}
.publicLobbyItem p {margin:5px 0 0}
.journeyTutorialReplay {display:block;margin:18px auto 0}
.lobbyAccessControls {padding:11px;border:1px solid var(--line);border-radius:12px;background:rgba(18,44,62,.55);margin:12px 0}
.lobbyAccessControls .label {margin:0 0 7px}
.lobbyAccessControls .checkRow {display:flex;align-items:flex-start;gap:10px;margin:12px 0 0;white-space:normal;line-height:1.4;font-size:12px}
/* V54 All Games and lobby tools */
.journeyBottomActions{display:flex;justify-content:center;gap:10px;margin:16px auto 0;flex-wrap:wrap}
.journeyBottomActions .btn{min-width:96px;padding:9px 15px;font-size:.87rem}
.journeySettingsPanel{margin-top:16px;border:1px solid #315065;background:#0c1a25;border-radius:14px;padding:18px;max-height:68vh;overflow:auto}
.journeySettingsHeading{display:flex;justify-content:space-between;align-items:center;gap:10px}
.journeySettingsHeading h2{font-size:1.13rem;margin:0}
.settingsMockBoard{margin:16px 0;border:1px solid #42617b;background:#091822;overflow:hidden;border-radius:12px;min-height:225px}
.settingsMockTop,.settingsMockBottom{padding:12px;text-align:center;background:#162c3e;font-size:calc(12px * var(--mock-scale,1));}
.settingsMockStage{display:flex;align-items:stretch;justify-content:space-between;gap:8px;min-height:156px;padding:10px}
.settingsMockLog,.settingsMockSide{border-radius:7px;background:#243848;padding:12px 8px;font-size:calc(12px * var(--mock-scale,1));flex:0 0 auto;max-width:35%}
.settingsMockSide{width:min(var(--mock-width,30%),35%)}
.settingsMockLog{width:25%}
.settingsMockHexes{display:flex;flex:1;flex-wrap:wrap;gap:3px;justify-content:center;align-content:center;max-width:330px;margin:auto}
.settingsMockHexes span{display:grid;place-items:center;clip-path:polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%);background:#315d52;width:58px;height:62px;font-size:27px}
.settingsMockHexes span:nth-child(3n){background:#946e3c}.settingsMockHexes span:nth-child(4n){background:#526c81}
.settingsSandboxSliders{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 16px}
.settingsSandboxSliders label{display:grid;grid-template-columns:1fr auto;gap:5px;align-items:center;font-size:.82rem}
.settingsSandboxSliders input{grid-column:1/-1;width:100%;accent-color:#56acff}
.settingsSandboxSliders output{color:#ffca65}
.journeySettingsActions{display:flex;gap:12px;justify-content:center;margin-top:16px}
.lobbyCardHeading{display:flex;align-items:center;gap:8px}
.lobbyCardHeading h2{margin-right:auto}.leaveLobbyTopBtn{font-size:.8rem;padding:7px 10px}
#modalActions.bossProfileActions{justify-content:space-between;width:100%;display:flex}
#modalActions.bossProfileActions button:last-child{margin-left:auto}
@media(max-width:680px){.settingsSandboxSliders{grid-template-columns:1fr}.journeySettingsHeading{flex-direction:column;align-items:flex-start}.settingsMockHexes span{width:43px;height:45px;font-size:20px}}


/* Optional provider sign-in and linked-identity account controls. */
.oauthOptions { margin-top: 14px; }
.oauthDivider { display:flex; align-items:center; gap:12px; margin:10px 0 12px; font-size:12px; color:#aebfca; text-align:center; }
.oauthDivider:before,.oauthDivider:after { content:""; flex:1; height:1px; background:rgba(173,195,211,.28); }
.oauthProviderButtons { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
.oauthProviderButtons .oauthProvider { flex:1 1 100px; min-height:39px; border-color:#42657d; background:#172937; white-space:normal; text-align:center; }
.oauthProviderButtons .oauthProvider:hover { border-color:#dfb34f; background:#233a49; }
.oauthLinkedRow { display:flex; gap:10px; align-items:center; justify-content:space-between; flex-wrap:wrap; padding:8px 0; border-bottom:1px solid rgba(255,255,255,.08); }
.oauthLinkedRow strong { font-weight:700; color:#f3f6fa; }
.oauthLinkedRow span { font-size:12px; color:#aebfca; }
.oauthLinkedActions { display:flex; gap:8px; flex-wrap:wrap; }
@media(max-width:600px){.oauthProviderButtons .oauthProvider { flex:1 1 100%; } }

/* Public lobby discovery, details, navigation — v55 */
.publicLobbyFilters{display:grid;grid-template-columns:minmax(170px,2fr) repeat(4,minmax(112px,1fr));gap:9px;margin-bottom:10px}
.publicLobbyFilters label{display:flex;flex-direction:column;gap:5px;color:var(--muted);font-size:11px;font-weight:650}
.publicLobbyFilters .input{width:100%;min-width:0;min-height:36px;padding:7px 9px;font-size:12px}
#publicLobbyCount{margin:2px 0 9px}
.publicLobbyItem{width:100%;cursor:pointer;text-align:left;color:var(--text);font:inherit;transition:background .12s,border-color .12s}
.publicLobbyItem:hover,.publicLobbyItem:focus-visible{background:rgba(30,69,91,.9);border-color:var(--accent);outline-offset:2px}
.publicLobbyItemText{display:flex;flex-direction:column;gap:5px;min-width:0}
.publicLobbyViewAction{white-space:nowrap;font-size:12px;font-weight:750;color:#9fd4ff}
.publicLobbyDetail{margin-top:12px}
.publicLobbyDetail h2{margin:8px 0 7px}
.publicLobbyDetailMap{display:block;width:min(100%,650px);height:auto;aspect-ratio:5/3;object-fit:contain;margin:15px auto;padding:8px;background:rgba(7,19,29,.88);border:1px solid var(--line);border-radius:14px}
.publicLobbyDetailFields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:16px 0}
.publicLobbyDetailField{display:flex;flex-direction:column;gap:6px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:rgba(14,36,53,.7);overflow-wrap:anywhere}
.publicLobbyDetailField span{font-size:11px;color:var(--muted)}
.publicLobbyDetailField strong{font-size:14px;font-weight:650}
#publicLobbyDetailJoinBtn{width:100%}
.portalBackBtn{display:block;margin:0 0 20px;text-align:left}
.overlayBackBtn{display:block;margin:0 0 18px}
body.casual-mode #downloadTexturePackBtn,body.casual-mode #uploadTexturePackBtn,body.casual-mode #deleteTexturePackBtn{display:none!important}
@media(max-width:920px){.publicLobbyFilters{grid-template-columns:repeat(3,minmax(0,1fr))}.publicLobbyFilters label:first-child{grid-column:span 3}}
@media(max-width:620px){.publicLobbyFilters{grid-template-columns:repeat(2,minmax(0,1fr))}.publicLobbyFilters label:first-child{grid-column:span 2}.publicLobbyViewAction{width:100%;text-align:right}.publicLobbyDetailFields{grid-template-columns:1fr}.publicLobbyDetailMap{margin-top:8px}}

.walkthroughNav{display:flex;gap:8px;align-items:center;flex-wrap:wrap;justify-content:flex-end}

/* Live walkthrough: a docked guide, NOT a substitute board. The real engine and
   game canvas remain interactive underneath the instructions. */
.modeChoice.lockedMode { opacity:.45; cursor:not-allowed; filter:grayscale(.5); }
.modeChoice.lockedMode strong::before { content:"🔒 "; font-size:.8em; }
.tutorialGuide { position:fixed;top:clamp(58px,8vh,88px);right:16px;width:min(355px,calc(100vw - 32px));
  max-height:calc(100dvh - 110px);overflow-y:auto;z-index:1500;padding:19px 20px 18px;
  border:1px solid #d3a960;border-radius:17px;background:linear-gradient(142deg,rgba(12,35,49,.98),rgba(5,15,25,.98));
  box-shadow:0 16px 44px rgba(0,0,0,.75);color:#f3eee2;pointer-events:auto; }
.tutorialGuide.hidden {display:none!important}
.tutorialGuideHeader {display:flex;justify-content:space-between;gap:12px;align-items:center;color:#e9cc8c;font-size:11px;font-weight:750;letter-spacing:.07em}
.tutorialGuide h2 {margin:12px 0 7px;color:#fff0b8;font-size:clamp(18px,2vw,23px);line-height:1.2}
.tutorialGuide p {font-size:13px;line-height:1.55;margin:8px 0}
#tutorialGuideHint {color:#acd1d8;font-size:12px}
.tutorialGuideActions {display:flex;gap:9px;flex-wrap:wrap;margin-top:16px}
.tutorialGuideActions .btn {font-size:12px;flex:1;min-width:116px}
.tutorialAttention {outline:3px solid #ffd66b!important;outline-offset:3px;animation:tutorialLivePulse 1.7s ease-in-out infinite;z-index:2;}
@keyframes tutorialLivePulse {50%{outline-color:#fff4bd;filter:drop-shadow(0 0 8px #fbbf58)}}
@media(max-width:720px) {
 .tutorialGuide {top:58px;right:8px;width:min(320px,calc(100vw - 16px));padding:12px 14px;
    max-height:min(36dvh,280px);border-radius:13px}
 .tutorialGuide h2 {font-size:16px;margin:7px 0 4px}
 .tutorialGuide p {font-size:11px;margin:4px 0}
 .tutorialGuideActions {margin-top:8px}
 .tutorialGuideActions .btn {padding:7px 10px}
}

/* V59: independent Daily/Weekly tabs and movable guide */
.challengePeriodTabs { margin: 0 0 14px; }
.challengePeriodTabs .hTab { min-width:110px; }
.tutorialGuideHeader { cursor:grab; touch-action:none; user-select:none; -webkit-user-select:none; }
.tutorialGuideHeader:active { cursor:grabbing; }
.challengeExplorer { display:flex; flex-direction:column; gap:12px; }
.challengeExplorer .challengeMapTabs { margin-bottom:4px; }
.challengeExplorerFilters { display:flex; flex-wrap:wrap; align-items:flex-end; gap:10px; padding:12px 0; }
.challengeExplorerFilters label { display:flex; flex-direction:column; gap:4px; font-size:12px; min-width:110px; }
.challengeExplorerFilters .checkRow { display:flex; align-items:center; flex-direction:row; gap:6px; }
.challengeExplorerFilters input[type=search] { min-width:180px; }
.challengeExplorerDateCustom { display:flex; gap:8px; flex-wrap:wrap; }
.challengeExplorerTable { max-width:100%; overflow-x:auto; }
.challengeExplorerTable table { width:100%; border-collapse:collapse; }
.challengeExplorerTable th,.challengeExplorerTable td { padding:9px 12px; border-bottom:1px solid rgba(164,189,199,.22); text-align:left; white-space:nowrap; }
.challengeExplorerTable th button { background:none; color:inherit; cursor:pointer; border:0; text-align:left; font-weight:700; }
.challengeExplorerTable tr:first-child td { color:#f2d99b; }
.challengeExplorer .historyList { width:100%; }
.challengeExplorer .hint { margin:12px 0; }
@media(max-width:720px) { .challengeExplorerFilters { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px; } .challengeExplorerFilters input[type=search] { min-width:0;width:100%; } }

/* V62 — all four right game-panel sections can be collapsed to either handle. */
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #resourcesCard,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #logCard,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #devCard,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #rightSidebarResourcesDock {
    box-sizing:border-box;
    min-height:0!important;
    max-height:none!important;
    overflow:hidden!important;
    flex-shrink:0;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #rightSidebarResourcesDock {
    padding-top:0;
  }
}
.spectatorNoColor {
  background:none!important;
  border:2px dashed rgba(170,183,196,.8)!important;
  box-shadow:none!important;
}
.discardLabel {display:flex; align-items:center; gap:9px;}
.discardResourceIcon {width:34px; height:34px; object-fit:contain; flex:0 0 34px;}

/* In the read-only Settings room, the real HUD provides its own size/audio
   controls. Keep only unobtrusive exit and reset buttons over the board. */
body.settings-sandbox #journeySettingsPanel {
  display:flex!important;
  position:fixed!important;
  z-index:140;
  top:calc(54px + env(safe-area-inset-top, 0px));
  left:12px;
  right:auto;
  width:max-content;
  max-width:calc(100vw - 24px);
  max-height:none;
  margin:0;
  padding:8px;
  gap:8px;
  align-items:center;
  overflow:visible;
  border:1px solid rgba(245,192,83,.56);
  border-radius:10px;
  background:rgba(13,29,43,.92);
  box-shadow:0 8px 24px rgba(0,0,0,.38);
}
body.settings-sandbox #journeySettingsPanel .btn {min-height:36px;white-space:nowrap;}
body.settings-sandbox #app #board {cursor:default!important;}
body.settings-sandbox #app #rollDock,
body.settings-sandbox #app #turnCard .actions,
body.settings-sandbox #app #backTurnBtn,
body.settings-sandbox #app #pauseBtn,
body.settings-sandbox #app #playBtn,
body.settings-sandbox #app #endGameVoteBtn,
body.settings-sandbox #app #leaveGameBtn {pointer-events:none!important;opacity:.42;}
@media(max-width:700px){body.settings-sandbox #journeySettingsPanel {
  top:calc(48px + env(safe-area-inset-top, 0px));left:8px;
  max-width:calc(100vw - 16px);gap:5px;padding:5px;
} body.settings-sandbox #journeySettingsPanel .btn{font-size:12px;padding:6px 9px;}}

/* V63: Resizing must never erase the existing resource and development details.
   The header/scale buttons stay put; each section's real contents scroll inside
   its own pane, even when a slider collapses a pane to zero pixels. */
@media (min-width:901px) and (pointer:fine), (min-width:1181px) {
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #resourcesCard,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #logCard,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #devCard,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #rightSidebarResourcesDock {
    min-height:0!important;
    max-height:none!important;
    box-sizing:border-box;
    overflow:hidden!important;
    flex-shrink:0!important;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #resourcesCard {
    display:flex;flex-direction:column;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #resourcesCard .resourcesHeaderRow,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #devCard .devHeaderRow,
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #logCard .cardTitleRow {
    flex:0 0 auto;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #resourcesCard > .panelScaleContent {
    display:block!important;
    flex:1 1 auto;
    min-height:0;
    height:auto;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain;
    scrollbar-width:thin;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #resourcesCard #resourcesBox {
    display:flex!important;
    flex-direction:column;
    flex:0 0 auto;
    gap:5px;
    padding:0 2px 4px;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #resourcesCard .resSummaryRow {
    display:flex!important;
    min-height:31px;
    flex:0 0 auto;
    margin:0;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #logCard .logList {
    overflow-y:auto!important;
    overscroll-behavior:contain;
    scrollbar-width:thin;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #devCard > .panelScaleContent {
    min-height:0;
    height:auto;
    flex:1 1 auto;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    scrollbar-width:thin;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #devCard .devHand {
    overflow-y:visible!important;
    min-height:0;
    flex:0 0 auto!important;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #rightSidebarResourcesDock {
    display:block;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    scrollbar-width:thin;
    padding-right:2px;
  }
  body.in-game:not(.gamePanelsCollapsed) .rightSidebarInner > #rightSidebarResourcesDock .rightSidebarResourcesBody {
    min-height:0;
    gap:8px;
  }
}

/* V63: real, asset-driven startup loading gate. No invented progress or fake delay. */
.gameBootLoader {
  position:fixed; inset:0; z-index:999999;
  display:grid; place-items:center;
  padding:20px; box-sizing:border-box;
  background:radial-gradient(ellipse at 50% 16%, #18384a 0%, #0b1b2a 48%, #07121e 100%);
  color:#f6f3e9;
  opacity:1;
  transition:opacity .30s ease,visibility .30s ease;
}
.gameBootLoader.gameBootDone { opacity:0; visibility:hidden; pointer-events:none; }
.gameBootCard { width:min(100%,470px); text-align:center; padding:clamp(20px,4vw,45px); box-sizing:border-box;
  border:1px solid rgba(233,190,102,.3); border-radius:24px;
  background:rgba(10,24,37,.91); box-shadow:0 18px 90px rgba(0,0,0,.3); }
.gameBootLogo { width:72px; height:72px; object-fit:contain; display:block; margin:0 auto 14px; }
.gameBootEyebrow { font-weight:900; font-size:11px; letter-spacing:.22em; color:#e9bc66; }
.gameBootCard h1 { font-size:clamp(22px,4vw,30px); line-height:1.2; margin:10px 0; }
.gameBootCard p { font-size:14px; min-height:20px; color:#a9c8d7; margin:15px 0 20px; }
.gameBootProgressTrack { width:100%; height:15px; overflow:hidden; border:1px solid #446278; border-radius:100px; background:#0a151f; }
.gameBootProgressFill { height:100%; width:0; border-radius:inherit; background:linear-gradient(90deg,#b68c44,#edc66d);
  transition:width .16s linear; }
.gameBootProgressMeta { margin-top:9px; display:flex; justify-content:space-between; gap:8px;
  color:#b0cada; font-size:12px; font-variant-numeric:tabular-nums; text-align:left; }
.gameBootProgressMeta strong {color:#f2d99d;}
#gameBootContinue:not([hidden]) {display:block; margin:22px auto 0;}

/* V66: The mobile walkthrough is a distinct, compact touch-first guide. */
.tutorialGuideMobile { width:min(360px,calc(100vw - 20px)); max-height:min(57vh,480px); overflow-y:auto; overscroll-behavior:contain; }
.tutorialGuideMobile .tutorialGuideHeader {font-size:10px;}
.tutorialGuideMobile .tutorialGuideActions .btn {min-width:96px;}
@media (max-width:900px), (pointer:coarse) and (max-width:1180px) {
  body.live-tutorial-mobile .tutorialGuide {left:8px;right:auto;top:clamp(48px,6vh,76px);max-height:42vh;width:min(350px,calc(100vw - 16px));z-index:400;}
  body.live-tutorial-mobile .tutorialGuide h2 {font-size:16px;}
  body.live-tutorial-mobile .tutorialGuideActions {position:sticky;bottom:0;background:#101b25;padding:6px 0;}
}
