html, body {
  margin: 0;
  padding: 0;
  background: #050509;
  color: #eee;
  font-family: system-ui, sans-serif;
  overflow: hidden;
  height: 100%;
  overflow-y: auto;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}

#frame {
  margin-top: 10px;
  margin-bottom: 10px;
  width: 100%;
  position: relative;
  z-index: 99998;
}

#frame iframe {
  border: 0;
  padding: 0;
  width: 70%;
  height: 60px;
  border-radius: 12px;
  overflow: hidden;
  display: block;
  margin: auto;
}

/* FAUCET */
#faucetFrame {
  border: none;
  border-radius: 18px;
  display: block;
  margin: 30px auto;
  background: transparent;
}

h1 {
  margin: 6px 0;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

#topBar, #bottomBar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 4px;
  font-size: 11px;
}

.panel, .small-panel {
  background: #10131a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 4px 8px;
}

.small-panel {
  min-width: 160px;
}

button, select {
  background: #1a1d26;
  color: #eee;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
}

button:hover {
  background: #222735;
}

/* Farm Container for relative positioning */
.farm-container {
  position: relative;
  display: inline-block;
  margin: 10px auto;
}

#farm {
  margin: 0 auto;
  width: 70vmin;
  height: 70vmin;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: .5vmin;
  background: #06070c;
  border: 1px solid #333;
  border-radius: 12px;
  padding: .5vmin;
  box-sizing: border-box;
}

.tile {
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4vmin;
  cursor: pointer;
  transition: transform .05s;
  user-select: none;
}

.tile:hover {
  transform: translateY(-1px);
}

.locked {
  background: #111;
  border: 1px solid #222;
}

.empty {
  background: #2b2415;
  border: 1px solid #3a3120;
}

.planted {
  background: #3d331a;
  border: 1px solid #57421d;
}

.growing {
  background: #56421d;
  border: 1px solid #866225;
}

.ready {
  background: #567d2a;
  border: 1px solid #9bd740;
  box-shadow: 0 0 10px rgba(150,255,80,.25);
}

.dead {
  background: #444;
  border: 1px solid #666;
}

.good {
  filter: brightness(1.1);
}

.excellent {
  filter: brightness(1.2) saturate(1.2);
}

.golden {
  animation: glow 1s infinite alternate;
}

@keyframes glow {
  from { box-shadow: 0 0 5px gold; }
  to { box-shadow: 0 0 18px gold; }
}

#msg {
  height: 18px;
  font-size: 12px;
  padding: 5px;
}

.popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.hidden {
  display: none;
}

.popupBox {
  width: 320px;
  background: #141824;
  border: 2px solid #4d7cff;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 0 30px rgba(80,120,255,.4);
  animation: popupAnim .25s ease;
}

.popupBox h2 {
  margin-top: 0;
  color: #8cb4ff;
  letter-spacing: .08em;
}

.popupBox button {
  margin-top: 18px;
  width: 120px;
  padding: 10px;
  font-size: 14px;
}

