/* =====================================================
   MORTSEB GAMES VALLEY - Pixel Art RPG Style
   ===================================================== */

@font-face {
  font-family: 'PixelFont';
  src: local('Press Start 2P');
}

:root {
  /* Retro Color Palette */
  --sky: #87ceeb;
  --grass-light: #7ec850;
  --grass-dark: #5a9c32;
  --dirt: #c4a66a;
  --water: #5b8dd9;
  --water-dark: #4a7bc8;
  --tree-trunk: #8b5a2b;
  --tree-leaves: #228b22;
  --stone: #808080;
  --stone-light: #a0a0a0;
  --wood: #deb887;
  --wood-dark: #b8860b;
  --roof-red: #cd5c5c;
  --roof-blue: #6495ed;
  
  /* UI Colors */
  --ui-bg: rgba(0, 0, 0, 0.85);
  --ui-border: #ffd700;
  --ui-text: #ffffff;
  --ui-text-dim: #aaaaaa;
  --ui-accent: #ffd700;
  --ui-highlight: #ff6b6b;
  
  /* Fonts */
  --font-pixel: 'Press Start 2P', monospace;
  --font-ui: 'Press Start 2P', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: var(--font-pixel);
  color: var(--ui-text);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ===== Game Canvas ===== */
#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ===== HUD Overlay ===== */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 100;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  pointer-events: auto;
}

.brand-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  border: 2px solid #fff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  color: #000;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.brand-text {
  font-size: 10px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.hud-title {
  text-align: center;
}

.title-main {
  display: block;
  font-size: 14px;
  color: #ffd700;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
  letter-spacing: 2px;
}

.title-sub {
  display: block;
  font-size: 8px;
  color: #aaa;
  text-shadow: 1px 1px 0 #000;
  margin-top: 4px;
}

.hud-nav {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.nav-link {
  font-size: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.6);
  border: 2px solid #555;
  color: #aaa;
  text-decoration: none;
  transition: all 0.1s;
}

.nav-link:hover {
  border-color: #ffd700;
  color: #fff;
  background: rgba(255,215,0,0.1);
}

/* ===== Intro Panel ===== */
.intro-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.5s ease;
}

.intro-panel.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.intro-content {
  text-align: center;
  max-width: 500px;
  padding: 40px;
  background: var(--ui-bg);
  border: 4px solid var(--ui-border);
  box-shadow: 0 0 0 4px #000, 8px 8px 0 rgba(0,0,0,0.5);
}

