* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #1b1206;
  color: #f1e9d2;
  font-family: 'Courier New', monospace;
  overflow-x: hidden;
  user-select: none;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #3a2a17;
  border: 3px solid #22160a;
  box-shadow: inset 0 0 0 2px #5a4326;
}
#title {
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 1px;
  color: #7CFC00;
  text-shadow: 2px 2px 0 #000;
}
#balance-box {
  font-size: 15px;
  color: #FFD700;
  font-weight: bold;
}
#spins-left {
  text-align: center;
  font-size: 13px;
  color: #cbb98a;
}
#spins-left span { color: #7CFC00; font-weight: bold; }

.grid5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: #241708;
  border: 3px solid #22160a;
  box-shadow: inset 0 0 0 2px #5a4326;
  padding: 4px;
}
#reel { grid-template-rows: repeat(3, 1fr); }
#reel .cell { aspect-ratio: 1/1; }

.grid5-6 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
  background: #100a04;
  border: 3px solid #22160a;
  box-shadow: inset 0 0 0 2px #5a4326;
  padding: 4px;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  aspect-ratio: 1/1;
  border-radius: 3px;
  background: #2c1e10;
  border: 1px solid #4a3319;
  transition: transform 0.15s, opacity 0.25s;
}
.cell.empty { background: #201408; border-color: #33220f; }

.cell .hp-badge {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 10px;
  color: #fff;
  background: rgba(0,0,0,0.55);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 1.3;
}

.block.earth { background: #7a4a21; }
.block.stone { background: #7d7d7d; }
.block.gold { background: linear-gradient(135deg, #ffe066, #d4af13); color:#3a2a00; }
.block.redstone { background: radial-gradient(circle, #c62828 40%, #5a1010 100%); }
.block.diamond { background: linear-gradient(135deg, #7df9ff, #14b8c4); color:#00303a; }
.block.obsidian { background: #140a24; border-color: #3a1f5c; }
.block.broken { background: #100a04 !important; opacity: 0.25; filter: grayscale(1); }

.pick.wood { background: #5a3d1e; }
.pick.iron { background: #b0b0b0; color:#222; }
.pick.gold_pick { background: linear-gradient(135deg, #ffe066, #d4af13); color:#3a2a00; }
.pick.diamond_pick { background: linear-gradient(135deg, #7df9ff, #14b8c4); color:#00303a; }
.pick.book { background: #8a5a2f; }
.pick.dynamite { background: #b22222; }

.cell.pop { animation: pop 0.35s ease; }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }

.cell.shatter { animation: shatter 0.4s ease forwards; }
@keyframes shatter { 0% { transform: scale(1); opacity: 1; } 60% { transform: scale(1.2) rotate(8deg); } 100% { transform: scale(0.2) rotate(20deg); opacity: 0; } }

#chests-row .cell {
  font-size: 22px;
  background: #241708;
  border: 1px dashed #5a4326;
}
#chests-row .cell.opened {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  color: #2a1a00;
  font-weight: bold;
  font-size: 13px;
  animation: pop 0.4s ease;
}

#result-banner {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  padding: 8px;
  border: 2px solid #22160a;
  min-height: 20px;
}
#result-banner.win { background: #1e4d1e; color: #7CFC00; }
#result-banner.lose { background: #4d1e1e; color: #ff6b6b; }
#result-banner.hidden { display: none; }

#controls { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row label { font-size: 13px; color: #cbb98a; }
#bet-controls { display: flex; gap: 6px; flex: 1; justify-content: flex-end; }
#bet-input {
  width: 140px;
  background: #241708;
  border: 2px solid #5a4326;
  color: #f1e9d2;
  font-family: inherit;
  font-size: 14px;
  padding: 6px;
  text-align: right;
}
.bet-btn {
  background: #3a2a17;
  border: 2px solid #5a4326;
  color: #f1e9d2;
  padding: 6px 10px;
  font-family: inherit;
  font-weight: bold;
}
#spin-btn {
  background: linear-gradient(180deg, #7CFC00, #4caf00);
  border: 3px solid #2a5a00;
  color: #123400;
  font-weight: bold;
  font-size: 17px;
  padding: 12px;
  letter-spacing: 1px;
  font-family: inherit;
}
#spin-btn:disabled { opacity: 0.5; }
#spin-btn:active:not(:disabled) { transform: translateY(1px); }

#legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: center;
  font-size: 10px;
  color: #cbb98a;
  margin-top: 4px;
}
.legend-item { display: flex; align-items: center; gap: 3px; }
.swatch { width: 10px; height: 10px; display: inline-block; border-radius: 2px; }
.swatch.earth { background: #7a4a21; }
.swatch.stone { background: #7d7d7d; }
.swatch.redstone { background: #c62828; }
.swatch.gold { background: #ffe066; }
.swatch.diamond { background: #7df9ff; }
.swatch.obsidian { background: #140a24; }
