:root{
  --bg:#0b0f14;
  --panel:rgba(255,255,255,.04);
  --line:rgba(255,255,255,.12);
  --text:#e7eef9;
  --muted:#9fb0c7;
  --accent:#f4c542;
  --good:#34d399;
  --bad:#fb7185;
  --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;
  --r:14px;
}

*{box-sizing:border-box;}

html, body{
  min-height:100%;
}

body{
  margin:0; padding:0;
  font-family:var(--sans);
  color:var(--text);
  width:100%;
  overflow-x:hidden;
  background:
    radial-gradient(900px 600px at 20% 10%, rgba(244,197,66,.10), transparent 60%),
    radial-gradient(900px 600px at 80% 20%, rgba(125,211,252,.08), transparent 55%),
    linear-gradient(180deg, #070a0f, var(--bg));
  background-repeat:no-repeat;
  background-size:cover;
  background-attachment:fixed;
}

.pill{
  display:inline-flex; gap:8px; align-items:center;
  padding:6px 10px; border-radius:999px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.22);
  font-family:var(--mono); font-size:12px; color:var(--muted);
  white-space:nowrap;
}
.pill b{color:var(--text);}
.roundDelta{
  min-width:28px;
  text-align:right;
  font-family:var(--mono);
}

.wrap{
  max-width:980px; margin:0 auto;
  padding:8px 8px 12px;
  width:100%;
  display:grid; gap:16px;
}
.card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--r);
  padding:10px;
}
.toolbarRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  flex-wrap:nowrap;
}
.row.actionRow{
  display:flex;
  flex-wrap:nowrap;
  gap:6px;
  width:auto;
  margin-left:auto;
}
.actionRow button{
  width:auto;
  flex:0 0 auto;
  padding:7px 9px;
  font-size:12px;
  white-space:nowrap;
}

.row{display:flex; gap:10px; align-items:center; flex-wrap:wrap;}
.between{justify-content:space-between;}
h2{margin:0; font-size:14px; letter-spacing:.2px;}
.small{font-size:12.5px; color:var(--muted); line-height:1.35;}
.mono{font-family:var(--mono);}

input[type="text"]{
  background:rgba(0,0,0,.28); color:var(--text);
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 10px;
  outline:none;
}
select{
  background:rgba(0,0,0,.28);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:12px;
  padding:8px 10px;
  outline:none;
}
input:focus{border-color:rgba(244,197,66,.6); box-shadow:0 0 0 3px rgba(244,197,66,.12);}
select:focus{border-color:rgba(244,197,66,.6); box-shadow:0 0 0 3px rgba(244,197,66,.12);}

button{
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:750;
}
button:hover{background:rgba(255,255,255,.09);}
button:disabled{
  opacity:.45;
  cursor:not-allowed;
  background:rgba(255,255,255,.03);
  border-color:rgba(255,255,255,.10);
  color:rgba(231,238,249,.60);
  box-shadow:none;
}
button:disabled:hover{
  background:rgba(255,255,255,.03);
}
.btnAccent{border-color:rgba(244,197,66,.30); background:rgba(244,197,66,.14);}
.btnAccent:hover{background:rgba(244,197,66,.20);}
.btnDanger{border-color:rgba(251,113,133,.30); background:rgba(251,113,133,.10);}
.btnDanger:hover{background:rgba(251,113,133,.16);}

/* Setup chips */
.chips{display:flex; flex-wrap:wrap; gap:8px; margin-top:10px;}
.chip{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.22);
  font-family:var(--mono);
  font-size:12.5px;
}
.chip.starterChip{
  border-color:rgba(244,197,66,.58);
  background:rgba(244,197,66,.26);
  box-shadow:0 0 0 2px rgba(244,197,66,.18);
}
.chip.starterChip span{
  color:#fff5cf;
  font-weight:800;
}
.chip button{padding:6px 8px; border-radius:10px; font-size:12px;}
.recentPlayersWrap{margin-top:10px;}
.recentPlayers{margin-top:6px;}
.recentPlayers .chip{
  padding:0;
  border:none;
  background:transparent;
}
.recentPlayers .chip button{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(244,197,66,.35);
  background:rgba(244,197,66,.16);
  font-family:var(--mono);
  font-size:12px;
}
.recentPlayers .chip button:hover{
  background:rgba(244,197,66,.24);
}
.setupActionsRow{
  margin-top:10px;
  gap:8px;
}
.setupActionsRow button{
  flex:1 1 0;
  min-width:140px;
}

