/* Construye Nariño — Estética pixel-art tipo Minecraft:
   biseles marcados de 3-4 px, sin bordes redondeados, sin filtrado suave. */

:root {
  --wj-verde: #52a535;
  --wj-amarillo: #e8c825;
  --wj-azul: #0c2439;
  --wj-panel: #c6c6c6;
  --wj-panel-dark: #555;
  --wj-panel-light: #fff;
  color-scheme: dark;
}

* { box-sizing: border-box; border-radius: 0 !important; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: var(--wj-azul);
  font-family: "Courier New", monospace;
  color: #f5f5f5;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#game-canvas { display: block; width: 100vw; height: 100vh; }

.hidden { display: none !important; }

/* ---------- Cubiertas de pantalla completa ---------- */
.wj-cover {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #1a5276 0%, var(--wj-azul) 100%);
  text-align: center; padding: 12px;
}

.wj-logo {
  font-size: clamp(2rem, 7vw, 3.5rem); font-weight: bold; line-height: 1.05;
  color: var(--wj-amarillo);
  text-shadow: 4px 4px 0 #6d4d00, 8px 8px 0 rgba(0,0,0,.4);
  letter-spacing: .08em; margin-bottom: 18px;
}

#loading-text { color: #cfe3f0; font-size: 1.05rem; letter-spacing: .05em; }

/* Aviso de rotación (móvil vertical) */
#rotate { z-index: 90; background: var(--wj-azul); }
.wj-rotate-icon { font-size: 4rem; animation: wj-tilt 1.2s infinite steps(2); }
@keyframes wj-tilt { 50% { transform: rotate(-90deg); } }
.wj-rotate-text { font-size: 1.6rem; font-weight: bold; color: var(--wj-amarillo); margin-top: 10px; }
.wj-rotate-sub { color: #cfe3f0; margin-top: 8px; line-height: 1.5; }

/* ---------- Paneles con bisel Minecraft ---------- */
.wj-panel {
  background: var(--wj-panel); color: #2b2b2b;
  border-top: 4px solid var(--wj-panel-light);
  border-left: 4px solid var(--wj-panel-light);
  border-right: 4px solid var(--wj-panel-dark);
  border-bottom: 4px solid var(--wj-panel-dark);
  box-shadow: 0 0 0 4px #000, 0 12px 32px rgba(0,0,0,.5);
  padding: 18px 22px; max-width: 480px; width: min(94vw, 480px);
  max-height: 92vh; overflow-y: auto;
}

.wj-title { font-size: 1.5rem; font-weight: bold; color: #1c4587; letter-spacing: .06em;
  text-shadow: 2px 2px 0 rgba(255,255,255,.6); margin-bottom: 4px; }
.wj-title-sm { font-size: 1.15rem; font-weight: bold; color: #1c4587; margin-bottom: 8px; }
.wj-subtitle { font-size: .82rem; color: #444; line-height: 1.45; margin-bottom: 10px; }

#avatar-preview { display: block; margin: 0 auto 6px; image-rendering: pixelated;
  background: #9dc3e6; border: 3px solid #555; }

.wj-row { margin: 8px 0; text-align: left; }
.wj-row label { display: block; font-size: .8rem; font-weight: bold; margin-bottom: 4px; }

.wj-row input, #chat-input {
  width: 100%; padding: 8px 10px; font: bold 1rem "Courier New", monospace;
  background: #1e1e1e; color: #eee; border: 3px solid;
  border-color: #555 #fff #fff #555; outline: none;
}

.wj-avatar-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.wj-opt span { font-size: .75rem; font-weight: bold; display: block; margin-bottom: 3px; }
.wj-swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.wj-swatch {
  width: 24px; height: 24px; border: 3px solid;
  border-color: #fff #555 #555 #fff; cursor: pointer; padding: 0;
  font-size: 11px; line-height: 1; color: #222;
}
.wj-swatch.sel { border-color: var(--wj-amarillo); outline: 2px solid #6d4d00; }

.wj-btn {
  display: block; width: 100%; margin-top: 12px; padding: 12px;
  font: bold 1.05rem "Courier New", monospace; letter-spacing: .08em;
  color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.5); cursor: pointer;
  background: var(--wj-verde);
  border-top: 4px solid #8ed470; border-left: 4px solid #8ed470;
  border-right: 4px solid #2d6417; border-bottom: 4px solid #2d6417;
}
.wj-btn:active { transform: translate(2px, 2px); }

.wj-error { margin-top: 10px; color: #a40000; font-weight: bold; font-size: .85rem; }
.wj-credits { margin-top: 12px; font-size: .68rem; color: #666; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }

#crosshair {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 22px; color: rgba(255,255,255,.85); text-shadow: 1px 1px 0 rgba(0,0,0,.6);
  pointer-events: none;
}

#topbar {
  position: fixed; top: 8px; left: 8px; right: 8px; display: flex; gap: 8px;
  align-items: center; font-size: .85rem; pointer-events: none;
}
#topbar span {
  background: rgba(0,0,0,.55); padding: 5px 9px; border: 2px solid rgba(255,255,255,.25);
}
#pos-indicator { color: #cfe3f0; }
.wj-mini-btn {
  pointer-events: auto; margin-left: auto; width: 34px; height: 34px;
  font: bold 1rem "Courier New", monospace; color: #fff; cursor: pointer;
  background: rgba(0,0,0,.55); border: 2px solid rgba(255,255,255,.35);
}
#fullscreen-btn { margin-left: 0; }

/* Barra rápida de materiales */
#hotbar {
  position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%);
  display: flex; gap: 2px; background: rgba(0,0,0,.45); padding: 3px;
  border: 3px solid #222; box-shadow: 0 0 0 2px rgba(255,255,255,.2);
}
.wj-slot {
  width: 46px; height: 46px; position: relative; cursor: pointer;
  border: 3px solid; border-color: #555 #fff #fff #555; background: rgba(139,139,139,.55);
  padding: 0;
}
.wj-slot canvas { width: 100%; height: 100%; display: block; }
.wj-slot.sel { border-color: #fff; outline: 3px solid var(--wj-amarillo); z-index: 1; }
.wj-slot .wj-key {
  position: absolute; top: 0; left: 2px; font-size: 10px; color: #fff;
  text-shadow: 1px 1px 0 #000;
}

#mine-progress {
  position: fixed; left: 50%; top: 56%; transform: translateX(-50%);
  width: 120px; height: 12px; background: rgba(0,0,0,.6); border: 2px solid #fff;
}
#mine-bar { height: 100%; width: 0; background: var(--wj-amarillo); }

