/* Conquest '95 — Windows 95 era chrome */
:root {
  --face: #c0c0c0; --hi: #ffffff; --lo: #808080; --dk: #000000;
  --title1: #000080; --title2: #1084d0; --desk: #008080;
  --ocean: #1b4e86; --ocean-line: #2a5f98;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--desk);
  font: 12px/1.35 Tahoma, "MS Sans Serif", Geneva, Verdana, sans-serif;
  color: #000; -webkit-font-smoothing: none;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, select, input { font: inherit; }
/* phones/tablets: no double-tap zoom (pinch still works), no text selection from fast taps,
   and 16px text boxes so iPhones don't zoom in when one is tapped */
html, body, button, a, input, select, label, svg, path { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, svg { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) { input[type=text], input[type=number], select { font-size: 16px; } }

.window {
  background: var(--face); padding: 3px;
  border: 1px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi);
  box-shadow: inset 1px 1px 0 #dfdfdf, inset -1px -1px 0 var(--lo);
}
.main { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100vh - 20px); }
.titlebar {
  background: linear-gradient(90deg, var(--title1), var(--title2));
  color: #fff; font-weight: bold; padding: 3px 4px; display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.title-icon { width: 14px; height: 14px; background: conic-gradient(#c81e1e 0 25%, #d9b100 0 50%, #1c8c2a 0 75%, #1f45c8 0); border: 1px solid #000; }
.tb-buttons { margin-left: auto; display: flex; gap: 2px; }
.tb-buttons b {
  width: 16px; height: 14px; line-height: 11px; text-align: center; color: #000; background: var(--face); font-size: 11px;
  border: 1px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); cursor: default;
}
.tb-buttons b[data-close] { cursor: pointer; }
.menubar { display: flex; align-items: center; gap: 2px; padding: 2px 0; flex-wrap: wrap; }
.menubar button { background: none; border: 1px solid transparent; padding: 2px 8px; cursor: pointer; }
.menubar button:hover { border-color: var(--hi) var(--lo) var(--lo) var(--hi); }
.menubar .menu-link { color: inherit; text-decoration: none; border: 1px solid transparent; padding: 2px 8px; white-space: nowrap; }
.menubar .menu-link:hover { border-color: var(--hi) var(--lo) var(--lo) var(--hi); }
.speed { margin-left: auto; display: flex; gap: 6px; align-items: center; padding-right: 4px; }

