  @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

  * { margin: 0; padding: 0; box-sizing: border-box; }

  :root {
    --oro: #c9a84c;
    --oro-oscuro: #8a6a1f;
    --sangre: #8b1a1a;
    --sangre-clara: #c0392b;
    --piedra: #2a2018;
    --piedra-media: #3d3020;
    --texto: #e8d5a3;
    --azul-mana: #3a7bbf;
    --verde-veneno: #4a8a3a;
    --gris-ui: #1a1410;
  }

  body {
    background: #0a0806;
    color: var(--texto);
    font-family: 'Crimson Text', serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
  }

  /* PANTALLA INICIO */
  #pantalla-inicio {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, #1a0e04 0%, #050302 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    gap: 24px;
  }

  #pantalla-inicio h1 {
    font-family: 'Cinzel', serif;
    font-size: clamp(28px, 5vw, 56px);
    font-weight: 900;
    color: var(--oro);
    text-shadow: 0 0 40px rgba(201,168,76,0.6), 0 2px 4px #000;
    letter-spacing: 4px;
    text-align: center;
    animation: pulse-title 3s ease-in-out infinite;
  }

  @keyframes pulse-title {
    0%, 100% { text-shadow: 0 0 40px rgba(201,168,76,0.6), 0 2px 4px #000; }
    50% { text-shadow: 0 0 80px rgba(201,168,76,0.9), 0 2px 4px #000; }
  }

  #pantalla-inicio p {
    font-size: 18px;
    color: #b09060;
    font-style: italic;
    text-align: center;
    max-width: 500px;
    line-height: 1.6;
  }

  .btn-inicio {
    margin-top: 20px;
    padding: 14px 48px;
    background: linear-gradient(135deg, #8a6a1f, #c9a84c, #8a6a1f);
    border: 2px solid var(--oro);
    color: #0a0806;
    font-family: 'Cinzel', serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 3px;
    cursor: pointer;
    clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
    transition: all 0.2s;
  }

  .btn-inicio:hover {
    background: linear-gradient(135deg, #c9a84c, #f0d060, #c9a84c);
    transform: scale(1.05);
  }

  /* CONTENEDOR JUEGO */
  #juego {
    display: none;
    width: 100vw;
    height: 100vh;
    position: relative;
  }

  /* CANVAS 3D */
  #canvas3d {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  /* UI LATERAL IZQUIERDA */
  .panel-lateral {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 140px;
    background: linear-gradient(to right, rgba(10,8,6,0.97), rgba(20,15,10,0.85));
    border-right: 2px solid var(--oro-oscuro);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    gap: 6px;
    z-index: 10;
  }

  .panel-lateral.derecha {
    right: 0;
    left: auto;
    border-right: none;
    border-left: 2px solid var(--oro-oscuro);
    background: linear-gradient(to left, rgba(10,8,6,0.97), rgba(20,15,10,0.85));
  }

  /* PORTRAIT PERSONAJE */
  .portrait {
    width: 72px;
    height: 72px;
    border: 2px solid var(--oro);
    border-radius: 50%;
    background: radial-gradient(circle, #3d2510, #1a0e04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 4px;
    position: relative;
    overflow: hidden;
  }

  .portrait::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(201,168,76,0.3);
  }

  /* BARRAS */
  .barra-contenedor {
    width: 100%;
  }

  .barra-label {
    font-size: 9px;
    font-family: 'Cinzel', serif;
    color: var(--oro-oscuro);
    letter-spacing: 1px;
    margin-bottom: 2px;
  }

  .barra {
    height: 10px;
    background: #1a0e04;
    border: 1px solid #3d2510;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
  }

  .barra-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
  }

  .barra-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 40%;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
  }

  .barra-vida .barra-fill { background: linear-gradient(90deg, #6b0000, var(--sangre-clara)); }
  .barra-mana .barra-fill { background: linear-gradient(90deg, #1a3a6b, var(--azul-mana)); }

  .barra-num {
    font-size: 9px;
    color: var(--texto);
    text-align: right;
    margin-top: 1px;
  }

  /* SLOTS HABILIDADES */
  .slot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    width: 100%;
    margin-top: 4px;
  }

  .slot {
    width: 100%;
    aspect-ratio: 1;
    background: radial-gradient(circle, #2a1f10, #1a1410);
    border: 1px solid var(--oro-oscuro);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
  }

  .slot:hover {
    border-color: var(--oro);
    background: radial-gradient(circle, #3d2f18, #2a1f10);
    transform: scale(1.05);
  }

  .slot.activo {
    border-color: var(--oro);
    box-shadow: 0 0 8px rgba(201,168,76,0.5);
  }

  .slot-cd {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-family: 'Cinzel', serif;
    color: var(--texto);
    font-weight: bold;
    display: none;
  }

  .slot-nombre {
    position: absolute;
    bottom: 1px;
    left: 0; right: 0;
    font-size: 7px;
    text-align: center;
    color: var(--oro-oscuro);
    font-family: 'Cinzel', serif;
  }

  /* PANEL SUPERIOR */
  #panel-top {
    position: absolute;
    top: 0; left: 140px; right: 140px;
    height: 60px;
    background: linear-gradient(to bottom, rgba(10,8,6,0.95), transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
  }

  .btn-top {
    width: 44px;
    height: 44px;
    background: radial-gradient(circle, #2a1f10, #1a1410);
    border: 1px solid var(--oro-oscuro);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-top:hover {
    border-color: var(--oro);
    box-shadow: 0 0 10px rgba(201,168,76,0.4);
  }

  /* MINIMAPA */
  #minimapa {
    position: absolute;
    top: 68px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 180px;
    background: rgba(10,8,6,0.88);
    border: 1px solid var(--oro-oscuro);
    border-radius: 4px;
    z-index: 10;
    overflow: hidden;
  }

  #minimapa canvas {
    width: 100%;
    height: 100%;
  }

  /* PANEL INFERIOR - CONTROLES */
  #controles {
    position: absolute;
    bottom: 0; left: 140px; right: 140px;
    height: 120px;
    background: linear-gradient(to top, rgba(10,8,6,0.95), transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 10;
  }

  .pad-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #2a1f10, #1a1410);
    border: 1px solid var(--oro-oscuro);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.1s;
    color: var(--texto);
  }

  .pad-btn:hover, .pad-btn:active {
    background: linear-gradient(135deg, #3d2f18, #2a1f10);
    border-color: var(--oro);
    transform: scale(0.95);
  }

  .pad-grid {
    display: grid;
    grid-template-areas:
      ". up ."
      "left . right"
      ". down .";
    grid-template-columns: 48px 48px 48px;
    grid-template-rows: 48px 48px 48px;
    gap: 4px;
  }

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

  /* PANEL COMBATE */
  #panel-combate {
    position: absolute;
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10,8,6,0.92);
    border: 1px solid var(--oro-oscuro);
    border-radius: 6px;
    padding: 12px 20px;
    min-width: 320px;
    max-width: 500px;
    z-index: 20;
    display: none;
    flex-direction: column;
    gap: 10px;
  }

  #panel-combate h3 {
    font-family: 'Cinzel', serif;
    color: var(--sangre-clara);
    font-size: 16px;
    letter-spacing: 2px;
    text-align: center;
    border-bottom: 1px solid var(--oro-oscuro);
    padding-bottom: 6px;
  }

  .enemigo-info {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .enemigo-portrait {
    width: 56px;
    height: 56px;
    border: 2px solid var(--sangre);
    border-radius: 4px;
    background: radial-gradient(circle, #2a0808, #0a0302);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
  }

  .enemigo-stats { flex: 1; }

  .barra-enemigo {
    height: 12px;
    background: #1a0a0a;
    border: 1px solid var(--sangre);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
  }

  .barra-enemigo-fill {
    height: 100%;
    background: linear-gradient(90deg, #5a0000, var(--sangre-clara));
    transition: width 0.4s ease;
  }

  .acciones-combate {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .btn-accion {
    padding: 8px 16px;
    background: linear-gradient(135deg, #2a1f10, #1a1410);
    border: 1px solid var(--oro-oscuro);
    color: var(--texto);
    font-family: 'Crimson Text', serif;
    font-size: 14px;
    cursor: pointer;
    clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
    transition: all 0.15s;
  }

  .btn-accion:hover:not(:disabled) {
    border-color: var(--oro);
    background: linear-gradient(135deg, #3d2f18, #2a1f10);
    color: var(--oro);
  }

  .btn-accion:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }

  .btn-accion.peligro {
    border-color: #6b0000;
    color: #ff6060;
  }

  /* LOG DE COMBATE */
  #log-combate {
    position: absolute;
    bottom: 130px;
    right: 148px;
    width: 200px;
    max-height: 120px;
    overflow-y: auto;
    background: rgba(10,8,6,0.85);
    border: 1px solid #2a1f10;
    border-radius: 4px;
    padding: 6px 8px;
    z-index: 10;
    font-size: 11px;
    color: #907050;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  #log-combate::-webkit-scrollbar { width: 4px; }
  #log-combate::-webkit-scrollbar-track { background: #1a1410; }
  #log-combate::-webkit-scrollbar-thumb { background: var(--oro-oscuro); }

  .log-linea { line-height: 1.4; }
  .log-daño { color: #e05050; }
  .log-cura { color: #50c050; }
  .log-sistema { color: var(--oro-oscuro); font-style: italic; }
  .log-mana { color: #5090e0; }

  /* NOTIFICACIÓN FLOTANTE */
  #notif {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10,8,6,0.9);
    border: 1px solid var(--oro);
    padding: 12px 24px;
    font-family: 'Cinzel', serif;
    font-size: 15px;
    color: var(--oro);
    letter-spacing: 2px;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    text-align: center;
    border-radius: 4px;
  }

  /* LOOT POPUP */
  #loot-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #1a1208, #0a0806);
    border: 2px solid var(--oro);
    padding: 20px 30px;
    z-index: 60;
    display: none;
    flex-direction: column;
    gap: 12px;
    min-width: 260px;
    clip-path: polygon(10px 0%, 100% 0%, calc(100% - 10px) 100%, 0% 100%);
  }

  #loot-popup h3 {
    font-family: 'Cinzel', serif;
    color: var(--oro);
    font-size: 14px;
    letter-spacing: 3px;
    text-align: center;
  }

  .item-loot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(201,168,76,0.05);
    border: 1px solid var(--oro-oscuro);
    border-radius: 4px;
  }

  .item-icono { font-size: 28px; }

  .item-nombre {
    font-size: 14px;
    color: var(--texto);
    font-weight: 600;
  }

  .item-rareza {
    font-size: 11px;
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
  }

  .rareza-comun { color: #909090; }
  .rareza-raro { color: #5090e0; }
  .rareza-epico { color: #a050e0; }
  .rareza-legendario { color: var(--oro); }

  /* GAME OVER */
  #game-over {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    flex-direction: column;
    gap: 20px;
    transition: background 1s;
    pointer-events: all;
  }

  #game-over.visible {
    background: rgba(0,0,0,0.85);
  }

  #game-over h2 {
    font-family: 'Cinzel', serif;
    font-size: 48px;
    color: var(--sangre-clara);
    text-shadow: 0 0 30px rgba(192,57,43,0.8);
    letter-spacing: 4px;
  }

  /* INDICADOR BRUJULA */
  #brujula {
    position: absolute;
    top: 68px;
    right: 155px;
    width: 50px;
    height: 50px;
    border: 1px solid var(--oro-oscuro);
    border-radius: 50%;
    background: rgba(10,8,6,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 11px;
    font-family: 'Cinzel', serif;
    color: var(--oro);
    flex-direction: column;
  }

  .compass-n { color: var(--sangre-clara); font-weight: 700; font-size: 13px; }


  /* v0.86 exploración — UI de combate oculta */
  #panel-combate,
  #log-combate,
  #nombre-enemigo-panel,
  #texto-vida-enemigo,
  #portrait-enemigo,
  #barra-enemigo-panel {
    display: none !important;
  }