body {
  background-color: lightblue;
  margin: 0;
  font-family: Monaco, monospace;
  min-height: 100vh;
}

h1 {
  text-align: center;
  margin: 10px 0 16px 0;
  font-family: "Comic Sans MS", "Comic Sans", cursive;
  font-size: 3rem;
  background: linear-gradient(
    to right,
    #ef5350, #f48fb1, #7e57c2, #2196f3,
    #26c6da, #43a047, #eeff41, #f9a825, #ff5722
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 2px black;
}

.top-left-buttons {
  position: fixed;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 10px;
  z-index: 100;
}

.back-buttons {
  background: #fff;
  border: 1px solid #000;
  padding: 8px 12px;
  cursor: pointer;
  font-family: Monaco, monospace;
  font-size: 13px;
}

.back-buttons:hover {
  background: #000;
  color: #fff;
}

.back-buttons:active {
  background-color: #32a6a8;
  transform: translate(0px, 2px);
}

.game-wrapper {
  padding: 60px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100%;
  box-sizing: border-box;
}

.game-container {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
  max-width: 2000px;
}

/* The canvas flexes to fill the space between the panels; a ResizeObserver in
   the JS keeps the drawing buffer matched to the on-screen size. */
#gameCanvas {
  border: 3px solid #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  display: block;
  flex: 1 1 auto;
  min-width: 320px;
  height: calc(100vh - 200px);
  min-height: 480px;
}

/* ── Fullscreen: hide the chrome, let the game fill the screen ── */

body.fullscreen h1,
body.fullscreen .top-left-buttons {
  display: none;
}

body.fullscreen .game-wrapper {
  padding: 10px;
}

body.fullscreen #gameCanvas {
  height: calc(100vh - 26px);
  min-height: 0;
}

#gameCanvas.demolish {
  cursor: not-allowed;
}

.sidebar {
  width: 430px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-stockpile-row {
  display: flex;
  gap: 10px;
}

/* ── Sidebar tabs ── */

.tab-bar {
  display: flex;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 8px 4px;
  border: 2px solid #000;
  background: #fff;
  font-family: Monaco, monospace;
  font-size: 12px;
  cursor: pointer;
}

.tab-btn:hover:not(.selected) {
  background: #eee;
}

.tab-btn:active {
  transform: translate(0, 1px);
}

.tab-btn.selected {
  background: #000;
  color: #fff;
}

.tab-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tab-page .discoveries-panel {
  width: auto;
  align-self: stretch;
  max-height: 320px;
}

.stats-stockpile-row .panel {
  flex: 1;
}

.panel {
  background: white;
  border: 2px solid black;
  padding: 10px 12px;
}

.panel h2 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-family: Monaco, monospace;
  border-bottom: 1px solid #000;
  padding-bottom: 4px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin: 4px 0;
  font-family: Monaco, monospace;
}

.stat-row .value {
  font-weight: bold;
}

