:root {
  --bg: #eef6ef;
  --panel-bg: #ffffff;
  --text: #3a3a3a;
  --accent: #7cc576;
  --accent-dark: #4f9c4a;
  --health: #e2846b;
  --coin: #e8c547;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

.screen {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* Journey screen */

#hud {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  background: var(--panel-bg);
  width: 100%;
  max-width: 900px;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.hud-row {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.hud-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-label {
  font-size: 0.8rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bar {
  width: 140px;
  height: 14px;
  background: #eee;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid #ddd;
}

.bar-fill {
  height: 100%;
  transition: width 0.15s ease-out;
}

.health-fill {
  background: var(--health);
  width: 100%;
}

#coin-count, #plank-count, #iron-count {
  font-weight: 600;
  color: #b8901f;
}

.item-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.item-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.item-btn:not(:disabled):hover {
  background: var(--accent-dark);
}

.small-btn {
  padding: 4px 10px;
  font-size: 0.85rem;
}

.secondary-btn {
  background: #8a97a8;
}

.secondary-btn.active {
  background: var(--accent-dark);
}

#debug-coords {
  font-family: monospace;
  font-size: 0.85rem;
  color: #888;
}

.secondary-btn:hover {
  background: #6d7a8b;
}

.item-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f4f4;
  border-radius: 6px;
  padding: 4px 8px 4px 12px;
  font-size: 0.9rem;
  cursor: help;
}

.passive-tag {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
}

#world-canvas {
  margin-top: 16px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  background: #000;
}

#journey-hint {
  margin-top: 10px;
  color: #777;
  font-size: 0.9rem;
}

/* On-screen movement controls, shown only on touch devices without a mouse */

#mobile-dpad {
  display: none;
}

@media (pointer: coarse) {
  #mobile-dpad {
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
    gap: 4px;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 500;
  }
}

.dpad-btn {
  background: rgba(124, 197, 118, 0.85);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.3rem;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.dpad-btn:active {
  background: var(--accent-dark);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Expedition report modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--panel-bg);
  padding: 28px 32px;
  border-radius: 12px;
  width: 380px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.modal h2 {
  margin-top: 0;
  color: var(--accent-dark);
}

.modal p {
  margin: 10px 0;
  color: #555;
}

/* Base screen */

.base-panel {
  background: var(--panel-bg);
  margin: 30px 0 30px;
  padding: 32px 40px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  width: 460px;
  max-width: 92vw;
  text-align: center;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.base-panel h1 {
  margin-top: 0;
  color: var(--accent-dark);
}

.night-report {
  min-height: 1.2em;
  color: #666;
  font-style: italic;
}

.base-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  align-items: baseline;
  font-size: 1.1rem;
  margin: 16px 0 24px;
}

.base-stats b {
  font-weight: 700;
  color: #b8901f;
}

.building {
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.building h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.building p {
  margin: 4px 0;
  color: #666;
  font-size: 0.9rem;
}

.build-btn, .start-btn {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.build-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.build-btn:not(:disabled):hover, .start-btn:hover {
  background: var(--accent-dark);
}

.start-btn {
  font-size: 1.1rem;
  padding: 14px;
}

.shop-offers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.shop-offer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f4f4f4;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.building-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.building-controls .item-btn.active {
  background: var(--accent-dark);
}

.controls-break {
  flex-basis: 100%;
  height: 0;
}

.loadout {
  text-align: left;
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 20px;
}

.loadout-tag {
  display: inline-block;
  background: #ede4fb;
  color: #6a3fb5;
  border-radius: 4px;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  font-size: 0.8rem;
  font-weight: 600;
}
