* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Verdana, sans-serif;
  background: #f0f4f8;
  color: #1e293b;
}

#topbar {
  background: #ffcc00;
  border-bottom: 6px solid #e0a800;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: 1px; }
.player-info { display: flex; gap: 14px; align-items: center; font-weight: 600; }
.tier-badge {
  background: #d32f2f;
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 13px;
}
.cred-display { background: #111827; color: #ffcc00; padding: 4px 10px; border-radius: 12px; }

#tabs {
  display: flex;
  background: #1e293b;
  overflow-x: auto;
}
.tab-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 4px solid transparent;
  white-space: nowrap;
}
.tab-btn:hover { color: #fff; }
.tab-btn.active { color: #ffcc00; border-bottom-color: #ffcc00; }

main { padding: 16px 20px 60px; max-width: 1100px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.hint { color: #475569; font-size: 14px; }

canvas {
  display: block;
  background: #7fd858;
  border-radius: 10px;
  border: 4px solid #1e293b;
  margin: 0 auto;
  max-width: 100%;
}

#onlinePlayersBox { margin-top: 14px; background: #fff; border-radius: 10px; padding: 10px 16px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
#onlinePlayersBox ul { list-style: none; padding: 0; margin: 6px 0 0; }
#onlinePlayersBox li { padding: 3px 0; font-size: 14px; }

.store-columns, .inventory-columns, .market-columns { display: flex; gap: 24px; flex-wrap: wrap; }
.store-columns > div, .inventory-columns > div, .market-columns > div { flex: 1 1 300px; }

.item-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.item-card {
  background: #fff;
  border: 3px solid #1e293b;
  border-radius: 10px;
  padding: 10px;
  width: 160px;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.15);
  font-size: 13px;
  position: relative;
}
.item-card.locked { opacity: 0.55; }
.item-card.equipped { border-color: #22c55e; }
.item-name { font-weight: 700; margin-bottom: 4px; }
.item-stat { color: #334155; margin-bottom: 4px; }
.item-cost { font-weight: 700; color: #b45309; margin-bottom: 6px; }
.owned-tag { color: #16a34a; font-size: 11px; font-weight: 700; }
.locked-tag { color: #dc2626; font-size: 11px; font-weight: 700; }
.thumb { width: 100%; height: 80px; object-fit: cover; border-radius: 6px; border: 2px solid #94a3b8; margin-bottom: 6px; background: #e5e7eb; }

button {
  background: #d32f2f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
button:hover { background: #b91c1c; }
input, select {
  padding: 8px;
  border-radius: 8px;
  border: 2px solid #94a3b8;
  font-size: 13px;
  margin: 4px 0;
  width: 100%;
}

.buy-btn, .equip-btn { background: #16a34a; }
.buy-btn:hover, .equip-btn:hover { background: #15803d; }
.unequip-btn, .cancel-btn { background: #6b7280; }
.unequip-btn:hover, .cancel-btn:hover { background: #4b5563; }
.buy-listing-btn { background: #2563eb; }
.buy-listing-btn:hover { background: #1d4ed8; }

.build-layout { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.palette { display: flex; flex-direction: column; gap: 6px; }
.brick-swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 3px solid #1e293b;
  padding: 0;
}
.brick-swatch.selected { outline: 3px solid #ffcc00; }
.brick-swatch.eraser { background: #fff; color: #1e293b; font-weight: 900; }
.build-controls { display: flex; flex-direction: column; gap: 8px; width: 200px; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.level-btn {
  background: #3b82f6;
  border: 3px solid #1e293b;
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
  color: #fff;
  font-size: 12px;
}
.level-btn.boss { background: #dc2626; }
.level-btn .lvl-num { font-size: 18px; font-weight: 900; }
.level-btn .lvl-name { font-size: 11px; margin: 2px 0; }
.level-btn .lvl-reward { font-weight: 700; }

.battle-area { margin-top: 20px; background: #0f172a; border-radius: 12px; padding: 16px; }
.battle-area.hidden { display: none; }
.battle-bars { color: #fff; margin-top: 10px; }
.bar-label { font-size: 13px; margin-top: 6px; }
.hp-bar { background: #334155; border-radius: 6px; overflow: hidden; height: 16px; }
.hp-fill { height: 100%; transition: width 0.3s; }
.hp-fill.player { background: #22c55e; width: 100%; }
.hp-fill.enemy { background: #ef4444; width: 100%; }
.battle-log {
  background: #111827;
  color: #d1d5db;
  font-size: 12px;
  height: 100px;
  overflow-y: auto;
  border-radius: 6px;
  padding: 8px;
  margin-top: 10px;
}
.battle-buttons { display: flex; gap: 10px; margin-top: 10px; }

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #ffcc00;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 999;
}
#toast.show { opacity: 1; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff;
  border: 4px solid #1e293b;
  border-radius: 14px;
  padding: 24px;
  width: 320px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 6px 6px 0 rgba(0,0,0,0.3);
}
.modal-box h2 { margin-top: 0; }
.modal-box input { text-align: center; }