/* Current round entries (mobile-first) */
.entryList{display:grid; gap:8px; margin-top:8px;}
.entryRow{
  border:1px solid rgba(255,255,255,.10);
  border-radius:12px;
  background:rgba(0,0,0,.18);
  padding:7px 8px;
}
.entryTop{display:flex; align-items:center; justify-content:space-between; gap:8px;}
.playerMeta{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}
.pname{font-family:var(--mono); font-weight:850; letter-spacing:.2px;}
.scoreMeta{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:nowrap;
}
.ptotal{
  font-family:var(--mono);
  font-size:11px;
  color:var(--good);
  font-weight:800;
  text-align:right;
}
.roundMini{
  font-family:var(--mono);
  font-size:11px;
  font-weight:700;
  color:var(--muted);
}
.playerBidBadge{
  font-family:var(--mono);
  font-size:11px;
  font-weight:800;
  border:1px solid rgba(244,197,66,.45);
  background:rgba(244,197,66,.20);
  color:#fff5cf;
  border-radius:999px;
  padding:3px 8px;
  white-space:nowrap;
}
.turn{
  border-color: rgba(244,197,66,.35);
  box-shadow: 0 0 0 3px rgba(244,197,66,.10);
}
.inputs{
  margin-top:5px;
  display:grid;
  grid-template-columns: 1fr;
  gap:5px;
  align-items:end;
}
.inputs.phaseBids{
  grid-template-columns:1fr;
}
.inputs.phaseResults{
  grid-template-columns:1fr;
}
.field{min-width:0;}
.field label{
  display:block;
  font-size:11px;
  color:var(--muted);
  margin:0 0 4px;
  letter-spacing:.02em;
  white-space:nowrap;
}
.numPad{
  display:grid;
  grid-template-columns: repeat(var(--num-count, 6), minmax(0, 1fr));
  gap:4px;
}
.numBtn{
  min-height:28px;
  min-width:0;
  width:100%;
  padding:5px 0;
  border-radius:9px;
  font-family:var(--mono);
  font-weight:800;
  font-size:11px;
  line-height:1;
}
.numBtn.active{
  border-color:rgba(244,197,66,.45);
  background:rgba(244,197,66,.22);
}
.numBtn:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.bonusRow{
  display:grid;
  grid-template-columns: 1.45fr 1fr;
  gap:6px;
  align-items:end;
}
.roundActions{
  margin-top:10px;
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
}
.roundActions #btnRoundAction{
  width:100%;
}
.toggleBtn{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.pos{color:var(--good); font-weight:800;}
.neg{color:var(--bad); font-weight:800;}

/* History */
.histWrap{
  overflow-x:auto;
  overflow-y:auto;
  margin-top:14px;
}
table{
  width:max-content;
  min-width:100%;
  border-collapse:separate;
  border-spacing:0;
  border:1px solid var(--line);
  border-radius:var(--r);
  overflow:hidden;
  background:rgba(0,0,0,.18);
}
th,td{
  padding:10px 10px;
  border-bottom:1px solid rgba(255,255,255,.06);
  text-align:left;
  vertical-align:top;
  white-space:nowrap;
}
th:first-child, td:first-child{
  min-width:72px;
}
th:not(:first-child), td:not(:first-child){
  min-width:120px;
}
th{
  font-size:12px;
  color:var(--muted);
  background:rgba(0,0,0,.22);
  position:sticky; top:0; z-index:2;
  white-space:nowrap;
}
tr:last-child td{border-bottom:none;}
.right{text-align:right;}
.cellPts{font-family:var(--mono); font-weight:800;}
.cellTot{font-family:var(--mono); font-size:11.5px; color:var(--muted); margin-top:2px; white-space:nowrap;}

/* Layout spacing inside game view */
#gameScreen{
  display:grid;
  gap:10px;
}

