/* Population Circles: game layer on top of the visualizer. */

/* Anything that would give the headcount away is hidden in the game. */
.game #stats, .game .heap, .game #labels, .game #results i { display: none; }
/* Explore can show city names (never their populations). */
.game:not(.exploring) .explore-only { display: none; }
.game.exploring.cityNames #labels, .game.roomCities:not(.exploring) #labels { display: block; }
.game #labels .lbl small { display: none; }

#overlay { position: fixed; inset: 0; pointer-events: none; }

kbd { font: 11px ui-monospace, monospace; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 3px; padding: 0 4px; margin-left: 4px; color: #cfc9bb; }

.game button.primary { background: #f0b46a; color: #1a1408; border-color: #f0b46a; font-weight: 600; }
.game button.primary:hover { background: #f5c486; }
.game button:disabled { opacity: 0.45; cursor: default; }
.game button.on { background: #f0b46a33; border-color: #f0b46a; color: #f5d2a2; }

.card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(480px, calc(100vw - 32px));
  background: rgba(14, 16, 20, 0.94); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 20px 22px;
  backdrop-filter: blur(8px); box-shadow: 0 10px 40px rgba(0,0,0,0.5); font-size: 14px; }
.card h2 { margin: 0 0 10px; font-size: 20px; }
.card p { color: #c9c5bb; margin: 8px 0; }
.card button { width: 100%; padding: 8px 0; margin-top: 12px; font-size: 14px; }
.card.small { top: auto; bottom: 24px; transform: translateX(-50%); width: min(440px, calc(100vw - 32px)); }
.card .big { font-size: 30px; font-weight: 700; color: #f5d2a2; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.card .big small { font-size: 14px; font-weight: 400; color: #9a988f; }
.card .muted { color: #9a988f; margin-top: 6px; }
.card .ideal { color: #8fe0a0; font-weight: 600; }
.card table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.card th, .card td { text-align: left; padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.card th { color: #9a988f; font-weight: 500; }
.card td:last-child, .card th:last-child, .card td:nth-child(n+3), .card th:nth-child(n+3) { text-align: right; }

#hud { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); text-align: center; pointer-events: none;
  background: rgba(14, 16, 20, 0.86); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 8px 18px;
  min-width: 320px; }
#roundNo { color: #9a988f; font-size: 12px; }
#challenge { font-size: 18px; margin: 2px 0 4px; }
#challenge b { color: #f5d2a2; }
.hudRow { display: flex; justify-content: center; gap: 18px; color: #b9b6ad; font-variant-numeric: tabular-nums; }
#timer { font-weight: 600; color: #e8e6e1; }
#timer.low { color: #ff7a6a; }

#tools { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  background: rgba(14, 16, 20, 0.86); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 8px 10px; }
#tools button { flex: none; padding: 6px 14px; }
#readout { min-width: 230px; text-align: center; color: #c9c5bb; font-variant-numeric: tabular-nums; }
#readout b { color: #fff; }
#readout .muted { color: #8d8a82; }
#tools.explore { width: max-content; max-width: calc(100vw - 24px); box-sizing: border-box; flex-wrap: wrap; justify-content: center; }
#tools.explore #readout { min-width: 300px; line-height: 1.35; }
.palette { display: flex; align-items: center; gap: 4px; }
#tools .fold { width: 26px; height: 32px; padding: 0; font-size: 13px; color: #9a988f; }
#tools.collapsed { padding: 3px; gap: 0; }
#tools.collapsed > :not(.fold) { display: none !important; }
#tools.collapsed .fold { width: auto; height: 26px; padding: 0 10px; font-size: 12px; color: #c9c5bb; }
#tools .palette button { width: 34px; height: 32px; padding: 0; font-size: 17px; line-height: 1; }
.palette select { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); color: #e8e6e1;
  border-radius: 6px; padding: 5px 6px; font: inherit; font-size: 13px; margin-left: 4px; }
.card button.explore { background: rgba(110,198,255,0.1); border-color: rgba(110,198,255,0.45); color: #cfe9ff; }
/* Menu: Explore sits top right (where a close button would be); Solo and Multiplayer are sections. */
.introHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.introHead h2 { margin: 0; }
/* The title is set in Fraunces Bold (SIL OFL, fonts/Fraunces-OFL.txt), subset to just "Capita Count". */
@font-face { font-family: 'Fraunces Title'; src: url('fonts/fraunces-title.woff2') format('woff2'); font-weight: 700; font-display: swap; }
.card .introHead h2 { font-family: 'Fraunces Title', Georgia, serif; font-weight: 700; font-size: 28px; letter-spacing: 0.005em; color: #f2efe6; }
.card .introHead button.explore { flex: none; width: auto; margin: 0; padding: 5px 14px; font-size: 13px; }
.introSec { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.introSec h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #9a988f; }
.introSec > button { margin-top: 8px; }
.introSec > .field { margin-top: 8px; }
.card .opts { margin-top: 8px; color: #b9b6ad; font-size: 13px; }
.card .opts summary { cursor: pointer; color: #c9c5bb; }
.card .opts summary .muted { margin-left: 4px; font-size: 12px; }
.card .opts[open] summary .muted { display: none; }
.card .opts .field { margin-top: 8px; }
.card button.explore:hover { background: rgba(110,198,255,0.18); }

/* Dropdowns: a dark list, so the options are readable (the light text was on the browser's white list). */
.game select { color-scheme: dark; }
.game select option { background: #1b1e24; color: #e8e6e1; }
.game select option:checked { background: #3a3324; color: #f5d2a2; }

.card .intro-opt { margin: 10px 0 4px; color: #e8e6e1; font-size: 14px; flex-wrap: wrap; }
.card .intro-opt .muted { margin: 0; font-size: 12px; width: 100%; padding-left: 22px; }

/* Settings panel: collapsible, collapsed by default in the game. */
.game #panel { width: auto; min-width: 0; padding: 6px; }
.game #panel.open { width: 300px; padding: 8px 14px 12px; }
.game #panel:not(.open) #panelBody { display: none; }
.panel-toggle { display: flex; align-items: center; gap: 6px; width: 100%; background: transparent; border: none;
  color: #e8e6e1; font-weight: 600; padding: 2px 6px; }
.panel-toggle:hover { background: rgba(255,255,255,0.06); }
.game #panel.open .panel-toggle { margin-bottom: 6px; padding: 2px 0; justify-content: space-between; }
.panel-toggle .chev { color: #9a988f; transition: transform 0.15s; }
.game #panel.open .panel-toggle .chev { transform: rotate(180deg); }

.quit { position: fixed; left: 52px; top: 12px; height: 34px; padding: 0 12px; font-size: 13px;
  background: rgba(14, 16, 20, 0.86); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; }
.mute { position: fixed; left: 12px; top: 12px; width: 34px; height: 34px; padding: 0; font-size: 16px; line-height: 1;
  background: rgba(14, 16, 20, 0.86); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; }

#hintBtn { color: #f5d2a2; }
.hintTag { font-size: 11px; color: #1a1408; background: #f0b46a; border-radius: 3px; padding: 0 4px; margin-left: 4px; }
.game input:disabled + * , .game label:has(input:disabled) { opacity: 0.6; }

/* Result callout, pinned next to the player's circle on the globe. */
.callout { position: fixed; width: 270px; z-index: 3; font-size: 13px;
  background: rgba(14, 16, 20, 0.92); border: 1px solid rgba(255,255,255,0.1); border-left: 3px solid #ffb050;
  border-radius: 10px; padding: 12px 14px; backdrop-filter: blur(6px); box-shadow: 0 8px 30px rgba(0,0,0,0.45); }
.callout.docked { left: 50%; bottom: 24px; transform: translateX(-50%); }
.callout .counting { color: #b9b6ad; }
.callout .tally { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; line-height: 1.1; }
.callout .tally small { font-size: 12px; font-weight: 400; color: #9a988f; }
.callout .bar { position: relative; height: 6px; margin: 8px 0 3px; background: rgba(255,255,255,0.08); border-radius: 3px; }
.callout .bar i { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #8fe0a0; }
#tallyFill { height: 100%; width: 0; background: #ffb050; border-radius: 3px; }
#tallyFill.over { background: #ff8a5c; }
.callout .tallyTarget { display: flex; justify-content: space-between; font-size: 11px; color: #8d8a82; }
.callout .tallyTarget span:nth-child(2) { color: #8fe0a0; }
.callout .bar.most i { display: none; }   /* most people: the bar fills to the best spot, no target mark */
.callout .off { margin-top: 10px; font-weight: 600; }
.callout .pts { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.callout .pts small { font-size: 12px; font-weight: 400; color: #9a988f; }
.callout .great { color: #8fe0a0; } .callout .good { color: #f5d2a2; } .callout .ok { color: #f0b46a; } .callout .poor { color: #ff8a6a; }
.callout .muted { color: #9a988f; margin-top: 6px; font-size: 12px; }
.callout .ideal { color: #8fe0a0; font-weight: 600; }
.callout button { width: 100%; margin-top: 10px; padding: 6px 0; }
/* The result's details keep their space while the tally counts, so the box doesn't grow. */
.callout .pending { visibility: hidden; }

/* Intro / lobby */
.card .field.inline { flex-direction: row; align-items: center; justify-content: space-between; font-size: 13px; }
.card .field { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 4px; color: #b9b6ad; font-size: 12px; }
.card input[type=text], .card select { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14);
  color: #e8e6e1; border-radius: 6px; padding: 7px 9px; font: inherit; font-size: 14px; }
.card select { padding: 4px 6px; font-size: 13px; }
.btnRow { display: flex; gap: 8px; }
.btnRow button { flex: 1; }
.btnRow.join { margin-top: 8px; align-items: stretch; }
.btnRow.join input { flex: 1; text-transform: uppercase; letter-spacing: 0.2em; font-weight: 600; margin-top: 12px; }
.card .err { color: #ff8a6a; margin-top: 8px; font-size: 13px; }
.card .howto { margin-top: 10px; color: #b9b6ad; }
.card .howto summary { cursor: pointer; color: #e8e6e1; }
.card h2 .code { letter-spacing: 0.15em; color: #f5d2a2; }
.share { display: flex; gap: 8px; }
.share input { flex: 1; min-width: 0; font-size: 12px !important; color: #b9b6ad !important; }
.share button { width: auto !important; margin: 0 !important; padding: 0 12px !important; flex: none; }
.plist { list-style: none; padding: 0; margin: 12px 0; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.plist .tag { font-size: 11px; color: #9a988f; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 8px 0; font-size: 13px; color: #b9b6ad; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.settings label.check { grid-column: 1 / -1; justify-content: flex-start; }
.settings.readonly select, .settings.readonly input { pointer-events: none; opacity: 0.7; }

/* Players strip during a game */
#players { position: fixed; left: 12px; top: 56px; display: flex; flex-direction: column; gap: 4px; pointer-events: none;
  font-size: 13px; }
#players .p { display: flex; align-items: center; gap: 7px; background: rgba(14, 16, 20, 0.82); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 7px; padding: 4px 9px; min-width: 150px; }
#players .p .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
#players .p .s { color: #9a988f; font-variant-numeric: tabular-nums; font-size: 12px; }
#players .p.off { opacity: 0.45; }
#players .p .st { width: 14px; text-align: center; color: #8fe0a0; }
#players .p.me { border-color: rgba(240,180,106,0.4); }

#toast { position: fixed; left: 50%; top: 110px; transform: translateX(-50%); background: rgba(60, 20, 14, 0.92);
  border: 1px solid #ff8a6a66; color: #ffd0c4; padding: 6px 14px; border-radius: 8px; font-size: 13px; z-index: 5; }

/* Round summary (multiplayer) */
.card.side { left: auto; right: 16px; top: 50%; transform: translateY(-50%); width: min(380px, calc(100vw - 32px)); padding: 14px 16px; }
.card.side h3 { margin: 0 0 6px; font-size: 16px; }
.card table td .dot { margin-right: 6px; vertical-align: -1px; }
.card tr.me td { color: #f5d2a2; }
.card td.muted { color: #8d8a82; }
/* replay (admin) */
#replay { top: 16px; transform: none; max-height: calc(100dvh - 32px); overflow-y: auto; }
#replay .rpTop { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#replay .rpTop h3 { margin: 0; }
#replay button { width: auto; flex: none; margin: 0; padding: 4px 10px; }
#replay .rpNav { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; font-weight: 600; }
#replay .rpNav span { flex: 1; text-align: center; font-size: 13px; }
#replay .rpCh { font-size: 14px; color: #e8e6e1; margin: 4px 0 2px; }
#replay tbody tr { cursor: pointer; }
#replay tbody tr.sel { background: rgba(255, 255, 255, 0.08); }
#replay td button { font-size: 12px; padding: 2px 8px; }
#replay .rpBtns { display: flex; gap: 8px; margin-top: 10px; }
#replay .rpBtns button { flex: 1; }
#replay #rpInfo { font-size: 12.5px; line-height: 1.4; }

.callout .who { display: flex; align-items: center; gap: 7px; font-weight: 600; margin-bottom: 6px; color: #e8e6e1; }
.callout .area { margin-top: 6px; color: #c9c5bb; }

[hidden] { display: none !important; }

/* ---------- touch screens and phones */
.game button, .game select, .game input { touch-action: manipulation; }
.card { max-height: calc(100dvh - 24px); overflow-y: auto; box-sizing: border-box; }
#tools { bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (pointer: coarse) {
  .game kbd { display: none; }
  #tools button { min-height: 38px; }
  #tools .palette button { width: 38px; height: 38px; }
}
@media (max-width: 640px) {
  #hud { top: 54px; min-width: 0; width: calc(100vw - 24px); box-sizing: border-box; padding: 6px 10px; }
  #challenge { font-size: 15px; }
  #tools, #tools.explore { bottom: calc(10px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 16px);
    box-sizing: border-box; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 6px; }
  #tools #readout, #tools.explore #readout { order: -1; flex-basis: 100%; min-width: 0; font-size: 13px; }
  #tools .palette { flex-wrap: wrap; justify-content: center; }
  #tools.collapsed { padding: 3px; }
  #players { top: auto; bottom: calc(130px + env(safe-area-inset-bottom)); font-size: 12px; }
  #players .p { min-width: 0; padding: 3px 7px; }
  #toast { top: 130px; max-width: calc(100vw - 32px); }
  .callout { width: min(270px, calc(100vw - 24px)); box-sizing: border-box; }
  .card { padding: 16px; }
  .card input[type=text], .card select { font-size: 16px; }   /* iOS zooms into smaller inputs */
  .card.side { right: 8px; width: calc(100vw - 16px); top: auto; bottom: 10px; transform: none; max-height: 55dvh; }
}
@media (max-width: 640px) {
  #replay { top: auto; bottom: 10px; max-height: 45dvh; }
}