.intro-icon {
  font-size: 48px;
  margin-bottom: 20px;
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.intro-content h1 {
  font-size: 16px;
  color: var(--ui-accent);
  margin-bottom: 16px;
  text-shadow: 2px 2px 0 #000;
  line-height: 1.5;
}

.intro-content p {
  font-size: 10px;
  color: var(--ui-text-dim);
  line-height: 1.8;
  margin-bottom: 24px;
}

.intro-controls {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 30px;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 8px;
  color: var(--ui-text-dim);
}

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: linear-gradient(to bottom, #444, #222);
  border: 2px solid #666;
  border-bottom-width: 4px;
  border-radius: 4px;
  font-size: 12px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

.key.small {
  min-width: 24px;
  height: 24px;
  font-size: 10px;
}

.intro-start {
  font-family: var(--font-pixel);
  font-size: 12px;
  padding: 14px 28px;
  background: linear-gradient(to bottom, #ffd700, #ff8c00);
  border: none;
  border-bottom: 4px solid #cc6600;
  color: #000;
  cursor: pointer;
  transition: all 0.1s;
}

.intro-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 #cc6600;
}

.intro-start:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.intro-hint {
  font-size: 8px;
  color: #888;
  margin-top: 20px;
}

/* ===== Dialog ===== */
.dialog {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 150;
  animation: fadeIn 0.2s ease;
}

.dialog[hidden] {
  display: none;
}

.dialog-content {
  width: 90%;
  max-width: 450px;
  max-height: 80vh;
  background: var(--ui-bg);
  border: 4px solid var(--ui-border);
  box-shadow: 0 0 0 4px #000, 8px 8px 0 rgba(0,0,0,0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255,215,0,0.1);
  border-bottom: 2px solid var(--ui-border);
}

.dialog-icon {
  font-size: 24px;
}

.dialog-title {
  font-size: 12px;
  color: var(--ui-accent);
  text-shadow: 2px 2px 0 #000;
}

.dialog-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.dialog-footer {
  padding: 12px 16px;
  background: rgba(0,0,0,0.5);
  border-top: 2px solid #333;
}

.dialog-hint {
  font-size: 8px;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Leaderboard in Dialog */
.leaderboard-empty {
  text-align: center;
  padding: 20px;
}

.leaderboard-empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.leaderboard-empty p {
  font-size: 10px;
  color: var(--ui-text-dim);
  line-height: 1.8;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 40px 1fr 60px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border: 2px solid #333;
}

.leaderboard-row.header {
  background: transparent;
  border: none;
  font-size: 8px;
  color: #888;
}

.leaderboard-rank {
  font-size: 14px;
  color: var(--ui-accent);
  text-shadow: 1px 1px 0 #000;
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-name {
  font-size: 10px;
}

.leaderboard-score {
  font-size: 10px;
  text-align: right;
  color: #4ade80;
}

/* ===== Mobile Controls ===== */
.mobile-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 100;
  pointer-events: none;
}

@media (max-width: 768px), (hover: none) {
  .mobile-controls {
    display: flex;
  }
  
  .hud-nav {
    display: none;
  }
}

.dpad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  gap: 4px;
  pointer-events: auto;
}

.dpad-btn {
  width: 50px;
  height: 50px;
  background: rgba(0,0,0,0.7);
  border: 3px solid #555;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.1s;
  -webkit-user-select: none;
  user-select: none;
}

.dpad-btn:active {
  background: rgba(255,215,0,0.3);
  border-color: #ffd700;
}

.dpad-up { grid-area: up; }
.dpad-down { grid-area: down; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }

.action-btn {
  width: 60px;
  height: 60px;
  background: linear-gradient(to bottom, #ffd700, #ff8c00);
  border: 3px solid #fff;
  border-radius: 50%;
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #000;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 0 #cc6600;
  -webkit-user-select: none;
  user-select: none;
}

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

/* ===== Interact Prompt ===== */
.interact-prompt {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--ui-bg);
  border: 2px solid var(--ui-border);
  font-size: 10px;
  color: #fff;
  z-index: 90;
  animation: pulse 1s ease infinite;
  display: flex;
  align-items: center;
  gap: 8px;
}

.interact-prompt[hidden] {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.8; transform: translateX(-50%) scale(1.02); }
}

/* ===== Game House Info (for future games) ===== */
.house-info {
  text-align: center;
  padding: 10px;
}

.house-info-title {
  font-size: 12px;
  color: var(--ui-accent);
  margin-bottom: 12px;
}

.house-info-desc {
  font-size: 9px;
  color: var(--ui-text-dim);
  line-height: 1.8;
  margin-bottom: 16px;
}

.house-info-btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 10px 20px;
  background: linear-gradient(to bottom, #4ade80, #22c55e);
  border: none;
  border-bottom: 3px solid #16a34a;
  color: #000;
  cursor: pointer;
}

.house-info-btn:hover {
  transform: translateY(-1px);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #111;
}

::-webkit-scrollbar-thumb {
  background: #444;
  border: 2px solid #111;
}

::-webkit-scrollbar-thumb:hover {
  background: #666;
}

/* ===== Connection Status ===== */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.7);
  border: 2px solid #333;
  color: #888;
}

.connection-status.connected {
  border-color: #4ade80;
  color: #4ade80;
}

.connection-status.disconnected {
  border-color: #f87171;
  color: #f87171;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.5s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Toast Notifications ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 20px;
  background: var(--ui-bg);
  border: 2px solid var(--ui-border);
  font-size: 10px;
  color: #fff;
  z-index: 180;
  opacity: 0;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  font-size: 14px;
}

/* ===== Player Name Tags ===== */
.player-nametag {
  position: absolute;
  font-size: 8px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.8);
  border: 1px solid currentColor;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .intro-content {
    padding: 24px;
    margin: 16px;
  }
  
  .intro-content h1 {
    font-size: 12px;
  }
  
  .intro-controls {
    gap: 24px;
  }
  
  .key {
    min-width: 28px;
    height: 28px;
    font-size: 10px;
  }
  
  .hud-top {
    padding: 8px 12px;
  }
  
  .title-main {
    font-size: 10px;
  }
  
  .brand-text {
    display: none;
  }
}