/* Desktop enhancements */
@media (min-width: 900px){
  .wrap{padding:14px 14px 22px;}
  .card{padding:12px;}
  .entryRow{padding:8px 10px;}
  .inputs{gap:8px;}
  .numBtn{min-height:30px; font-size:12px;}
  .actionRow button{padding:9px 11px; font-size:14px;}
}

.modalOverlay{
  position:fixed;
  inset:0;
  z-index:30;
  background:rgba(4,7,12,.92);
  backdrop-filter:blur(8px);
}
.modalPage{
  height:100dvh;
  width:100%;
  display:grid;
  grid-template-rows:auto 1fr;
  padding:12px;
  padding-left:max(12px, env(safe-area-inset-left));
  padding-right:max(12px, env(safe-area-inset-right));
  gap:10px;
}
.modalHead{
  border:1px solid var(--line);
  border-radius:var(--r);
  background:rgba(0,0,0,.24);
  padding:10px 12px;
}
.modalBody{
  min-height:0;
  border:1px solid var(--line);
  border-radius:var(--r);
  background:rgba(0,0,0,.22);
  padding:10px;
  display:grid;
  grid-template-rows:auto minmax(0, 1fr);
  gap:10px;
}
.modalBody .histWrap{
  height:100%;
  margin-top:0;
}
.histTabs{
  display:flex;
  gap:8px;
}
.tabBtn{
  flex:1 1 0;
  padding:8px 10px;
  border-radius:10px;
  font-family:var(--mono);
  font-size:12px;
  font-weight:800;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  color:var(--muted);
}
.tabBtn.active{
  color:var(--text);
  border-color:rgba(244,197,66,.35);
  background:rgba(244,197,66,.18);
}
.tabPanel{
  min-height:0;
}
#tabPanelHistory{
  display:grid;
  min-height:0;
}
#tabPanelGraph{
  display:grid;
  min-height:0;
}
.graphWrap{
  border:1px solid var(--line);
  border-radius:12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0)),
    rgba(0,0,0,.18);
  overflow:hidden;
  min-height:0;
  height:100%;
}
#histGraphCanvas{
  display:block;
  width:100%;
  height:100%;
}
.archiveGamesList{
  display:grid;
  gap:10px;
  min-height:0;
  overflow-y:auto;
  padding-right:2px;
}
.archiveGameCard{
  border:1px solid var(--line);
  border-radius:12px;
  background:rgba(0,0,0,.18);
  padding:8px 10px;
}
.archiveGameSummary{
  cursor:pointer;
  list-style:none;
  display:grid;
  gap:4px;
}
.archiveGameSummary::-webkit-details-marker{display:none;}
.archiveGameSummaryTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.archiveGameTitle{
  font-family:var(--mono);
  font-weight:800;
  font-size:12.5px;
}
.archiveGameMeta{
  font-size:11.5px;
  color:var(--muted);
  font-family:var(--mono);
}
.archiveGameDetail{
  margin-top:8px;
  display:grid;
  gap:8px;
}
.archiveStatsLine{
  font-size:12px;
  color:var(--muted);
}
.statsFilterRow{
  margin-top:4px;
  margin-bottom:2px;
}
#tabPanelArchiveStats{
  display:grid;
  grid-template-rows:auto minmax(180px, auto) minmax(0, 1fr);
  gap:10px;
  min-height:0;
}
.statsCharts{
  min-height:0;
  overflow-y:auto;
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
}
.statsChartCard{
  border:1px solid var(--line);
  border-radius:12px;
  background:rgba(0,0,0,.18);
  padding:8px;
  min-height:210px;
  height:210px;
}
.statsChartCard canvas{
  width:100%;
  height:100%;
  display:block;
}
@media (min-width: 900px){
  .statsCharts{
    grid-template-columns:1fr 1fr;
  }
  .statsChartCard{
    min-height:240px;
    height:240px;
  }
}
body.modalOpen{
  overflow:hidden;
}
.hidden{display:none !important;}
