/* 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);
}
.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);
}
.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;}
.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;}
.clockDragGrip{width:20px; height:20px; border-radius:999px; font-size:10px; opacity:.95;}
.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);
}

/* 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;
}
.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);
}

.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{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)}
@media(max-width:650px){.modeChoices{grid-template-columns:1fr}.portalScreen{padding:12px}.portalCard{padding:26px 20px}.portalLogo{width:185px}}
.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)}