@keyframes popupAnim {
  from {
    transform: scale(.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================ */
/* TUTORIAL STYLES - POSITIONED RELATIVE TO FARM */
/* ============================================ */

.tutorial-mini {
  position: absolute;
  top: 10px;
  left: 220px;
  background: linear-gradient(135deg, #1a2a1a 0%, #0a1a0a 100%);
  border: 3px solid #ffd700;
  border-radius: 16px;
  padding: 12px 15px;
  width: 240px;
  pointer-events: auto;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: bounceIn 0.3s ease;
}

.tutorial-mini.hidden {
  display: none !important;
}

/* Mobile - adjust position within farm */
@media (max-width: 767px) {
  .tutorial-mini {
    top: 160px;
    left: 5px;
    width: calc(100% - 20px);
    max-width: 250px;
    padding: 8px 12px;
  }
  
  .tutorial-mini-emoji {
    font-size: 28px;
  }
  
  .tutorial-mini-title {
    font-size: 13px;
  }
  
  .tutorial-mini-message {
    font-size: 11px;
  }
  
  .tutorial-mini-skip, .tutorial-mini-next {
    padding: 5px 8px;
    font-size: 10px;
  }
}

@keyframes bounceIn {
  0% { transform: scale(0.8); opacity: 0; }
  80% { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}

.tutorial-mini.hidden {
  display: none;
}

.tutorial-mini-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #ffd700;
}

.tutorial-mini-step {
  background: #ffd700;
  color: #1a1a1a;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: bold;
}

.tutorial-mini-exit {
  background: none;
  border: none;
  color: #ff8866;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.2s;
}

.tutorial-mini-exit:hover {
  color: #ffaa88;
}

.tutorial-mini-body {
  text-align: center;
}

.tutorial-mini-emoji {
  font-size: 32px;
  margin-bottom: 5px;
}

.tutorial-mini-title {
  color: #ffd700;
  font-size: 14px;
  font-weight: bold;
  margin: 5px 0;
}

.tutorial-mini-message {
  font-size: 11px;
  color: #ddd;
  margin: 5px 0;
  line-height: 1.4;
}

.tutorial-mini-progress {
  height: 3px;
  background: #333;
  border-radius: 2px;
  margin: 8px 0;
  overflow: hidden;
}

.tutorial-mini-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ffaa00);
  width: 0%;
  transition: width 0.3s ease;
}

.tutorial-mini-footer {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tutorial-mini-skip, .tutorial-mini-next {
  background: #444;
  border: none;
  padding: 5px 10px;
  font-size: 10px;
  flex: 1;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.tutorial-mini-skip:hover {
  background: #555;
}

.tutorial-mini-next {
  background: #4a7c2a;
}

.tutorial-mini-next:hover {
  background: #5a9c3a;
}

.tutorial-cursor {
  position: fixed;
  background: #ffd700;
  color: #1a1a1a;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: bold;
  z-index: 3002;
  pointer-events: none;
  animation: pulse 1s infinite;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tutorial-cursor::before {
  content: "👇";
  margin-right: 4px;
}

.tutorial-cursor.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.tile-highlight {
  animation: tutorialGlow 1s infinite;
  border: 2px solid #ffd700 !important;
  box-shadow: 0 0 15px #ffd700 !important;
}

.building-highlight {
  animation: tutorialGlow 1s infinite;
  border-color: #ffd700 !important;
  box-shadow: 0 0 15px #ffd700 !important;
}

@keyframes tutorialGlow {
  0%, 100% { box-shadow: 0 0 5px #ffd700; }
  50% { box-shadow: 0 0 20px #ffd700; }
}

/* ============================================ */
/* BUILDINGS STYLES - FOR PNG IMAGES */
/* ============================================ */

.buildings-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 20px auto;
  flex-wrap: wrap;
  padding: 15px;
  background: linear-gradient(135deg, #1a2a1a 0%, #0a1a0a 100%);
  border-radius: 30px;
  border: 1px solid #4a6a3a;
  max-width: 900px;
}

.silo-building, .well-building, .water-building, .town-building {
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s, filter 0.2s;
  background: linear-gradient(135deg, #2a2a1a 0%, #1a1a0a 100%);
  padding: 15px 12px 10px 12px;
  border-radius: 20px;
  border: 2px solid;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  min-width: 100px;
}

.silo-building { border-color: #8b5a2b; }
.well-building { border-color: #4488aa; }
.water-building { border-color: #66ffcc; }
.town-building { border-color: #ffaa66; }

/* Workers Section Styles */
.workers-section {
  margin: 15px 0;
  padding: 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
}

.workers-section h3 {
  margin: 0 0 10px 0;
  color: #ffaa66;
  font-size: 14px;
  text-align: center;
}

.worker-cards {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.worker-card {
  background: #1a2a2a;
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  flex: 1;
  min-width: 80px;
  border: 1px solid #ffaa66;
}

.worker-emoji {
  font-size: 24px;
  margin-bottom: 4px;
}

.worker-name {
  font-weight: bold;
  font-size: 11px;
  color: #ffaa66;
}

.worker-desc {
  font-size: 9px;
  color: #aaa;
  margin: 4px 0;
}

.worker-cost {
  font-size: 8px;
  color: #88ccff;
  margin: 4px 0;
}

.worker-card button {
  background: #4a7c2a;
  border: none;
  padding: 4px 8px;
  font-size: 10px;
  margin-top: 5px;
  width: 100%;
}

.worker-card button:hover {
  background: #5a9c3a;
}

.worker-status {
  margin-top: 10px;
  padding: 8px;
  background: #0a1a1a;
  border-radius: 8px;
  font-size: 10px;
  color: #88ffcc;
  text-align: center;
  max-height: 60px;
  overflow-y: auto;
}

.silo-building:hover, .well-building:hover, .water-building:hover, .town-building:hover {
  transform: translateY(-5px);
  filter: brightness(1.05);
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.silo-building:active, .well-building:active, .water-building:active, .town-building:active {
  transform: translateY(0);
}

.building-image {
  width: 70px;
  height: 70px;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.3));
}

.usage-text, .well-text, .water-text, .town-text {
  font-size: 11px;
  margin-top: 8px;
  font-weight: bold;
  background: rgba(0,0,0,0.6);
  padding: 4px 8px;
  border-radius: 20px;
  text-align: center;
}

.silo-building .usage-text { color: #ffd966; }
.well-building .well-text { color: #88ccff; }
.water-building .water-text { color: #66ffcc; }
.town-building .town-text { color: #ffaa66; }

.building-label {
  font-size: 10px;
  color: #aaa;
  margin-top: 6px;
}

/* ============================================ */
/* MODAL STYLES */
/* ============================================ */

.silo-modal, .well-modal, .water-modal, .town-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.silo-modal.hidden, .well-modal.hidden, .water-modal.hidden, .town-modal.hidden {
  display: none;
}

.silo-content {
  background: linear-gradient(135deg, #1a1f2e 0%, #0f1219 100%);
  border: 2px solid #8b5a2b;
  border-radius: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease;
}

.well-content {
  background: linear-gradient(135deg, #1a2a3a 0%, #0a1a2a 100%);
  border: 2px solid #4488aa;
  border-radius: 24px;
  width: 90%;
  max-width: 400px;
  padding: 30px;
  text-align: center;
  animation: slideUp 0.3s ease;
}

.water-content {
  background: linear-gradient(135deg, #1a3a3a 0%, #0a2a2a 100%);
  border: 2px solid #66ffcc;
  border-radius: 24px;
  width: 90%;
  max-width: 400px;
  padding: 30px;
  text-align: center;
  animation: slideUp 0.3s ease;
}

.town-content {
  background: linear-gradient(135deg, #2a2a3a 0%, #1a1a2a 100%);
  border: 2px solid #ffaa66;
  border-radius: 24px;
  width: 90%;
  max-width: 400px;
  padding: 30px;
  text-align: center;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.silo-header {
  background: #2a2418;
  padding: 20px;
  border-bottom: 2px solid #8b5a2b;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.silo-header h2 {
  margin: 0;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.silo-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 14px;
  color: #ffd966;
}

.silo-crops {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.silo-crop-item {
  background: #1e2438;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  transition: transform 0.1s;
}

.silo-crop-item:hover {
  background: #2a3248;
  transform: translateX(5px);
}

.crop-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 2;
  min-width: 150px;
}

.crop-emoji { font-size: 32px; }
.crop-details { flex: 1; }
.crop-name { font-weight: bold; font-size: 16px; }
.crop-qty { font-size: 20px; font-weight: bold; color: #ffd966; }
.crop-price { font-size: 12px; color: #aaa; }

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

.crop-actions button {
  padding: 6px 12px;
  font-size: 12px;
  background: #2a3a5a;
  border: none;
}

.crop-actions button:hover { background: #3a4a6a; }

.silo-expand {
  background: #2a2418;
  padding: 15px 20px;
  border-top: 1px solid #8b5a2b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
}

.silo-expand button {
  background: #4a7c2a;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: bold;
  transition: background-color 0.2s;
}

.silo-expand button:hover { background: #5a9c3a; }

.close-silo, .close-well, .close-water, .close-town {
  background: #8b3a2a;
  padding: 8px 16px;
}

.close-silo:hover, .close-well:hover, .close-water:hover, .close-town:hover {
  background: #a84a3a;
}

.empty-silo {
  text-align: center;
  padding: 40px;
  color: #888;
  font-size: 18px;
}

.modal-message {
  background: #0a1a2a;
  padding: 10px;
  border-radius: 8px;
  margin: 10px;
  font-size: 12px;
  color: #ffcc66;
  text-align: center;
}

.well-stats, .water-stats, .town-stats {
  background: rgba(0,0,0,0.3);
  padding: 15px;
  border-radius: 12px;
  margin: 15px 0;
}

.well-content h2 { color: #88ccff; margin-top: 0; }
.water-content h2 { color: #66ffcc; margin-top: 0; }
.town-content h2 { color: #ffaa66; margin-top: 0; }

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */

@media (max-width: 500px) {
  #frame iframe {
    width: 90%;
    height: 50px;
  }

  .popupBox {
    width: 90%;
  }

  #faucetFrame {
    height: 620px;
  }
  
  .building-image {
    width: 50px;
    height: 50px;
  }
  
  .buildings-container {
    gap: 10px;
  }
  
  .silo-building, .well-building, .water-building, .town-building {
    min-width: 70px;
    padding: 10px 8px 8px 8px;
  }
}