:root{
  --bg:#fbfbff;
  --card:#ffffff;
  --ink:#1f2430;
  --muted:#6b7280;
  --accent:#7c3aed;
  --accent2:#06b6d4;
  --shadow: 0 12px 30px rgba(0,0,0,.08);
  --radius: 18px;
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Arial, "Noto Sans";
  color:var(--ink);
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(124,58,237,.12), transparent 60%),
    radial-gradient(900px 700px at 85% 30%, rgba(6,182,212,.12), transparent 55%),
    var(--bg);
}

/* ==== Layout base ==== */
.wrap{
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
}

/* ==== Top bar ==== */
.topbar{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(10px);
  border:1px solid rgba(0,0,0,.06);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 12px 14px;
}

/* Brand + portada */
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight: 780;
  min-width: 0;
}

.brand-img{
  width: 100%;
  max-width: 320px;
  height: auto;
  display:block;
  object-fit: contain;
}

/* HUD */
.hud{
  display:flex;
  gap:14px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}
.hud strong{color:var(--ink)}

/* ==== Cards ==== */
.card{
  margin-top: 14px;
  background: var(--card);
  border:1px solid rgba(0,0,0,.06);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 14px;
}

.title{margin:0 0 6px 0; font-size: 20px}
.subtitle{margin:0 0 12px 0; color:var(--muted); font-size: 13px}

/* ==== Menú personajes ==== */
.grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.char{
  display:flex;
  gap:10px;
  align-items:center;
  padding: 12px;
  border-radius: 16px;
  border:1px solid rgba(0,0,0,.08);
  background:#fff;
  cursor:pointer;
  user-select:none;
  box-shadow: 0 6px 14px rgba(0,0,0,.06);
}
.char:hover{transform: translateY(-1px)}
.char[aria-selected="true"]{
  outline: 3px solid rgba(124,58,237,.28);
  border-color: rgba(124,58,237,.35);
}

.avatar{
  width:44px; height:44px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.08);
  display:grid; place-items:center;
  font-weight: 800;
  overflow: hidden;
  flex: 0 0 auto;
}
.char .meta{display:flex; flex-direction:column; gap:2px}
.char .name{font-weight: 780}
.char .desc{font-size:12px; color:var(--muted)}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.label{font-size: 13px; color: var(--muted)}
.input{
  flex: 1 1 220px;
  border-radius: 14px;
  border:1px solid rgba(0,0,0,.10);
  padding: 10px 12px;
  font-weight: 650;
  font-size: 16px;
}

/* Botones */
button{
  border-radius: 14px;
  border:1px solid rgba(0,0,0,.10);
  padding: 10px 12px;
  background:#fff;
  box-shadow: 0 6px 14px rgba(0,0,0,.06);
  color: var(--ink);
  font-weight: 750;
  cursor:pointer;
}
button:hover{transform: translateY(-1px)}
button:active{transform: translateY(0px)}
button:disabled{opacity:.55; cursor:not-allowed; transform:none}

.primary{
  background: linear-gradient(135deg, rgba(124,58,237,.95), rgba(6,182,212,.95));
  color:#fff;
  border:none;
}
.ghost{background: rgba(0,0,0,.04)}

.note{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.note.small{font-size:11px; opacity:.9}

.hint{margin-top:8px; color:var(--muted); font-size:12px}

.footer{
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align:center;
}

/* =========================
   GAME (la parte crítica)
   ========================= */

/* Aseguramos que la card del juego sea normal (NO flex forzado) */
.card.game{
  padding: 14px;
}

/* Canvas: ancho 100%, altura por ratio (sin deformación) */
.game #canvas{
  width: 100%;
  height: auto;
  display: block;

  /* Mantiene proporción correcta SIEMPRE */
  aspect-ratio: 900 / 520;

  /* Para que se vea grande, sin romper el layout */
  max-height: 72vh;

  border-radius: 14px;
  border:1px solid rgba(0,0,0,.06);
  background: linear-gradient(180deg, #eaf6ff, #fff);
  touch-action: none;
}

/* En pantallas grandes, dejalo un poco más grande */
@media (min-width: 1024px){
  .game #canvas{
    max-height: 78vh;
  }
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 600px){
  .wrap{ padding: 10px; }

  .topbar{
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
  }

  .brand{
    width: 100%;
    justify-content: space-between;
  }

  .brand-img{
    max-width: 100%;
    max-height: 140px;
  }

  .hud{
    width: 100%;
    justify-content: space-between;
    gap: 8px 10px;
  }

  .game #canvas{
    max-height: 78vh;
  }
}

@media (max-width: 420px){
  .title{ font-size: 20px; }
  .subtitle{ font-size: 13px; }
  .hud{ font-size: 13px; }
}