.bevel-in {
  border: 1px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo);
  box-shadow: inset 1px 1px 0 var(--dk), inset -1px -1px 0 #dfdfdf;
}
.btn {
  background: var(--face); padding: 4px 10px; min-width: 70px; cursor: pointer;
  border: 1px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi);
  box-shadow: inset 1px 1px 0 #dfdfdf, inset -1px -1px 0 var(--lo);
}
.btn:active:not(:disabled) { border-color: var(--dk) var(--hi) var(--hi) var(--dk); box-shadow: inset 1px 1px 0 var(--lo); }
.btn:disabled { color: var(--lo); text-shadow: 1px 1px 0 var(--hi); cursor: default; }
.btn.primary { outline: 1px solid #000; outline-offset: -5px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }

.body { display: flex; gap: 6px; flex: 1; min-height: 0; }
.mapwrap { flex: 1; background: var(--ocean); padding: 2px; min-width: 0; display: flex; align-items: center; }
#map { width: 100%; height: auto; display: block; touch-action: manipulation; }
.side { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
fieldset { border: 1px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); box-shadow: 1px 1px 0 var(--hi) inset; margin: 0; padding: 4px 6px 6px; }
legend { padding: 0 3px; }
.logbox { flex: 1; display: flex; flex-direction: column; min-height: 120px; }
#log { background: #fff; flex: 1; overflow-y: auto; padding: 3px 4px; max-height: 260px; min-height: 100px; }
#log div { padding: 1px 0; }
#log i { display: inline-block; width: 8px; height: 8px; border: 1px solid #000; margin-right: 4px; vertical-align: 0; }

.statusbar { display: flex; gap: 3px; margin-top: 4px; }
.statusbar span { padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status { flex: 1; }

/* players table */
#players { width: 100%; border-collapse: collapse; }
#players td { padding: 2px 3px; white-space: nowrap; }
#players tr.cur td { background: var(--title1); color: #fff; }
#players tr.dead td { color: var(--lo); text-decoration: line-through; }
#players .sw { width: 12px; height: 12px; border: 1px solid #000; display: inline-block; vertical-align: -2px; }
#players th { font-weight: normal; color: #333; text-align: left; padding: 0 3px; font-size: 11px; }
#players td.n { text-align: right; }

/* orders */
#orders p { margin: 0 0 4px; }
#orders .big { font-size: 15px; font-weight: bold; }
.seg { display: inline-flex; }
.seg .btn { min-width: 0; padding: 3px 8px; }
.seg .btn.on { border-color: var(--dk) var(--hi) var(--hi) var(--dk); box-shadow: inset 1px 1px 0 var(--lo); background: #d4d0c8 repeating-conic-gradient(#fff 0 25%, var(--face) 0 50%) 0 0/2px 2px; }
input[type=range] { width: 100%; }

/* dice */
.dice { display: flex; gap: 10px; min-height: 40px; align-items: center; flex-wrap: wrap; }
.dice .side-lbl { font-size: 11px; color: #333; width: 100%; }
.dice .grp { display: flex; gap: 4px; }
.die {
  width: 30px; height: 30px; border: 1px solid #000; border-radius: 4px; display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 3px; box-shadow: 2px 2px 0 rgba(0,0,0,.35);
}
.die.att { background: #c81e1e; } .die.att i { background: #fff; }
.die.def { background: #f4f4f4; } .die.def i { background: #000; }
.die i { width: 6px; height: 6px; border-radius: 50%; place-self: center; visibility: hidden; }
.die i.on { visibility: visible; }
.die.lost { opacity: .45; }
.vs { font-weight: bold; }

/* cards */
#cards .hand { display: flex; flex-wrap: wrap; gap: 4px; }
.card {
  width: 60px; height: 78px; background: #fffbe6; border: 1px solid #000; padding: 3px; font-size: 10px;
  display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; text-align: center;
  box-shadow: 1px 1px 0 #000;
}
.card.sel { outline: 2px dashed var(--title1); outline-offset: 1px; background: #e6ecff; }
.card .ico { font-size: 22px; line-height: 1; font-family: Georgia, serif; }
.card .ty { font-weight: bold; text-transform: uppercase; font-size: 9px; }
.card.mine .nm { font-weight: bold; }
.muted { color: #555; }

/* map */
.terr { stroke: none; transition: fill .25s; }
.tedge { fill: none; stroke: #111; stroke-width: .8; stroke-linejoin: round; pointer-events: none; }
.terr.click { cursor: pointer; }
.terr.click:hover, .terr.hover { filter: brightness(1.25); }
.tedge.src { stroke: #fff700; stroke-width: 3; }
.tedge.tgt { stroke: #fff; stroke-width: 2; stroke-dasharray: 4 3; animation: march .6s linear infinite; }
.tedge.tgtsel { stroke: #ff3b3b; stroke-width: 3.2; stroke-dasharray: none; animation: none; }
.terr.dim { filter: brightness(.78) saturate(.8); }
@keyframes march { to { stroke-dashoffset: -14; } }
.lane { stroke: #d8e6f5; stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .8; }
.grid { stroke: var(--ocean-line); stroke-width: 1; }
.cont-label { fill: #c9dcf0; font: bold 11px Tahoma, sans-serif; letter-spacing: 1px; opacity: .85; pointer-events: none; }
.lbl { pointer-events: none; }
.lbl circle { fill: #fff; stroke-width: 2; }
.lbl text { font: bold 11px Tahoma, sans-serif; text-anchor: middle; dominant-baseline: central; fill: #000; }
.lbl.flash circle { animation: flash .7s ease-out; }
@keyframes flash { 0% { fill: #ffe14d; r: 16; } 100% { fill: #fff; } }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 10px; }
.hidden { display: none !important; }
.dialog { width: 460px; max-width: 100%; max-height: calc(100vh - 20px); overflow: auto; }
.dialog-body { padding: 10px; }
.dialog-body table { width: 100%; border-collapse: collapse; }
.dialog-body td { padding: 3px; }
.dialog-body input[type=text] { width: 100%; padding: 2px 3px; border: 1px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); box-shadow: inset 1px 1px 0 #000; }
.dialog-body h4 { margin: 10px 0 4px; }
.dialog-body ul { margin: 4px 0; padding-left: 18px; }
.dialog-body .sw { width: 14px; height: 14px; border: 1px solid #000; display: inline-block; }
.dialog-body .actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 20;
  background: #ffffe1; border: 1px solid #000; padding: 6px 12px; box-shadow: 2px 2px 0 rgba(0,0,0,.4); max-width: 90vw;
}

@media (max-width: 900px) {
  body { padding-block: 0; }
  .main { min-height: 100vh; }
  .body { flex-direction: column; }
  .side { width: 100%; }
  .tb-buttons { display: none; }
  #log { max-height: 160px; }
}
@media (max-width: 900px) {
  .mapwrap { overflow-x: auto; display: block; }
  #map { min-width: 780px; }
  .side .orders { order: -2; }
  .side fieldset:has(#dice) { order: -1; }
}

/* zoom, lakes, capitals */
.zoom { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; }
.zoom #zoomlvl { min-width: 38px; text-align: center; font-variant-numeric: tabular-nums; }
.mapwrap { overflow: auto; }
.mapwrap.zoomed { display: block; }
.lake { fill: var(--ocean); stroke: #111; stroke-width: .8; pointer-events: none; }
.lbl .cap { stroke: #000; stroke-width: .9; stroke-linejoin: round; }
.mapwrap.zoomed { max-height: calc(100vh - 110px); }
@media (max-width: 900px) { .mapwrap.zoomed { max-height: 75vh; } }
