/* Dungeon Crawler IO - Pixel Art Style */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0a;
  color: #ccc;
  font-family: monospace;
  overflow: hidden;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
}

/* ===== MAIN PAGE ===== */
.main-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#bg-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

.fog-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
  background: radial-gradient(ellipse at center, rgba(10,10,10,0.3) 0%, rgba(10,10,10,0.85) 70%, rgba(10,10,10,0.98) 100%);
  pointer-events: none;
}

.pixel-noise {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' width='1' height='1' fill='white'/%3E%3Crect x='2' y='2' width='1' height='1' fill='white'/%3E%3C/svg%3E");
  background-size: 4px 4px;
  pointer-events: none;
}

.main-ui {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
}

.game-title {
  font-size: clamp(20px, 5vw, 48px);
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255,215,0,0.5), 0 4px 0 #B8860B;
  margin-bottom: 10px;
  text-align: center;
  animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 20px rgba(255,215,0,0.5), 0 4px 0 #B8860B; }
  50% { text-shadow: 0 0 40px rgba(255,215,0,0.8), 0 4px 0 #B8860B; }
}

.game-subtitle {
  font-size: clamp(8px, 1.5vw, 14px);
  color: #888;
  margin-bottom: 30px;
}

.main-panel {
  background: rgba(20,20,30,0.9);
  border: 2px solid #444;
  border-radius: 4px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
}

.main-panel h3 { color: #FFD700; font-size: 12px; margin-bottom: 16px; }

.main-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  background: #2a2a3a;
  border: 2px solid #555;
  color: #FFD700;
  font-family: monospace;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: all 0.1s;
}

