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

body {
  background: #140f0b;
  color: #fff6e0;
  font-family: "Courier New", Courier, monospace;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #251c14 0%, #100c08 100%);
}

#game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Stardew-inspired pixel wooden frames */
.hud-panel,
.pixel-panel {
  background: rgba(54, 34, 19, 0.92);
  border: 3px solid #d49447;
  box-shadow:
    inset 0 0 0 2px #6b4322,
    0 4px 0 #1f1208,
    0 6px 14px rgba(0, 0, 0, 0.65);
  border-radius: 4px;
}

/* Top HUD */
#top-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  z-index: 20;
}

.hud-left,
.hud-right {
  pointer-events: auto;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  border-right: 2px solid #7c512b;
}

.brand-title {
  font-weight: 900;
  font-size: 14px;
  color: #ffd86b;
  letter-spacing: 0.5px;
  text-shadow: 2px 2px 0 #1c0f05;
}

.zone-subtitle {
  font-size: 11px;
  color: #a9e386;
  font-weight: bold;
}

.quest-box {
  font-size: 12px;
  max-width: 390px;
  line-height: 1.3;
  color: #ffefc4;
}

.quest-tag {
  background: #e07a24;
  color: #fff;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 2px;
  margin-right: 4px;
  font-size: 11px;
}

.stat-pill {
  background: #23150b;
  border: 2px solid #8a5b32;
  padding: 4px 9px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 900;
  color: #fff3d1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.gold-pill {
  color: #ffdb4d;
  border-color: #d4a338;
}

.sales-pill {
  color: #8ce99a;
  border-color: #469653;
}

.sep {
  color: #8a5b32;
}

.energy-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #23150b;
  border: 2px solid #8a5b32;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
}

.energy-track {
  width: 68px;
  height: 11px;
  background: #140c06;
  border: 1px solid #634224;
  overflow: hidden;
}

#energy-fill {
  height: 100%;
  background: linear-gradient(90deg, #52b788, #74c69d);
  transition: width 0.15s ease;
}

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

.pixel-btn {
  background: #8f5629;
  color: #fff8e7;
  border: 2px solid #f0b565;
  box-shadow: 0 3px 0 #3a200d;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  border-radius: 3px;
  transition: transform 0.06s, background 0.1s;
}

.pixel-btn:hover {
  background: #ad6a34;
}

.pixel-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a200d;
}

.pixel-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: #3b7a3e;
  border-color: #8ce99a;
}

.btn-primary:hover {
  background: #49944d;
}

.btn-secondary {
  background: #3a6087;
  border-color: #91c9ff;
}

.btn-secondary:hover {
  background: #4875a3;
}

.btn-truck {
  background: #b85d19;
  border-color: #ffd180;
}

.btn-truck:hover {
  background: #d16b20;
}

.btn-large {
  padding: 9px 14px;
  font-size: 13px;
}

/* Left Pantry Sidebar */
#pantry-hud {
  position: absolute;
  top: 78px;
  left: 10px;
  width: 224px;
  padding: 10px;
  z-index: 20;
}

.pantry-header {
  font-size: 11px;
  font-weight: 900;
  color: #ffd86b;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
  text-align: center;
  border-bottom: 2px solid #6b4322;
  padding-bottom: 4px;
}

.ingredient-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(27, 16, 8, 0.72);
  border: 1px solid #694322;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 11px;
}

.ing-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ing-left canvas {
  width: 20px;
  height: 20px;
}

.ing-name {
  color: #ffefd0;
  font-weight: bold;
}

.ing-count {
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 2px;
  background: #2f1d0e;
  color: #a9e386;
}

.ing-count.zero {
  color: #ff8787;
}

.pantry-divider {
  height: 2px;
  background: #6b4322;
  margin: 8px 0;
}

.bars-stock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #2a180b;
  border: 2px solid #e09f3e;
  padding: 6px;
  border-radius: 3px;
}

.bars-stock-label {
  font-size: 10px;
  color: #ffd86b;
  text-transform: uppercase;
}

.bars-stock-count {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
}

.truck-stock-row {
  margin-top: 6px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  background: #1d1209;
  padding: 4px 6px;
  border: 1px solid #754b27;
  color: #ffd180;
}

/* Bottom Hotbar */
#bottom-hud {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 20;
}

#hotbar {
  display: flex;
  gap: 5px;
  padding: 6px;
}

.hotbar-slot {
  width: 58px;
  height: 62px;
  background: #23150b;
  border: 2px solid #8a5b32;
  border-radius: 3px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s, border-color 0.08s;
}

.hotbar-slot:hover {
  border-color: #ffd86b;
}

.hotbar-slot.active {
  background: #4a2d15;
  border: 3px solid #ffd86b;
  transform: translateY(-3px);
  box-shadow: 0 3px 0 #1a0f07;
}

.slot-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  color: #d4a373;
  font-weight: bold;
}

.slot-qty {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: 900;
  color: #a9e386;
}

.slot-label {
  font-size: 9px;
  text-align: center;
  color: #ffefc4;
  margin-top: 2px;
  line-height: 1;
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#controls-hint {
  padding: 4px 12px;
  font-size: 11px;
  display: flex;
  gap: 14px;
  color: #e6ccb2;
}

