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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #112233;
  font-family: 'Fredoka', sans-serif;
  color: #ffffff;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1b4b72;
}

canvas#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

/* UI Overlay */
.ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.interactive {
  pointer-events: auto;
}

/* Top bar: Level, XP, Coins */
.top-bar {
  position: absolute;
  top: 18px;
  left: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  z-index: 10;
}

.hud-card {
  background: #252b42;
  border: 4px solid #141724;
  box-shadow: 0 6px 0 #0f111a, inset 0 2px 0 rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Health & Energy Card */
.health-energy-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 14px;
}

.hearts-container {
  display: flex;
  gap: 4px;
  font-size: 16px;
  line-height: 1;
}

.heart {
  display: inline-block;
  transition: transform 0.15s;
}

.heart.empty {
  filter: grayscale(1) opacity(0.35);
}

.energy-bar-container {
  width: 130px;
  height: 14px;
  background: #141724;
  border: 2px solid #0f111a;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.energy-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #facc15 0%, #ca8a04 100%);
  box-shadow: 0 0 8px #facc15;
  transition: width 0.2s ease-out;
}

.energy-label {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #141724;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.level-badge {
  background: #f59e0b;
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 3px solid #b45309;
  box-shadow: 0 3px 0 #78350f;
  text-shadow: 1px 1px 0 #78350f;
}

.xp-bar-container {
  width: 160px;
  height: 16px;
  background: #141724;
  border: 3px solid #0f111a;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

.xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  border-radius: 4px;
  box-shadow: 0 0 10px #4ade80;
  transition: width 0.25s ease-out;
}

.coins-display {
  color: #facc15;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 2px 2px 0 #713f12;
}

/* Top right buttons */
.top-right {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  gap: 12px;
  z-index: 10;
}

.btn-icon {
  background: #3b82f6;
  border: 3px solid #1e40af;
  box-shadow: 0 5px 0 #1e3a8a, inset 0 2px 0 rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Fredoka', sans-serif;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-icon:hover {
  background: #60a5fa;
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #1e3a8a;
}

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

.btn-multi {
  background: #8b5cf6;
  border-color: #5b21b6;
  box-shadow: 0 5px 0 #4c1d95, inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.btn-multi:hover {
  background: #a78bfa;
  box-shadow: 0 7px 0 #4c1d95;
}

.btn-multi:active {
  box-shadow: 0 2px 0 #4c1d95;
}

/* Bottom Hotbar / Inventory */
.bottom-bar {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: #252b42;
  border: 4px solid #141724;
  box-shadow: 0 8px 0 #0f111a, inset 0 2px 0 rgba(255, 255, 255, 0.15);
  padding: 10px 14px;
  border-radius: 20px;
  z-index: 10;
}

.slot {
  width: 58px;
  height: 58px;
  background: #1a1e2e;
  border: 3px solid #2e3550;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slot:hover {
  background: #283049;
  border-color: #38bdf8;
  transform: translateY(-4px) scale(1.05);
}

.slot.active {
  border-color: #facc15;
  background: #3b3524;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-6px) scale(1.1);
}

.slot-icon {
  font-size: 26px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.slot-count {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #ffffff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.slot-key {
  position: absolute;
  top: 3px;
  left: 5px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #64748b;
}

/* Modals */
.modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #252b42;
  border: 5px solid #141724;
  border-radius: 20px;
  padding: 24px;
  min-width: 380px;
  max-width: 90vw;
  box-shadow: 0 16px 0 #0f111a, 0 30px 60px rgba(0, 0, 0, 0.8);
  z-index: 50;
  display: none;
}

.modal.open {
  display: block;
  animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  0% { transform: translate(-50%, -45%) scale(0.9); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 3px solid #1a1e2e;
  padding-bottom: 12px;
}

.modal-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: #facc15;
  text-shadow: 2px 2px 0 #713f12;
}

.modal-close {
  background: #ef4444;
  border: 3px solid #991b1b;
  box-shadow: 0 3px 0 #7f1d1d;
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  border-radius: 8px;
  cursor: pointer;
  padding: 4px 10px;
}

.modal-close:hover {
  background: #f87171;
}

/* Crafting grid */
.craft-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}

.craft-card {
  background: #1a1e2e;
  border: 3px solid #2e3550;
  box-shadow: 0 4px 0 #141724;
  border-radius: 14px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.craft-card:hover {
  background: #2a334f;
  border-color: #38bdf8;
  transform: translateY(-3px);
  box-shadow: 0 7px 0 #141724;
}

.craft-card.disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
}

.craft-card.disabled:hover {
  transform: none;
  background: #1a1e2e;
  border-color: #2e3550;
  box-shadow: 0 4px 0 #141724;
}

.craft-cost {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-align: center;
}

/* Multiplayer Modal */
.multi-section {
  margin-bottom: 18px;
}

.input-group {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

input[type="text"] {
  flex: 1;
  background: #141724;
  border: 3px solid #2e3550;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  font-family: 'Fredoka', sans-serif;
  font-size: 15px;
  outline: none;
}

input[type="text"]:focus {
  border-color: #38bdf8;
}

.btn-action {
  background: #10b981;
  color: #ffffff;
  border: 3px solid #047857;
  box-shadow: 0 4px 0 #064e3b;
  padding: 10px 18px;
  border-radius: 10px;
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-action:hover {
  background: #34d399;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #064e3b;
}

.btn-action:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #064e3b;
}

.room-code-badge {
  background: #141724;
  border: 2px dashed #f59e0b;
  padding: 10px 14px;
  border-radius: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: #facc15;
  display: inline-block;
  margin-top: 6px;
}

.btn-skills {
  background: #f59e0b;
  border-color: #b45309;
  box-shadow: 0 5px 0 #78350f, inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.btn-skills:hover {
  background: #fbbf24;
  box-shadow: 0 7px 0 #78350f;
}

/* Skill Tree Grid */
.modal-skills {
  min-width: 520px;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-height: 440px;
  overflow-y: auto;
  padding: 6px;
}

.skill-category {
  background: #1a1e2e;
  border: 3px solid #2e3550;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 2px solid #283049;
}

.skill-card {
  background: #252b42;
  border: 2px solid #3b4261;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.skill-card:hover {
  border-color: #facc15;
  background: #333a57;
  transform: translateY(-2px);
}

.skill-card.unlocked {
  background: #143528;
  border-color: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.skill-card.unlocked:hover {
  transform: none;
  cursor: default;
}

.skill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.skill-name {
  font-weight: 700;
  font-size: 13px;
  color: #ffffff;
}

.skill-desc {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.skill-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 2px 6px;
  border-radius: 4px;
}

.skill-badge.unlocked {
  background: #22c55e;
  color: #ffffff;
}

.skill-badge.available {
  background: #f59e0b;
  color: #000000;
}

/* Floating combat / loot text */
.floating-text {
  position: absolute;
  font-family: 'Fredoka', sans-serif;
  font-weight: 800;
  pointer-events: none;
  animation: floatBounce 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0 3px 6px rgba(0,0,0,0.6);
  z-index: 40;
}

@keyframes floatBounce {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { transform: translateY(-16px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-50px) scale(1); opacity: 0; }
}

/* Floating helper hint */
.helper-hint {
  position: absolute;
  bottom: 102px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.1);
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