.pos { color: #2e7d32; }
.neg { color: #c62828; }

/* Laws in force — hover for the full effect card */
.law-row { cursor: help; }
.law-row:hover { background: #f5f5f5; }

.tool-btn {
  width: 100%;
  padding: 7px 8px;
  margin: 3px 0;
  border: 2px solid #000;
  cursor: pointer;
  font-family: Monaco, monospace;
  font-size: 12px;
  text-align: left;
  transition: filter 0.1s, box-shadow 0.1s;
  display: flex;
  align-items: center;
  gap: 7px;
  box-sizing: border-box;
}

.tool-btn:hover {
  filter: brightness(1.12);
}

.tool-btn.selected {
  border-width: 3px;
  box-shadow: 3px 3px 0px #000;
}

.tool-swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.tool-desc {
  font-size: 11px;
  font-family: Monaco, monospace;
  color: #333;
  margin: 0;
  line-height: 1.5;
}

.zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.zoom-btn {
  width: 26px;
  height: 26px;
  border: 2px solid #000;
  background: white;
  font-family: Monaco, monospace;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.zoom-btn:hover {
  background: #000;
  color: white;
}

#zoom-label {
  font-size: 13px;
  font-family: Monaco, monospace;
  flex: 1;
  text-align: center;
}

.speed-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

#event-log {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid #ddd;
  padding-top: 4px;
}

.log-entry {
  font-size: 10px;
  font-family: Monaco, monospace;
  color: #333;
  padding: 1px 0;
  border-bottom: 1px solid #f0f0f0;
}

.speed-btn {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 2px solid #000;
  background: white;
  font-family: Monaco, monospace;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.speed-btn:hover {
  background: #000;
  color: white;
}

.speed-btn.selected {
  background: #000;
  color: white;
}

.speed-slider {
  flex: 1;
  cursor: pointer;
  accent-color: #000;
  min-width: 0;
}

.speed-label {
  font-size: 11px;
  font-family: Monaco, monospace;
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

.th-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.th-nav-btn {
  width: 20px;
  height: 20px;
  border: 2px solid #000;
  background: white;
  font-family: Monaco, monospace;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.th-nav-btn:hover {
  background: #000;
  color: white;
}

.th-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.th-nav-label {
  flex: 1;
  font-size: 10px;
  font-family: Monaco, monospace;
  text-align: center;
  color: #555;
}

.hint {
  font-size: 10px;
  color: #888;
  margin: 4px 0 0 0;
  font-family: Monaco, monospace;
}

#message {
  font-size: 12px;
  color: #c62828;
  font-family: Monaco, monospace;
  margin: 6px 0 0 0;
  min-height: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.action-btn {
  width: 100%;
  padding: 7px 8px;
  margin: 4px 0;
  border: 2px solid #000;
  cursor: pointer;
  font-family: Monaco, monospace;
  font-size: 11px;
  text-align: center;
  background: #e8f5e9;
  box-sizing: border-box;
}

.action-btn:hover {
  filter: brightness(1.1);
}

.action-btn:active {
  box-shadow: 2px 2px 0 #000;
  transform: translate(1px, 1px);
}

.action-btn.upgrade {
  background: #e8eaf6;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.discoveries-panel {
  width: 320px;
  background: white;
  border: 2px solid black;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-self: flex-start;
  max-height: 518px;
  overflow-y: auto;
  box-sizing: border-box;
}

.discoveries-panel h2 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-family: Monaco, monospace;
  border-bottom: 1px solid #000;
  padding-bottom: 4px;
}

.discovery-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #eee;
}

.discovery-entry:last-child {
  border-bottom: none;
}

.discovery-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.2);
  image-rendering: pixelated;
}

.discovery-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.discovery-name {
  font-size: 11px;
  font-family: Monaco, monospace;
  font-weight: bold;
}

.discovery-desc {
  font-size: 10px;
  font-family: Monaco, monospace;
  color: #555;
  line-height: 1.4;
}

/* ── Left column: minimap + discoveries ── */

.left-column {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: flex-start;
}

.left-column .discoveries-panel {
  width: auto;
  align-self: stretch;
  max-height: 320px;
}

#minimap {
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid #000;
  cursor: pointer;
  display: block;
  box-sizing: border-box;
}

/* ── Hover tooltip ── */

#tile-tooltip {
  display: none;
  position: fixed;
  z-index: 200;
  background: rgba(20, 24, 28, 0.92);
  color: #fff;
  font-family: Monaco, monospace;
  font-size: 11px;
  line-height: 1.5;
  padding: 6px 9px;
  border: 1px solid #000;
  pointer-events: none;
  max-width: 260px;
}

/* ── Event log categories ── */

.log-good { color: #2e7d32; }
.log-bad  { color: #c62828; }
.log-info { color: #1565c0; }

/* ── Powers panel ── */

.powers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.powers-grid .action-btn {
  margin: 0;
  font-size: 10.5px;
}

.mode-btn.selected {
  background: #000 !important;
  color: #fff;
}

/* ── Soul upgrades ── */

.upgrade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.upgrade-grid .action-btn {
  margin: 0;
  font-size: 10.5px;
}

/* ── Votes panel sway buttons ── */

.vote-row {
  align-items: center;
  gap: 6px;
}

.vote-row .value {
  margin-left: auto;
}

.sway-btn {
  border: 2px solid #000;
  background: #fff8e1;
  font-family: Monaco, monospace;
  font-size: 10px;
  cursor: pointer;
  padding: 1px 5px;
  flex-shrink: 0;
}

.sway-btn:hover:not(:disabled) {
  background: #000;
  color: #fff;
}

.sway-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ── Inspector ── */

.inspector-buttons {
  display: flex;
  gap: 6px;
}

.inspector-buttons .action-btn.selected {
  background: #000;
  color: #fff;
}

/* ── Trends ── */

#trends {
  width: 100%;
  border: 1px solid #ddd;
  display: block;
  box-sizing: border-box;
}

/* ── Records & chronicle ── */

.records-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 14px;
}

#chronicle-list {
  max-height: 130px;
  overflow-y: auto;
  border-top: 1px solid #ddd;
  padding-top: 4px;
}

.chronicle-entry {
  font-size: 10px;
  font-family: Monaco, monospace;
  color: #555;
  padding: 2px 0;
  border-bottom: 1px solid #f5f5f5;
  line-height: 1.4;
}

/* ── Era banner ── */

.era-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #fff;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
  font-family: "Comic Sans MS", "Comic Sans", cursive;
  font-size: 22px;
  padding: 12px 28px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.5s, transform 0.5s;
  pointer-events: none;
}

.era-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Research tree ── */

.research-tier {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #eee;
}

.research-tier:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.research-btn {
  flex: 1;
  min-width: 110px;
}

.research-btn.done {
  background: #e8f5e9;
  color: #2e7d32;
  opacity: 1;
}
