/* ==========================================================================
   Meadowbrook Valley - Master Game Stylesheet
   Cozy Pixel-Art & Retro Stardew Aesthetic
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&family=Nunito:wght@600;800;900&display=swap');

:root {
  --wood-dark: #3e2723;
  --wood-mid: #5d4037;
  --wood-light: #8d6e63;
  --parchment: #fbf5e5;
  --parchment-border: #d7ccc8;
  --gold: #ffb300;
  --gold-dark: #ff8f00;
  --energy-green: #4caf50;
  --energy-green-dark: #2e7d32;
  --health-red: #e53935;
  --health-red-dark: #b71c1c;
  --spring-accent: #81c784;
  --summer-accent: #ffb74d;
  --fall-accent: #ff7043;
  --winter-accent: #90caf9;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top, #4a6572, #232f34);
  color: #3e2723;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

#game-container {
  width: 100%;
  max-width: 1180px;
  background: var(--wood-mid);
  border: 8px solid var(--wood-dark);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- HEADER HUD --- */
#game-header {
  background: linear-gradient(180deg, #6d4c41, #4e342e);
  color: #fff;
  padding: 14px 20px;
  border-bottom: 4px solid var(--wood-dark);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hud-badge {
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 15px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.gold-badge {
  color: #ffd54f;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Vitals (Energy & Health) */
.vital-bar-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.vital-bar {
  position: relative;
  height: 18px;
  background: #212121;
  border-radius: 9px;
  border: 2px solid #000;
  overflow: hidden;
}

.vital-fill {
  height: 100%;
  transition: width 0.25s ease-out;
}

#energy-fill { background: linear-gradient(90deg, #66bb6a, #43a047); }
#health-fill { background: linear-gradient(90deg, #ef5350, #e53935); }

.vital-text {
  position: absolute;
  width: 100%;
  text-align: center;
  top: 0;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  line-height: 15px;
}

.hud-actions {
  display: flex;
  gap: 8px;
}

.hud-btn {
  background: #3e2723;
  color: #fff;
  border: 2px solid #8d6e63;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #5d4037;
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px);
}

.sleep-btn {
  background: #1565c0;
  border-color: #42a5f5;
}

/* --- NAVIGATION TABS --- */
#nav-tabs {
  display: flex;
  background: #3e2723;
  padding: 6px 12px 0;
  gap: 6px;
  border-bottom: 3px solid #271613;
  overflow-x: auto;
}

.tab-btn {
  background: #5d4037;
  color: #d7ccc8;
  border: 2px solid #271613;
  border-bottom: none;
  padding: 10px 18px;
  font-weight: 800;
  font-size: 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: #795548;
  color: #fff;
}

.tab-btn.active {
  background: var(--parchment);
  color: #3e2723;
  font-weight: 900;
  border-color: #271613;
  margin-top: -2px;
  padding-bottom: 12px;
}

/* --- MAIN WORKSPACE --- */
#game-main {
  background: var(--parchment);
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 480px;
}

.game-panel {
  display: none;
  padding: 20px;
  overflow-y: auto;
  max-height: 520px;
}

.game-panel.active {
  display: block;
}

/* Sidebar & Log */
#game-sidebar {
  background: #ede0d4;
  border-left: 4px solid var(--parchment-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  color: #5d4037;
  letter-spacing: 0.5px;
}

#action-log {
  flex: 1;
  background: #fbf5e5;
  border: 2px solid #d7ccc8;
  border-radius: 8px;
  padding: 10px;
  overflow-y: auto;
  max-height: 440px;
  font-size: 12px;
  line-height: 1.5;
  color: #4e342e;
}

.log-entry {
  padding: 4px 0;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
}

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

/* --- FARM GRID PANEL --- */
.farm-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.farm-controls-hint {
  font-size: 13px;
  color: #6d4c41;
  font-weight: 800;
}

#farm-grid {
  display: grid;
  grid-template-columns: repeat(8, 56px);
  grid-gap: 6px;
  background: #795548;
  padding: 12px;
  border: 4px solid #4e342e;
  border-radius: 10px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.4);
}

.farm-tile {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease, filter 0.1s ease;
  font-size: 22px;
}

.farm-tile:hover {
  transform: scale(1.06);
  filter: brightness(1.15);
  z-index: 2;
}

/* Soil States */
.tile-untilled {
  background: #8d6e63;
  border: 2px solid #6d4c41;
}

.tile-debris {
  background: #795548;
  border: 2px solid #5d4037;
}

.tile-tilled {
  background: #5d4037;
  border: 2px solid #3e2723;
}

.tile-tilled.watered {
  background: #3e2723;
  border: 2px solid #1a0f0d;
  box-shadow: inset 0 0 6px rgba(0, 150, 255, 0.4);
}

