/* The game page, the lobby and the sign-in page. Desktop first (design.md, "The game screen"). */
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #222; background: #f4f1ea; }
button { font: inherit; padding: 4px 10px; border: 1px solid #888; border-radius: 4px; background: #fff; cursor: pointer; }
button:hover { background: #eee; }
button.primary { background: #2f5d8a; border-color: #2f5d8a; color: #fff; }
button.primary:hover { background: #244a6f; }
button.link { border: none; background: none; padding: 0; color: #244a6f; text-align: left; }
button.link:hover { text-decoration: underline; background: none; }
.swatch { display: inline-block; width: 0.9em; height: 0.9em; border: 1px solid #555; border-radius: 2px; vertical-align: -0.1em; }
.hint { color: #666; }
.error { color: #b22; }

/* ---------- development page ---------- */
body.dev { max-width: 760px; margin: 2em auto; padding: 0 1em; }
.start { display: flex; flex-wrap: wrap; gap: 0.8em; align-items: end; }
.start label { display: flex; flex-direction: column; gap: 2px; }
.start select, .start input { font: inherit; padding: 3px; }
.games li { margin: 0.3em 0; }

/* ---------- game page ---------- */
body.game { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 1.2em; padding: 6px 12px; background: #2b2b2b; color: #eee; }
.topbar .home { color: #eee; text-decoration: none; font-weight: 600; }
.topbar .date { font-variant-numeric: tabular-nums; min-width: 12em; }
.topbar .pause { min-width: 6.5em; }
.topbar .pause.paused { background: #f2d58c; border-color: #f2d58c; }
.topbar .treasury { margin-left: auto; color: #ccc; }
.topbar .treasury.bad { color: #ff9b9b; }
.board { flex: 1; display: flex; min-height: 0; }
.mapbox { flex: 1; position: relative; min-width: 0; background: #99d9ea; }
.map, .map svg { width: 100%; height: 100%; display: block; }
.map svg { touch-action: none; user-select: none; cursor: default; }
.map svg.dragging { cursor: grabbing; }
.map #labels, .map #mountains, .map #rivers, .map #routes, .map #sea-zones, .map #edges, .map #landmass, .map .abbr { pointer-events: none; }
/* a settlement's name, zoomed in only (mapview.js); a click on it picks the settlement */
.map svg.zoomed .name { display: inline; }
.map [id^="settlement-"], .map [id^="pass-"], .map .lc-army { cursor: pointer; }
.zoom { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 32px; height: 32px; padding: 0; font-size: 18px; }
.toasts { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: rgba(40, 40, 40, 0.9); color: #fff; padding: 6px 12px; border-radius: 4px; max-width: 520px; }
.side { width: 340px; display: flex; flex-direction: column; border-left: 1px solid #bbb; background: #fbfaf6; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid #ccc; }
.tabs button { flex: 1; border: none; border-radius: 0; background: #ece8dd; padding: 6px 4px; border-right: 1px solid #ccc; }
.tabs button.active { background: #fbfaf6; font-weight: 600; box-shadow: inset 0 -2px #2f5d8a; }
.panel { padding: 10px 12px; border-bottom: 1px solid #ddd; min-height: 9em; max-height: 58vh; overflow-y: auto; }
.panel h2 { font-size: 16px; margin: 0 0 6px; }
.panel p { margin: 4px 0; }
.panel .men { font-weight: 600; }
.panel .siege { color: #a33; }
.panel .buttons, .panel .plan { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.panel .plan p { width: 100%; }
.panel .armies { list-style: none; padding: 0; margin: 6px 0; }
.panel .split { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.panel .split input { width: 6em; }
.side h3 { margin: 8px 12px 4px; font-size: 13px; text-transform: uppercase; color: #666; }
.events { list-style: none; margin: 0; padding: 0 12px 12px; overflow-y: auto; flex: 1; font-size: 13px; }
.events li { padding: 3px 0; border-bottom: 1px solid #eee; cursor: pointer; }
.events .when { color: #888; font-variant-numeric: tabular-nums; }

/* ---------- on the map ---------- */
.lc-army rect { stroke: #333; stroke-width: 1; }
.lc-army text { font: bold 9px system-ui, sans-serif; text-anchor: middle; fill: #111; pointer-events: none; }
.lc-army.mine rect { stroke: #000; stroke-width: 1.8; }
.lc-army.selected rect { stroke: #ffd400; stroke-width: 3; }
.lc-army.retreating { opacity: 0.6; }
.lc-army.retreating rect { stroke-dasharray: 2 2; }
.lc-siege-track { fill: none; stroke: rgba(0, 0, 0, 0.15); stroke-width: 3; pointer-events: none; }
.lc-siege { fill: none; stroke: #c9161f; stroke-width: 3; pointer-events: none; }
.lc-route { fill: none; stroke: #222; stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }

/* ---------- the country panels ---------- */
.panel .block { margin: 0 0 12px; }
.panel .block h3 { margin: 0 0 4px; font-size: 13px; text-transform: uppercase; color: #666; }
.panel .kv { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.panel .kv.good b { color: #276b2c; }
.panel .kv.bad b, .panel .bad { color: #b22; }
.panel .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; }
.panel .row label { min-width: 5.5em; }
.panel .row input[type=range] { flex: 1; min-width: 8em; }
.panel input[type=number] { width: 6.5em; }
.panel select { max-width: 100%; }
.panel .w { flex: 1; min-width: 9em; }
.panel .owned { color: #276b2c; padding: 2px 6px; }
.panel button.danger { border-color: #b22; color: #b22; }
.panel .buttons.vertical { flex-direction: column; align-items: flex-start; }
.panel details { margin-top: 8px; }
.panel details summary { cursor: pointer; color: #244a6f; }
.panel .queue { margin: 0; padding-left: 18px; }
.panel .tech { border: 1px solid #ddd; border-radius: 4px; padding: 5px 8px; margin: 5px 0; background: #fff; }
.panel .tech.done { background: #eef5ee; }
.panel .tech.target { border-color: #2f5d8a; }
.panel .tech .row { justify-content: space-between; }
.panel .bar { height: 6px; background: #ddd; border-radius: 3px; margin: 4px 0; }
.panel .bar i { display: block; height: 100%; background: #2f5d8a; border-radius: 3px; }

/* ---------- fleets and posts on the map ---------- */
.lc-fleet rect { stroke: #234; stroke-width: 1; }
.lc-fleet text { font: bold 9px system-ui, sans-serif; text-anchor: middle; fill: #111; pointer-events: none; }
.lc-fleet.mine rect { stroke: #000; stroke-width: 1.8; }
.lc-fleet.selected rect { stroke: #ffd400; stroke-width: 3; }
.lc-fleet.sailing { opacity: 0.7; }
.map .lc-fleet { cursor: pointer; }
.lc-post { font: bold 9px system-ui, sans-serif; pointer-events: none; paint-order: stroke; stroke: #fff; stroke-width: 2px; }

/* ---------- diplomacy ---------- */
.panel .offer { border: 1px solid #2f5d8a; border-radius: 4px; padding: 6px 8px; margin: 6px 0; background: #eef3f9; }
.panel .hint.good { color: #276b2c; }
.panel .preview { margin: 6px 0; font-weight: 600; }
.panel .preview.good { color: #276b2c; }
.panel .preview.bad { color: #b22; }
.panel .checks { display: flex; flex-direction: column; gap: 2px; max-height: 12em; overflow-y: auto; padding: 4px 0; }
.panel label.check { display: block; }
.tabs button { padding: 6px 2px; font-size: 13px; }

/* ---------- the lobby and the sign-in page ---------- */
.lobbybar { display: flex; align-items: baseline; justify-content: space-between; }
.lobbybar .who { color: #666; }
body.lobby section { margin: 1.4em 0; }
.tables, .games { list-style: none; padding: 0; }
.tables .table { border: 1px solid #ccc; border-radius: 4px; padding: 8px 10px; margin: 8px 0; background: #fbfaf6; }
.tables .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
button.danger { border-color: #b22; color: #b22; }

/* ---------- people in a game ---------- */
.topbar .setup { background: #f2d58c; color: #222; padding: 2px 8px; border-radius: 4px; }
.topbar .people { display: flex; gap: 0.9em; color: #ccc; }
.topbar .person.present { color: #cfe8cf; }
.topbar .person.away, .topbar .person.full { color: #f2d58c; }
.topbar .person.quit { color: #999; text-decoration: line-through; }
.topbar .chat-toggle, .topbar .quit { padding: 2px 8px; }
.chat { position: absolute; left: 10px; bottom: 56px; width: 320px; max-width: 60%; background: rgba(251, 250, 246, 0.96); border: 1px solid #999; border-radius: 4px; display: flex; flex-direction: column; }
.chat-log { list-style: none; margin: 0; padding: 6px 8px; max-height: 14em; overflow-y: auto; font-size: 13px; }
.chat-log li { padding: 1px 0; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 4px; padding: 4px; border-top: 1px solid #ccc; }
.chat-form input { flex: 1; min-width: 0; font: inherit; padding: 3px; }
[hidden] { display: none !important; }

/* ---------- replay, leaderboard, legal pages ---------- */
.topbar .seek { flex: 1; min-width: 8em; }
.topbar .verdict { font-size: 13px; }
.topbar .verdict.good { color: #cfe8cf; }
.topbar .verdict.bad { color: #ffb4b4; }
.topbar label { display: flex; align-items: center; gap: 4px; color: #ccc; }
.standing { list-style: none; margin: 0; padding: 0 12px 6px; font-size: 13px; counter-reset: rank; }
.standing li { padding: 1px 0; }
.standing li.person { font-weight: 600; }
.board-table { border-collapse: collapse; width: 100%; }
.board-table th, .board-table td { text-align: left; padding: 4px 10px; border-bottom: 1px solid #ddd; }
body.legal { max-width: 760px; margin: 2em auto; padding: 0 1em; }
.legal-page h2 { margin-top: 1.4em; font-size: 17px; }
