* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  background: #2b4a63;
  color: #1c2317;
}

#board {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  /* we handle pan/zoom ourselves; stop the browser from scrolling/zooming the
     page on touch so one-finger drag pans and two-finger pinch zooms the board */
  touch-action: none;
}
#board:active { cursor: grabbing; }

.hidden { display: none !important; }

/* overlays (setup, modals, scoreboard) */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 26, 38, 0.78);
  z-index: 20;
}
.panel {
  background: #f4efe2;
  border-radius: 14px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  min-width: 320px;
  max-width: 92vw;
}
.panel h1 { margin-bottom: 12px; color: #b03e14; }
.panel p { margin-bottom: 14px; color: #4a4234; }
.panel .hint { font-size: 12px; color: #8a8270; margin-top: 18px; margin-bottom: 0; }
.btnrow { display: flex; gap: 10px; justify-content: center; }
.btnrow.wrap { flex-wrap: wrap; margin-bottom: 12px; }
.btnrow button, #playAgain {
  font-size: 18px;
  padding: 11px 20px;
  border: none;
  border-radius: 8px;
  background: #b03e14;
  color: #fff;
  cursor: pointer;
}
.btnrow button:hover:not(:disabled), #playAgain:hover { background: #cf5323; }
.btnrow button:disabled { background: #b6ab95; cursor: default; }
#playAgain { margin-top: 18px; font-size: 16px; }
.ghostbtn { background: #b6ab95 !important; }
.ghostbtn:hover { background: #a3987f !important; }

/* resume-a-saved-game offer on the setup screen */
.resume { margin-bottom: 14px; padding: 12px 0 14px; border-bottom: 1px solid #d8d0bd; }
.resume > p { margin-bottom: 10px; font-size: 14px; font-weight: 700; color: #3a4a24; }
.resume .btnrow button { font-size: 15px; padding: 8px 18px; }
.resumeinfo { margin-top: 8px; font-size: 12px; color: #8a8270; }

/* vs-computer + online lobby */
.vsbot, .online { margin-top: 22px; padding-top: 16px; border-top: 1px solid #d8d0bd; }
.vsbot > p, .online > p { margin-bottom: 10px; font-size: 14px; color: #6a624f; }
.watchlabel { margin-top: 14px; }
.vsbot .btnrow button { font-size: 15px; padding: 9px 14px; }
.hostrow { display: flex; gap: 8px; align-items: center; justify-content: center; }
.hostrow label { font-size: 14px; color: #6a624f; }
.hostrow select {
  font-size: 16px; padding: 8px; border: 2px solid #c5bca5; border-radius: 8px;
  background: #fff; color: #3a3424; cursor: pointer;
}
#hostBtn, .joinrow button {
  font-size: 16px; padding: 8px 18px; border: none; border-radius: 8px;
  background: #b03e14; color: #fff; cursor: pointer;
}
#hostBtn:hover, .joinrow button:hover { background: #cf5323; }
.joinrow { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.joinrow input {
  width: 96px; font-size: 18px; letter-spacing: 4px; text-align: center;
  text-transform: uppercase; padding: 8px 10px; border: 2px solid #c5bca5;
  border-radius: 8px; background: #fff; color: #3a3424;
}
.netstatus { min-height: 18px; margin-top: 12px; font-size: 13px; color: #3a4a24; font-weight: 600; }
.netstatus.error { color: #b23; }
.you { font-size: 11px; font-weight: 700; color: #b03e14; }

/* in-game sidebar */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#sidebar {
  pointer-events: auto;
  position: absolute;
  top: 12px; left: 12px;
  width: 264px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: rgba(244, 239, 226, 0.96);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.4);
}
#sidebar h2 { color: #b03e14; margin-bottom: 4px; }
#sidebar h3 { margin: 10px 0 4px; font-size: 12px; color: #6a624f; text-transform: uppercase; letter-spacing: 0.05em; }
.status { font-size: 13px; font-weight: 600; color: #3a4a24; margin-bottom: 8px; min-height: 18px; }
.status.yourturn {
  color: #fff; background: #b03e14; padding: 6px 10px; border-radius: 6px;
  animation: yourturn-pulse 1.6s ease-out infinite;
}
@keyframes yourturn-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(176, 62, 20, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(176, 62, 20, 0); }
  100% { box-shadow: 0 0 0 0 rgba(176, 62, 20, 0); }
}
@media (prefers-reduced-motion: reduce) { .status.yourturn { animation: none; } }

.dicebar { display: flex; gap: 8px; align-items: center; }
.dice { font-size: 15px; font-weight: 700; min-width: 62px; color: #3a3424; }
.dicebar button, .buildrow button {
  font-size: 13px; padding: 7px 10px; border: none; border-radius: 6px;
  background: #b03e14; color: #fff; cursor: pointer; white-space: nowrap;
}
.dicebar button:disabled, .buildrow button:disabled { background: #b6ab95; cursor: default; }
.dicebar button:not(:disabled):hover, .buildrow button:not(:disabled):hover { background: #cf5323; }
.buildrow { display: flex; gap: 5px; flex-wrap: wrap; }
.buildrow button.active { outline: 3px solid #2b2317; }

/* hand of resource cards */
.hand { display: flex; gap: 5px; flex-wrap: wrap; min-height: 34px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 6px; padding: 5px 8px;
  color: #fff; font-size: 13px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);
  border: 1px solid rgba(0,0,0,0.3);
}
.devlist { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.devrow { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #3a3424; }
.devrow button {
  font-size: 11px; padding: 3px 9px; border: none; border-radius: 5px;
  background: #b03e14; color: #fff; cursor: pointer;
}
.devrow button:disabled { background: #b6ab95; cursor: default; }
.devrow button:not(:disabled):hover { background: #cf5323; }

/* trading */
.banktrade { display: flex; gap: 6px; align-items: center; }
.banktrade select {
  flex: 1; min-width: 0; font-size: 13px; padding: 5px 4px;
  border: 1px solid #c5bca5; border-radius: 6px; background: #fff;
}
.banktrade .rate { font-size: 12px; font-weight: 700; color: #6a624f; }
.banktrade button, .minor {
  font-size: 12px; padding: 6px 10px; border: none; border-radius: 6px;
  background: #b03e14; color: #fff; cursor: pointer;
}
.banktrade button:disabled { background: #b6ab95; cursor: default; }
.minor { margin-top: 6px; background: #8a7a58; }
.minor:hover { background: #9d8c66; }
.offerbox { margin-top: 6px; background: rgba(0,0,0,0.05); border-radius: 8px; padding: 8px; }
.offerhead, .offerrow { display: grid; grid-template-columns: 1fr 84px 84px; gap: 4px; align-items: center; }
.offerhead { font-size: 10px; text-transform: uppercase; color: #6a624f; margin-bottom: 4px; }
.offerhead span:not(:first-child), .stepper { text-align: center; }
.offerrow .rname { font-size: 12px; font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: 4px; justify-content: center; }
.stepper button {
  width: 20px; height: 20px; line-height: 1; border: none; border-radius: 4px;
  background: #8a7a58; color: #fff; font-weight: 700; cursor: pointer;
}
.stepper button:hover { background: #9d8c66; }
.stepper .n { min-width: 16px; font-size: 13px; font-weight: 700; }
.btnrow2 { display: flex; gap: 6px; margin-top: 8px; }
.btnrow2 button {
  flex: 1; font-size: 12px; padding: 6px 0; border: none; border-radius: 6px;
  background: #b03e14; color: #fff; cursor: pointer;
}
.btnrow2 button:disabled { background: #b6ab95; cursor: default; }
.standing {
  margin-top: 6px; background: rgba(176, 62, 20, 0.12); border: 1px solid rgba(176, 62, 20, 0.4);
  border-radius: 8px; padding: 8px; font-size: 12px; color: #3a3424;
}
.standing .btnrow2 button { font-size: 11px; }
.standing .offerdesc { font-weight: 600; margin-bottom: 4px; }

/* players panel */
.player {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  grid-template-areas: "swatch name vp" "swatch stats stats";
  align-items: center;
  gap: 1px 8px;
  padding: 5px 6px;
  border-radius: 6px;
  margin-bottom: 3px;
}
.player.active { background: rgba(176, 62, 20, 0.14); outline: 2px solid #b03e14; }
.swatch { grid-area: swatch; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.35); display: inline-block; }
.pname { grid-area: name; font-weight: 600; font-size: 14px; }
.pvp { grid-area: vp; font-weight: 700; font-size: 16px; }
.pstats { grid-area: stats; font-size: 11px; color: #4a4234; }
.badge {
  display: inline-block; font-size: 9px; font-weight: 700; padding: 1px 5px;
  border-radius: 6px; background: #b03e14; color: #fff; margin-left: 4px;
}

.log { font-size: 11px; color: #5a5240; max-height: 120px; overflow: hidden; }
.log div { padding: 1px 0; border-bottom: 1px solid rgba(0,0,0,0.06); }

/* discard modal steppers */
#discardRows .offerrow { grid-template-columns: 1fr 110px; margin-bottom: 4px; }
.counthint { font-size: 13px; font-weight: 700; }
.counthint.bad { color: #b23; }

#finalScores { list-style: none; text-align: left; margin: 12px 0; }
#finalScores li { padding: 6px 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
#finalScores .breakdown { font-size: 12px; color: #6a624f; margin-top: 2px; }

/* transient notice */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(12, 22, 30, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.4);
  pointer-events: none;
}

/* build version tag */
#version {
  position: fixed;
  right: 8px; bottom: 6px;
  z-index: 30;
  pointer-events: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
  #sidebar { width: 232px; padding: 10px 12px; }
}