#controls-hint strong {
  color: #ffd86b;
}

/* Context Prompt */
#context-prompt {
  position: absolute;
  bottom: 118px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 17, 8, 0.94);
  border: 2px solid #ffd86b;
  color: #fff8e7;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 900;
  border-radius: 4px;
  z-index: 25;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7);
}

.hidden {
  display: none !important;
}

/* Modals */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 3, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-window {
  width: min(920px, 95vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kitchen-modal-wide {
  width: min(1080px, 96vw);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #28170b;
  border-bottom: 3px solid #8a5b32;
}

.modal-header h2 {
  font-size: 18px;
  color: #ffd86b;
}

.modal-close {
  background: #9e2a2b;
  color: #fff;
  border: 2px solid #ff8787;
  width: 28px;
  height: 28px;
  font-weight: 900;
  cursor: pointer;
  border-radius: 3px;
}

.modal-body {
  padding: 14px;
  overflow-y: auto;
}

.kitchen-layout {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 14px;
}

.kitchen-section {
  background: rgba(28, 17, 9, 0.75);
  border: 2px solid #754b27;
  padding: 10px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kitchen-step-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #1d1108;
  border: 2px solid #d49447;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #ffefc4;
  font-weight: bold;
}

.batch-badge {
  background: #2d6a4f;
  border: 1px solid #8ce99a;
  color: #fff;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  font-size: 11px;
}

.kitchen-canvas-wrap {
  width: 100%;
  background: #140c06;
  border: 3px solid #8a5b32;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

#kitchen-canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: grab;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#kitchen-canvas:active {
  cursor: grabbing;
}

.kitchen-section h3 {
  color: #ffd86b;
  font-size: 15px;
  border-bottom: 1px solid #6b4322;
  padding-bottom: 5px;
}

.recipe-desc {
  font-size: 12px;
  color: #f3d5b5;
  line-height: 1.4;
}

.recipe-reqs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.req-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: #1b1008;
  border: 1px solid #5e3c1f;
  border-radius: 3px;
  font-size: 11px;
}

.req-card.ready {
  border-color: #469653;
}

.req-card.missing {
  border-color: #a33939;
  opacity: 0.85;
}

.production-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.auto-craft-status {
  margin-top: auto;
  background: #170e07;
  border: 1px dashed #8a5b32;
  padding: 8px;
  font-size: 11px;
  color: #a9e386;
}

.upgrades-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.upgrade-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #1b1008;
  border: 2px solid #6b4322;
  padding: 8px 10px;
  border-radius: 4px;
}

.upgrade-card.owned {
  border-color: #469653;
  background: rgba(34, 60, 36, 0.35);
}

.upgrade-info h4 {
  font-size: 13px;
  color: #ffd86b;
  margin-bottom: 2px;
}

.upgrade-info p {
  font-size: 11px;
  color: #d8be9e;
  line-height: 1.3;
}

/* Store Modal */
.store-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.npc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #211309;
  border: 2px solid #8a5b32;
  padding: 10px;
  border-radius: 4px;
}

#npc-portrait-canvas {
  width: 76px;
  height: 76px;
  border: 3px solid #d49447;
  background: #3c2817;
  border-radius: 4px;
}

.npc-name {
  font-size: 17px;
  font-weight: 900;
  color: #ffd86b;
}

.npc-role {
  font-size: 12px;
  color: #a9e386;
  margin-bottom: 4px;
}

.reputation-meter {
  font-size: 12px;
  color: #ffccd5;
}

.dialogue-bubble {
  background: #fff3d6;
  color: #2b180a;
  border: 3px solid #b07232;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: bold;
  line-height: 1.4;
}

.store-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.store-stat-card {
  background: #1c1008;
  border: 2px solid #6b4322;
  padding: 8px;
  text-align: center;
  border-radius: 4px;
}

.stat-label {
  font-size: 11px;
  color: #d4a373;
}

.stat-val {
  font-size: 16px;
  font-weight: 900;
  margin-top: 3px;
}

.gold-text {
  color: #ffdb4d;
}

.store-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.town-directory-section h4 {
  font-size: 13px;
  color: #ffd86b;
  margin-bottom: 6px;
}

.retail-accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.retail-card {
  background: #1a0f07;
  border: 2px solid #5e3c1f;
  padding: 7px;
  border-radius: 4px;
  font-size: 11px;
}

.retail-card.unlocked {
  border-color: #52b788;
}

.retail-card.locked {
  opacity: 0.65;
}

.retail-card-title {
  font-weight: 900;
  color: #ffd86b;
  margin-bottom: 2px;
}

/* Almanac Cards */
.almanac-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.almanac-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #1c1008;
  border: 2px solid #754b27;
  padding: 8px 10px;
  border-radius: 4px;
}

.almanac-card canvas {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.almanac-card h4 {
  color: #ffd86b;
  font-size: 13px;
}

.almanac-card p {
  font-size: 11px;
  color: #e6ccb2;
  line-height: 1.3;
}

/* Toast notifications */
#toast-container {
  position: absolute;
  top: 76px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 40;
  pointer-events: none;
}

.toast {
  background: rgba(34, 21, 10, 0.95);
  border: 2px solid #ffd86b;
  color: #fff8e7;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 4px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