.crop-label {
  font-size: 9px;
  font-weight: 900;
  color: #ffd54f;
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 3px;
  border-radius: 3px;
  position: absolute;
  bottom: 2px;
}

.pulse {
  animation: harvestPulse 1s infinite alternate;
}

@keyframes harvestPulse {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

/* --- HOTBAR (FOOTER) --- */
#game-footer {
  background: #4e342e;
  border-top: 4px solid var(--wood-dark);
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#hotbar-slots {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  padding: 4px;
}

.hotbar-slot {
  width: 52px;
  height: 52px;
  background: #d7ccc8;
  border: 3px solid #8d6e63;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  font-size: 22px;
  transition: all 0.15s ease;
}

.hotbar-slot:hover {
  background: #fbf5e5;
  border-color: #ffd54f;
}

.hotbar-slot.selected {
  border-color: #ffb300;
  box-shadow: 0 0 10px #ffb300, inset 0 0 6px #ffb300;
  transform: translateY(-4px);
  background: #fff;
}

.item-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 11px;
  font-weight: 900;
  color: #3e2723;
  text-shadow: 0 1px 1px #fff;
}

.quality-badge {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 12px;
}

.quality-badge.silver { color: #cfd8dc; text-shadow: 0 1px 1px #37474f; }
.quality-badge.gold { color: #ffd54f; text-shadow: 0 1px 1px #ff6f00; }
.quality-badge.iridium { color: #ba68c8; text-shadow: 0 1px 1px #4a148c; }

/* --- MINES STYLING --- */
.mines-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mines-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #4e342e;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
}

.monster-arena {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.monster-card {
  background: #fff;
  border: 2px solid #d7ccc8;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
}

.monster-card.dead {
  opacity: 0.35;
  filter: grayscale(1);
}

.monster-icon { font-size: 32px; }
.monster-name { font-weight: 800; font-size: 14px; }

.monster-hp-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.monster-hp-fill {
  height: 100%;
  background: #e53935;
  transition: width 0.2s ease;
}

.btn-attack {
  background: #e53935;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-weight: 800;
  cursor: pointer;
}

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

.ore-node-btn {
  background: #8d6e63;
  color: #fff;
  border: 2px solid #5d4037;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
}

.btn-ladder {
  background: #4caf50;
  color: #fff;
  border: 2px solid #2e7d32;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  align-self: flex-start;
}

/* --- FISHING MINIGAME --- */
.fishing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.fishing-controls {
  display: flex;
  gap: 12px;
}

#fishing-canvas {
  border: 4px solid #01579b;
  border-radius: 12px;
  background: #0288d1;
  box-shadow: var(--shadow);
}

.btn-reel {
  width: 160px;
  height: 48px;
  font-size: 18px;
  font-weight: 900;
  background: #ff9800;
  color: #fff;
  border: 3px solid #e65100;
  border-radius: 8px;
  cursor: pointer;
}

/* --- SOCIAL & DIALOGUE --- */
.social-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.npc-card {
  background: #fff;
  border: 2px solid #d7ccc8;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.npc-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.npc-avatar { font-size: 28px; }
.npc-hearts { font-size: 12px; color: #e53935; }

.npc-actions {
  display: flex;
  gap: 6px;
}

.npc-actions button {
  flex: 1;
  padding: 6px;
  border: 1px solid #bcaaa4;
  border-radius: 4px;
  background: #efebe9;
  font-weight: 800;
  cursor: pointer;
}

/* Dialogue Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-overlay.active {
  display: flex;
}

.dialogue-box {
  background: var(--parchment);
  border: 6px solid var(--wood-dark);
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialogue-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px dashed #bcaaa4;
  padding-bottom: 8px;
}

.dialogue-text {
  font-size: 15px;
  font-style: italic;
  line-height: 1.6;
  color: #3e2723;
  min-height: 60px;
}

/* --- SHOPS & BUNDLES --- */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.shop-item-card {
  background: #fff;
  border: 2px solid #d7ccc8;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-buy {
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px;
  font-weight: 800;
  cursor: pointer;
}

.bundle-room-card {
  background: #fff;
  border: 2px solid #8d6e63;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.bundle-box {
  background: #efebe9;
  border: 1px solid #bcaaa4;
  border-radius: 6px;
  padding: 10px;
  margin-top: 8px;
}

.bundle-item-tag {
  display: inline-block;
  background: #fff;
  border: 1px solid #d7ccc8;
  border-radius: 4px;
  padding: 2px 6px;
  margin: 2px;
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 860px) {
  #game-main { grid-template-columns: 1fr; }
  #farm-grid { grid-template-columns: repeat(6, 48px); }
  .farm-tile { width: 48px; height: 48px; }
}
