/* Cartoony medieval look: parchment, wood and chunky rounded borders. */

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

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: #3e2c1c url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><rect width="80" height="80" fill="%233e2c1c"/><path d="M0 20h80M0 60h80" stroke="%23352514" stroke-width="6"/></svg>');
  color: #f3e5c3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  width: 100%;
  max-width: 1180px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 16px;
}

h1 {
  font-size: 1.5rem;
  color: #ffd97a;
  text-shadow: 2px 2px 0 #5a3b16;
  margin-right: auto;
}

#stats { display: flex; gap: 8px; flex-wrap: wrap; }

.stat-box {
  background: #f6e7c1;
  color: #4a3417;
  border: 3px solid #8a6433;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 0.95rem;
  box-shadow: 0 3px 0 #5a3b16;
}

#run-mods { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  background: #6a4a86;
  color: #f6ecff;
  border: 2px solid #c9a6ee;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  cursor: help;
}

#controls { display: flex; gap: 8px; }

button {
  font-family: inherit;
  font-size: 0.95rem;
  background: #f6e7c1;
  color: #4a3417;
  border: 3px solid #8a6433;
  border-radius: 12px;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 #5a3b16;
  transition: transform .06s;
}
button:hover:not(:disabled) { transform: translateY(-2px); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 #5a3b16; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: #67a83d; color: #fff; border-color: #3e6b22; box-shadow: 0 3px 0 #2f5219; }
button.danger { background: #c0533c; color: #fff; border-color: #7d3021; box-shadow: 0 3px 0 #63261a; width: 100%; margin-top: 12px; }
button.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 3px 0 #2f5219, 0 0 14px #9ee46a; } }

main {
  display: flex;
  gap: 14px;
  padding: 0 16px 16px;
  width: 100%;
  max-width: 1180px;
  align-items: flex-start;
}

#board { flex: 1; min-width: 0; }

canvas {
  width: 100%;
  border: 6px solid #8a6433;
  border-radius: 14px;
  background: #7cb95c;
  box-shadow: 0 6px 0 #5a3b16, 0 10px 24px rgba(0,0,0,.45);
  display: block;
  cursor: crosshair;
}

/* -------------------------------------------------------------- barracks */

#shop-wrap { margin-top: 12px; }
#shop-wrap h2 { font-size: 1.05rem; color: #ffd97a; margin-bottom: 6px; }

#shop { display: flex; gap: 8px; flex-wrap: wrap; }

.shop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 86px;
  padding: 8px 4px;
  gap: 2px;
}
.shop-card .shop-emoji { font-size: 1.6rem; }
.shop-card .shop-name { font-weight: bold; font-size: 0.85rem; }
.shop-card .shop-cost { font-size: 0.8rem; color: #7a5a20; }
.shop-card.active { background: #ffe9a8; border-color: #d9a520; box-shadow: 0 0 12px #ffd97a, 0 3px 0 #5a3b16; }
.shop-card.poor { opacity: 0.5; }

/* ------------------------------------------------------------- inspector */

#inspector {
  width: 300px;
  flex-shrink: 0;
  background: #f6e7c1;
  color: #4a3417;
  border: 5px solid #8a6433;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 6px 0 #5a3b16;
}
#inspector h2 { font-size: 1.15rem; margin-bottom: 6px; }
#inspector h3 { font-size: 0.9rem; margin: 12px 0 5px; color: #6b4a1a; }
#inspector .hint { font-size: 0.85rem; color: #6b552f; line-height: 1.35; }

.stats { margin-top: 8px; }
.stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-bottom: 1px dashed #cbb283;
}

.mat-row { display: flex; flex-wrap: wrap; gap: 5px; }
.mat-btn {
  font-size: 0.75rem;
  padding: 4px 7px;
  border-width: 2px;
  border-radius: 8px;
  box-shadow: 0 2px 0 #5a3b16;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.mat-btn small { color: #7a5a20; }
.mat-btn.owned { background: #cfe8b8; border-color: #4d7a2c; opacity: 1; }

footer {
  padding: 6px 16px 18px;
  font-size: 0.85rem;
  color: #cbb283;
  max-width: 1180px;
  text-align: center;
}

/* ---------------------------------------------------------------- modals */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 4, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: #f6e7c1;
  color: #4a3417;
  border: 6px solid #8a6433;
  border-radius: 18px;
  box-shadow: 0 8px 0 #5a3b16, 0 16px 40px rgba(0,0,0,.6);
  padding: 26px 30px;
  max-width: 440px;
  text-align: center;
}
.modal h2 { margin-bottom: 10px; }
.modal p { margin-bottom: 14px; line-height: 1.4; }
.modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  text-align: left;
}
.modal-stats b { float: right; }
.modal-btns { display: flex; gap: 10px; justify-content: center; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #inspector { width: 100%; }
}