.main-btn:hover { background: #3a3a5a; border-color: #FFD700; transform: scale(1.02); }
.main-btn:active { transform: scale(0.98); }
.main-btn.secondary { color: #888; border-color: #444; }
.main-btn.secondary:hover { color: #ccc; border-color: #888; }

.room-input {
  display: flex; gap: 8px; margin-bottom: 8px;
}
.room-input input {
  flex: 1; padding: 10px;
  background: #1a1a2a; border: 2px solid #444; color: #fff;
  font-family: monospace; font-size: 10px;
  text-transform: uppercase;
}
.room-input input::placeholder { color: #555; }

.player-count {
  text-align: center; font-size: 10px; color: #666; margin-top: 16px;
}
.player-count span { color: #FFD700; }

.class-showcase {
  display: flex; justify-content: center; gap: 30px; margin-top: 24px;
}
.class-preview {
  text-align: center;
}
.class-icon {
  width: 48px; height: 48px; margin: 0 auto 8px;
  image-rendering: pixelated;
}
.class-preview span { font-size: 8px; color: #888; }

.public-rooms {
  margin-top: 16px;
}
.public-rooms h4 { font-size: 9px; color: #888; margin-bottom: 8px; }
.room-list { max-height: 120px; overflow-y: auto; }
.room-entry {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; background: #1a1a2a; margin-bottom: 4px; font-size: 8px;
  cursor: pointer;
}
.room-entry:hover { background: #2a2a4a; }
.room-entry .room-id { color: #FFD700; }
.room-entry .room-info { color: #888; }

/* ===== ROOM/JOIN PAGE ===== */
.join-container {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100vh; padding: 20px;
  background: #0a0a0a;
}

.join-panel {
  background: rgba(20,20,30,0.95); border: 2px solid #444;
  padding: 24px; max-width: 400px; width: 100%;
}

.join-panel h2 { color: #FFD700; font-size: 14px; margin-bottom: 20px; text-align: center; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 9px; color: #888; margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 10px;
  background: #1a1a2a; border: 2px solid #444; color: #fff;
  font-family: monospace; font-size: 10px;
}

.class-selector {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.class-option {
  flex: 1; min-width: 100px; padding: 12px 8px; text-align: center;
  background: #1a1a2a; border: 2px solid #444; cursor: pointer;
  font-family: monospace; font-size: 8px; color: #888;
}
.class-option:hover { border-color: #888; }
.class-option.selected { border-color: #FFD700; color: #FFD700; }
.class-option .class-opt-icon {
  width: 36px; height: 36px; margin: 0 auto 6px;
  image-rendering: pixelated;
}
.class-option .class-stats { font-size: 7px; color: #666; margin-top: 4px; }

.share-link {
  background: #1a1a2a; padding: 10px; font-size: 8px; color: #4169E1;
  text-align: center; margin-top: 12px; word-break: break-all;
  border: 1px solid #333; cursor: pointer;
}
.share-link:hover { color: #6495ED; }

/* ===== GAME PAGE ===== */
#game-canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  image-rendering: pixelated;
}

#hud-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }
#hud-container > * { pointer-events: auto; }
#dialog-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 20; pointer-events: none; }
#dialog-container > * { pointer-events: auto; }
#guide-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 30; pointer-events: none; }
#guide-container > * { pointer-events: auto; }

/* HUD Panels */
.hud-panel { position: absolute; }

.hud-stats {
  top: 10px; left: 10px; width: 250px;
  background: rgba(10,10,20,0.85); border: 1px solid #444;
  padding: 10px; font-size: 8px;
}

.stat-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.stat-label { width: 20px; color: #888; font-size: 8px; }
.stat-bar { flex: 1; height: 14px; background: #222; position: relative; border: 1px solid #333; }
.stat-fill { height: 100%; transition: width 0.2s; }
.stat-text { position: absolute; top: 1px; left: 50%; transform: translateX(-50%); font-size: 7px; color: #fff; text-shadow: 1px 1px 0 #000; }
.hp-fill { background: #2ecc40; }
.mana-fill { background: #0074d9; }
.xp-fill { background: #b10dc9; }

.stat-info { display: flex; gap: 10px; margin-top: 6px; font-size: 8px; }
.stat-info span { color: #888; }
#hud-level { color: #FFD700; }
#hud-gold { color: #DAA520; }
#hud-floor { color: #87CEEB; }
.shield-info { font-size: 8px; color: #6495ED; margin-top: 4px; }

.buffs-bar { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.buff-item {
  font-size: 7px; padding: 2px 5px;
  border: 1px solid #44AA44; background: rgba(20,40,20,0.7);
  animation: buffPulse 2s ease-in-out infinite;
}
.buff-item:first-child { animation-delay: 0s; }
@keyframes buffPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.hud-abilities {
  bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px;
  background: rgba(10,10,20,0.85); border: 1px solid #444; padding: 6px;
}

.ability-btn {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 8px; background: #2a2a3a; border: 1px solid #555;
  color: #ccc; cursor: pointer; min-width: 60px;
  font-family: monospace;
}
.ability-btn:hover { background: #3a3a5a; border-color: #FFD700; }
.ability-btn.disabled { opacity: 0.4; cursor: default; }
.ab-key { font-size: 10px; color: #FFD700; }
.ab-name { font-size: 6px; margin-top: 2px; }
.ab-cost { font-size: 6px; color: #4169E1; }
.consumable-btn { background: #1a2a1a; }
.consumable-btn:hover { background: #2a3a2a; }

.hud-side-buttons {
  top: 10px; right: 10px;
  display: flex; flex-direction: column; gap: 4px;
}

.hud-btn {
  padding: 8px 12px; background: rgba(10,10,20,0.85);
  border: 1px solid #444; color: #888; cursor: pointer;
  font-family: monospace; font-size: 8px;
}
.hud-btn:hover { color: #FFD700; border-color: #FFD700; }

.hud-log {
  bottom: 90px; left: 10px; width: 280px; max-height: 130px;
  background: rgba(10,10,20,0.7); border: 1px solid #333;
  padding: 6px; overflow-y: auto;
}

#combat-log { font-size: 7px; line-height: 1.6; }
.log-entry { opacity: 0.9; }

.hud-chat {
  bottom: 60px; left: 10px; width: 280px;
}
#chat-input {
  width: 100%; padding: 6px 8px;
  background: rgba(10,10,20,0.7); border: 1px solid #444;
  color: #fff; font-family: monospace; font-size: 9px;
  outline: none;
}
#chat-input:focus { border-color: #FFD700; background: rgba(10,10,20,0.9); }
#chat-input::placeholder { color: #555; }

/* Inventory Panel */
.inventory-panel {
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 350px; max-height: 80vh; overflow-y: auto;
  background: rgba(15,15,25,0.95); border: 2px solid #555;
  padding: 16px;
}

.inv-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.inv-header h3 { color: #FFD700; font-size: 12px; }
.close-btn { background: none; border: none; color: #888; font-size: 18px; cursor: pointer; }
.close-btn:hover { color: #fff; }

.inv-equipment { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.equip-slot { background: #1a1a2a; border: 1px solid #444; padding: 6px; }
.slot-label { font-size: 7px; color: #666; display: block; margin-bottom: 2px; }
.slot-item { font-size: 8px; color: #ccc; }

.inv-items { display: flex; flex-direction: column; gap: 4px; }
.inv-item {
  background: #1a1a2a; border: 1px solid #444; padding: 6px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 8px;
}
.inv-btns { display: flex; gap: 4px; }
.inv-action-btn {
  padding: 3px 6px; font-size: 7px; cursor: pointer;
  background: #2a2a3a; border: 1px solid #555; color: #ccc;
  font-family: monospace;
}
.inv-action-btn:hover { border-color: #FFD700; color: #FFD700; }
.inv-action-btn.drop:hover { border-color: #FF4444; color: #FF4444; }

/* Item detail popup */
.item-detail-panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(10,10,20,0.97); border: 2px solid #888; padding: 16px;
  min-width: 250px; max-width: 320px; z-index: 50; font-size: 9px;
}
.item-detail-header { font-size: 11px; margin-bottom: 8px; }
.item-rarity { font-size: 8px; margin-left: 4px; opacity: 0.7; }
.item-detail-slot { color: #666; font-size: 8px; margin-bottom: 6px; text-transform: capitalize; }
.item-stat { margin: 2px 0; color: #CCC; }
.item-mods { margin: 6px 0; padding: 4px; background: rgba(0,40,0,0.3); border-left: 2px solid #4a4; }
.item-skill { margin: 6px 0; padding: 4px; background: rgba(40,0,40,0.3); border-left: 2px solid #a4a; }
.item-gold { color: #DAA520; margin-top: 6px; }
.item-detail-actions { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }

/* Minimap */
.minimap-panel {
  top: 50px; right: 50px;
  background: rgba(15,15,25,0.95); border: 2px solid #555; padding: 8px;
}
.mm-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.mm-header h3 { font-size: 10px; color: #888; }
#minimap-canvas { border: 1px solid #333; }

/* Dialog Panel */
.dialog-panel {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  width: 450px; max-width: 90vw;
  background: rgba(15,15,25,0.95); border: 2px solid #FFD700;
  padding: 16px;
}

.dialog-header { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.npc-portrait { width: 40px; height: 40px; border: 1px solid #555; }
.npc-info h3 { font-size: 11px; color: #FFD700; }
.npc-desc { font-size: 7px; color: #888; }
.dialog-greeting { font-size: 9px; color: #aaa; font-style: italic; margin-bottom: 8px; }
.dialog-text { font-size: 9px; color: #ccc; margin-bottom: 12px; line-height: 1.5; }

.dialog-choices { display: flex; flex-direction: column; gap: 6px; }
.dialog-choice {
  padding: 8px 12px; background: #2a2a3a; border: 1px solid #555;
  color: #ccc; cursor: pointer; font-family: monospace; font-size: 8px;
  text-align: left;
}
.dialog-choice:hover { border-color: #FFD700; color: #FFD700; }
.dialog-choice.disabled { opacity: 0.4; cursor: default; }
.dialog-rewards { font-size: 8px; color: #FFD700; margin-top: 8px; }

.shop-panel { margin-top: 12px; }
.shop-panel h4 { font-size: 10px; color: #888; margin-bottom: 8px; }
.shop-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px; background: #1a1a2a; margin-bottom: 4px; font-size: 8px;
}
.shop-price { color: #DAA520; }
.shop-buy-btn {
  padding: 4px 8px; font-size: 7px; cursor: pointer;
  background: #2a2a3a; border: 1px solid #555; color: #FFD700;
  font-family: monospace;
}

/* Guide Panel */
.guide-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 600px; max-width: 95vw; max-height: 85vh; overflow-y: auto;
  background: rgba(10,10,20,0.97); border: 2px solid #FFD700;
  padding: 20px;
}

.guide-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.guide-header h2 { font-size: 14px; color: #FFD700; }

.guide-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.guide-tab {
  padding: 6px 10px; background: #1a1a2a; border: 1px solid #444;
  color: #888; cursor: pointer; font-family: monospace; font-size: 8px;
}
.guide-tab:hover { color: #ccc; }
.guide-tab.active { border-color: #FFD700; color: #FFD700; background: #2a2a3a; }

.guide-content { font-size: 8px; line-height: 1.6; }

/* Bestiary */
.tier-header { margin: 12px 0 6px; font-size: 10px; }
.tier-1 { color: #ccc; } .tier-2 { color: #00FF00; } .tier-3 { color: #4169E1; }
.tier-4 { color: #9B30FF; } .tier-5 { color: #FFD700; } .tier-6 { color: #FF4400; }

.bestiary-entry {
  display: flex; gap: 8px; padding: 6px; background: #1a1a2a; margin-bottom: 4px; align-items: flex-start;
}
.bestiary-entry.undiscovered { opacity: 0.4; }
.monster-icon { width: 24px; height: 24px; min-width: 24px; border: 1px solid #333; }
.monster-info { flex: 1; }
.monster-name { display: block; color: #ccc; font-size: 9px; }
.monster-stats { display: block; color: #888; font-size: 7px; }
.monster-desc { display: block; color: #666; font-size: 7px; margin-top: 2px; }
.kill-count { display: block; color: #FF4444; font-size: 7px; }

/* Zone */
.zone-entry { background: #1a1a2a; padding: 10px; margin-bottom: 6px; }
.zone-entry.undiscovered { opacity: 0.5; }
.zone-entry h3 { font-size: 10px; color: #87CEEB; }
.zone-floors { color: #888; font-size: 8px; }
.zone-details { margin-top: 6px; }
.zone-details span { display: block; color: #666; }

/* Classes */
.class-entry { border: 2px solid #444; padding: 12px; margin-bottom: 10px; }
.class-stats { font-size: 8px; color: #888; margin: 6px 0; }
.class-passive { font-size: 7px; color: #666; margin-bottom: 8px; }
.ability-entry { background: #1a1a2a; padding: 6px; margin-bottom: 3px; }
.ab-name-guide { color: #FFD700; }
.ab-cost-guide { color: #4169E1; margin-left: 8px; }
.ab-desc { display: block; color: #888; margin-top: 2px; }
.ab-unlock { display: block; color: #FF4444; font-size: 7px; }

/* Items guide */
.items-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 12px; }
.item-entry { background: #1a1a2a; padding: 6px; }
.item-entry span { display: block; font-size: 7px; color: #888; }
.item-name { color: #ccc !important; font-size: 8px !important; }
.item-slot { color: #666 !important; }
.item-classes { color: #555 !important; }
.rarity-list { margin-bottom: 12px; }
.rarity-badge { font-size: 9px; }
.skills-list { margin-bottom: 12px; }
.skill-entry { padding: 3px 0; }
.skill-name { color: #9B30FF; }

/* Controls */
.controls-guide { font-size: 9px; }
.control-row { padding: 4px 0; }
kbd { background: #2a2a3a; border: 1px solid #555; padding: 2px 5px; color: #FFD700; font-size: 8px; }
.controls-guide ul { margin: 8px 0 0 16px; }
.controls-guide li { color: #888; margin-bottom: 4px; }

/* Notifications */
.hud-notification {
  position: fixed; top: 20%; left: 50%; transform: translateX(-50%);
  font-family: monospace; font-size: 14px;
  text-shadow: 2px 2px 0 #000; z-index: 100;
  animation: notifIn 0.3s ease-out;
  pointer-events: none;
}
.hud-notification.fade-out { animation: notifOut 0.5s ease-in forwards; }
@keyframes notifIn { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes notifOut { from { opacity: 1; } to { opacity: 0; transform: translateX(-50%) translateY(-20px); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #444; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* Mobile */
@media (max-width: 768px) {
  .hud-stats { width: 160px; font-size: 7px; padding: 6px; }
  .hud-abilities { flex-wrap: wrap; max-width: 95vw; bottom: 4px; padding: 4px; gap: 2px; }
  .ability-btn { min-width: 40px; padding: 4px 2px; font-size: 6px; }
  .ab-key { font-size: 8px; }
  .ab-name { font-size: 5px; }
  .ab-cost { font-size: 5px; }
  .consumable-btn { min-width: 35px; }
  .hud-side-buttons { gap: 2px; }
  .hud-btn { padding: 6px 8px; font-size: 7px; }
  .hud-log { width: 200px; max-height: 80px; bottom: 70px; font-size: 6px; }
  .hud-chat { bottom: 50px; width: 200px; }
  #chat-input { font-size: 8px; padding: 4px; }
  .dialog-panel { width: 95vw; bottom: 50px; padding: 10px; }
  .dialog-choice { padding: 10px; font-size: 9px; } /* Bigger touch targets */
  .guide-panel { width: 95vw; padding: 12px; }
  .inventory-panel { width: 95vw; }
  .inv-item { padding: 8px; } /* Bigger touch targets */
  .inv-action-btn { padding: 6px 10px; font-size: 8px; }
  .item-detail-panel { min-width: 90vw; }
  .game-title { font-size: 20px; }
  .class-selector { gap: 4px; }
  .class-option { padding: 8px 4px; min-width: 60px; font-size: 7px; }
  .main-panel { padding: 16px; }
  .buffs-bar { gap: 2px; }
  .buff-item { font-size: 6px; padding: 1px 3px; }

  /* Mobile d-pad overlay */
  .mobile-dpad { display: flex !important; }
}

/* Mobile directional pad - hidden on desktop */
.mobile-dpad {
  display: none;
  position: fixed; bottom: 80px; right: 10px; z-index: 15;
  flex-direction: column; align-items: center; gap: 2px;
  pointer-events: auto;
}
.dpad-row { display: flex; gap: 2px; }
.dpad-btn {
  width: 44px; height: 44px; background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2); color: #fff;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  user-select: none; touch-action: manipulation;
}
.dpad-btn:active { background: rgba(255,255,255,0.3); }