/* Tarjeta del sitio turístico */
#site-card {
  position: fixed; top: 52px; left: 50%; transform: translateX(-50%);
  max-width: min(92vw, 460px); text-align: center; padding: 10px 16px;
  background: rgba(12,36,57,.88); border: 3px solid var(--wj-amarillo);
  box-shadow: 4px 4px 0 rgba(0,0,0,.5); pointer-events: none;
}
#site-name { font-weight: bold; color: var(--wj-amarillo); font-size: 1rem; letter-spacing: .04em; }
#site-fact { font-size: .8rem; color: #dceaf5; margin-top: 4px; line-height: 1.4; }

/* Chat */
#chat-box { position: fixed; left: 8px; bottom: 70px; width: min(78vw, 380px); }
#chat-log { max-height: 30vh; overflow-y: auto; font-size: .8rem; line-height: 1.45;
  display: flex; flex-direction: column; justify-content: flex-end; }
#chat-log div { background: rgba(0,0,0,.45); padding: 2px 7px; margin-top: 2px; word-wrap: break-word; }
#chat-log b { color: var(--wj-amarillo); }
#chat-log .wj-sys { color: #9fd48a; font-style: italic; }
#chat-form { margin-top: 4px; }

/* Controles táctiles */
#joystick {
  position: fixed; left: 4vw; bottom: 10vh; width: 118px; height: 118px;
  background: rgba(0,0,0,.35); border: 3px solid rgba(255,255,255,.4);
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,.55); border: 3px solid #fff;
}
#touch-buttons {
  position: fixed; right: 3vw; bottom: 8vh; display: grid;
  grid-template-columns: repeat(2, 62px); gap: 10px; justify-items: center;
}
.wj-touch-btn {
  width: 62px; height: 62px; font-size: 1.5rem; color: #fff; cursor: pointer;
  background: rgba(0,0,0,.4); border: 3px solid rgba(255,255,255,.5);
  text-shadow: 1px 1px 0 #000; padding: 0;
}
.wj-touch-btn:active, .wj-touch-btn.on { background: rgba(232,200,37,.55); }
.wj-touch-small { width: 52px; height: 52px; font-size: 1.1rem; }

#help p { font-size: .82rem; line-height: 1.5; margin: 6px 0; text-align: left; }
.wj-help-tip { color: #1c4587; font-weight: bold; }

#toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.75); color: var(--wj-amarillo); font-weight: bold;
  padding: 8px 14px; border: 2px solid var(--wj-amarillo); pointer-events: none;
  max-width: 90vw; text-align: center;
}

@media (max-width: 760px) {
  #chat-box { bottom: auto; top: 46px; width: min(60vw, 300px); }
  #chat-log { max-height: 20vh; font-size: .7rem; }
  #hotbar { bottom: 4px; }
  .wj-slot { width: 38px; height: 38px; }
  .wj-avatar-row { grid-template-columns: 1fr; }
  .wj-panel { padding: 12px 14px; }
}
