/* ===========================================================
   MALLIY · Hoja de estilos principal
   =========================================================== */

:root {
  --p1: #6C4CF1;
  --p2: #9B5CF6;
  --p3: #4B2ED4;
  --ink: #1B1533;
  --ink-soft: #5B5477;
  --line: #E7E3F5;
  --bg: #F6F4FF;
  --card: #FFFFFF;
  --ok: #22C55E;
  --bad: #EF4444;
  --warn: #F59E0B;

  --a1: #E2445C;  /* triángulo */
  --a2: #2F80ED;  /* rombo */
  --a3: #F2A73B;  /* círculo */
  --a4: #27AE60;  /* cuadrado */

  --r: 16px;
  --shadow: 0 10px 30px rgba(60, 40, 130, .10);
  --shadow-lg: 0 20px 50px rgba(60, 40, 130, .18);
  --font: "Segoe UI", Roboto, "Helvetica Neue", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--p1); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; }
p { line-height: 1.55; }

.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ------------------------- Botones ------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: #EFEBFF;
  color: var(--p3);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--p1), var(--p2)); color: #fff; box-shadow: 0 8px 20px rgba(108,76,241,.35); }
.btn-dark   { background: var(--ink); color: #fff; }
.btn-ghost  { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-danger { background: #FEE2E2; color: #B91C1C; }
.btn-ok     { background: var(--ok); color: #fff; }
.btn-lg     { padding: 16px 28px; font-size: 1.15rem; border-radius: 14px; }
.btn-sm     { padding: 8px 14px; font-size: .85rem; border-radius: 10px; }
.btn-block  { width: 100%; }

/* ------------------------- Formularios -------------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: block; font-weight: 600; font-size: .9rem; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--p1);
  box-shadow: 0 0 0 4px rgba(108,76,241,.15);
}
textarea { min-height: 110px; resize: vertical; }

.alert { padding: 12px 16px; border-radius: 12px; margin: 12px 0; font-size: .93rem; }
.alert.ok    { background: #ECFDF5; color: #166534; border: 1px solid #BBF7D0; }
.alert.error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert.info  { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: #EFEBFF;
  color: var(--p3);
  letter-spacing: .3px;
}
.badge.ai   { background: linear-gradient(135deg,#6C4CF1,#9B5CF6); color: #fff; }
.badge.gray { background: #F1F0F7; color: var(--ink-soft); }

/* ------------------------- Landing / Login ---------------- */
.page-hero {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 15% -10%, #9B5CF6 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 10%, #4B2ED4 0%, transparent 50%),
              linear-gradient(160deg, #5B34E8, #2E1B85);
  color: #fff;
  display: flex;
  flex-direction: column;
}
.page-plain { padding: 24px; }

.hero-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 5vw, 60px);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.4rem; letter-spacing: 1px; color:#fff; }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: #fff; color: var(--p1);
  display: grid; place-items: center; font-weight: 900; font-size: 1.15rem;
}

.hero-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: clamp(20px, 5vw, 60px);
  align-items: center;
  padding: clamp(20px, 4vw, 50px) clamp(16px, 5vw, 60px) 60px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.hero-copy h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 800; letter-spacing: -1px; }
.hero-copy p { font-size: 1.1rem; opacity: .9; max-width: 520px; }
.hero-points { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; }
.hero-points li { display: flex; gap: 12px; align-items: flex-start; opacity: .95; }
.hero-points .dot {
  width: 26px; height: 26px; border-radius: 9px; flex: 0 0 26px;
  background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: .9rem;
}

.auth-card {
  background: var(--card);
  color: var(--ink);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}
.tabs { display: flex; background: #F1EFFA; border-radius: 14px; padding: 5px; margin-bottom: 22px; }
.tab {
  flex: 1; border: 0; background: transparent; padding: 11px 8px;
  border-radius: 10px; font-weight: 700; font-size: .95rem; cursor: pointer;
  color: var(--ink-soft); font-family: inherit;
}
.tab.active { background: #fff; color: var(--p3); box-shadow: 0 3px 10px rgba(60,40,130,.12); }

.pin-input {
  width: 100%;
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 12px;
  padding: 16px 10px;
  border: 2px dashed var(--line);
  border-radius: 14px;
}
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); font-size: .82rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ------------------------- App shell ---------------------- */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.app-header .inner {
  max-width: 1240px; margin: 0 auto;
  padding: 12px clamp(14px, 3vw, 28px);
  display: flex; align-items: center; gap: 16px;
}
.app-header .logo { color: var(--p3); }
.app-header .logo-mark { background: linear-gradient(135deg, var(--p1), var(--p2)); color: #fff; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); }
.avatar-fallback {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--p1), var(--p2)); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.container { max-width: 1240px; margin: 0 auto; padding: 26px clamp(14px, 3vw, 28px) 70px; }

.page-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title h1 { font-size: 1.8rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: #fff; border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.9rem; font-weight: 800; color: var(--p3); line-height: 1; }
.stat .l { color: var(--ink-soft); font-size: .85rem; margin-top: 6px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar select, .toolbar input { margin-top: 0; width: auto; min-width: 170px; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 18px; }
.quiz-card {
  background: #fff; border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.quiz-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.quiz-card .top { height: 8px; background: linear-gradient(90deg, var(--p1), var(--p2)); }
.quiz-card .body { padding: 18px; flex: 1; }
.quiz-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.quiz-card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 0; }
.quiz-card .actions { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.empty {
  background: #fff; border: 2px dashed var(--line); border-radius: var(--r);
  padding: 50px 24px; text-align: center; color: var(--ink-soft);
}

/* ------------------------- Modal -------------------------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(27,21,51,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; z-index: 100; backdrop-filter: blur(3px);
}
.modal {
  background: #fff; border-radius: 20px; width: min(680px, 100%);
  max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg);
}
.modal .head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal .content { padding: 22px 24px; }
.modal .foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.x-btn { border: 0; background: transparent; font-size: 1.5rem; cursor: pointer; color: var(--ink-soft); line-height: 1; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

/* ------------------------- Editor ------------------------- */
.q-card { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.q-card .q-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.q-num {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--p1), var(--p2)); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.opt-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.opt-shape { width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px; display: grid; place-items: center; color: #fff; font-size: .95rem; }
.opt-row input[type=text] { margin-top: 0; }
.opt-row .correct-btn {
  border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  width: 42px; height: 42px; flex: 0 0 42px; cursor: pointer; font-size: 1.1rem; color: var(--ink-soft);
}
.opt-row .correct-btn.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.sh1 { background: var(--a1); } .sh2 { background: var(--a2); }
.sh3 { background: var(--a3); } .sh4 { background: var(--a4); }

/* ------------------------- Asistente IA ------------------- */
.ai-panel { background: linear-gradient(135deg, #6C4CF1, #9B5CF6); color: #fff; border-radius: 20px; padding: 24px; margin-bottom: 24px; }
.ai-panel h2 { color: #fff; }
.ai-panel label { color: #fff; }
.ai-panel input, .ai-panel select, .ai-panel textarea { border-color: transparent; }
.ai-loading { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
.spinner.dark { border-color: rgba(108,76,241,.25); border-top-color: var(--p1); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------- Juego -------------------------- */
.play-shell {
  min-height: 100vh;
  background: linear-gradient(160deg, #5B34E8, #2E1B85);
  color: #fff;
  display: flex; flex-direction: column;
}
.play-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(14px, 4vw, 40px); gap: 12px; flex-wrap: wrap;
}
.chip {
  background: rgba(255,255,255,.16); border-radius: 999px;
  padding: 8px 16px; font-weight: 700; font-size: .9rem;
}
.play-main { flex: 1; display: flex; flex-direction: column; padding: 0 clamp(14px, 4vw, 40px) 24px; }

.pin-display {
  background: #fff; color: var(--ink); border-radius: 20px;
  padding: 22px 34px; text-align: center; box-shadow: var(--shadow-lg);
}
.pin-display .n {
  font-size: clamp(2.6rem, 9vw, 4.6rem); font-weight: 900; letter-spacing: 10px;
  color: var(--p3); line-height: 1;
}

.players-cloud { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }
.player-tag {
  background: rgba(255,255,255,.18); border-radius: 12px;
  padding: 10px 16px; font-weight: 700; animation: pop .3s ease;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.question-box {
  background: #fff; color: var(--ink); border-radius: 20px;
  padding: clamp(18px, 4vw, 34px); text-align: center; box-shadow: var(--shadow-lg);
  font-size: clamp(1.2rem, 3.2vw, 2rem); font-weight: 800;
}
.timer-ring {
  width: 78px; height: 78px; border-radius: 50%;
  background: #fff; color: var(--p3);
  display: grid; place-items: center; font-size: 2rem; font-weight: 900;
  box-shadow: var(--shadow-lg); flex: 0 0 78px;
}
.timer-ring.low { background: var(--bad); color: #fff; animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

.answers-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px;
}
@media (max-width: 560px) { .answers-grid { grid-template-columns: 1fr; } }
.answer-btn {
  border: 0; border-radius: 16px; padding: clamp(18px, 4vw, 30px) 18px;
  color: #fff; font-size: clamp(1rem, 2.4vw, 1.3rem); font-weight: 700;
  cursor: pointer; text-align: left; display: flex; gap: 14px; align-items: center;
  font-family: inherit; min-height: 92px;
  transition: transform .12s ease, filter .12s ease, opacity .2s ease;
  box-shadow: 0 8px 0 rgba(0,0,0,.18);
}
.answer-btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.06); }
.answer-btn:disabled { cursor: default; }
.answer-btn.dim { opacity: .35; }
.answer-btn.right { outline: 5px solid #fff; }
.answer-btn .shape { font-size: 1.4rem; flex: 0 0 auto; }
.answer-btn .cnt { margin-left: auto; background: rgba(0,0,0,.22); border-radius: 999px; padding: 4px 12px; font-size: .95rem; }
.a1 { background: var(--a1); } .a2 { background: var(--a2); }
.a3 { background: var(--a3); } .a4 { background: var(--a4); }

.result-hero {
  border-radius: 22px; padding: clamp(24px, 6vw, 50px); text-align: center;
  font-size: clamp(1.5rem, 5vw, 2.6rem); font-weight: 900; color: #fff;
  animation: pop .35s ease;
}
.result-hero.good { background: var(--ok); }
.result-hero.bad  { background: var(--bad); }
.result-hero.wait { background: rgba(255,255,255,.14); }

.board { background: #fff; color: var(--ink); border-radius: 20px; padding: 18px; box-shadow: var(--shadow-lg); }
.board-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; background: #F7F5FF;
  animation: pop .25s ease;
}
.board-row .pos { width: 32px; height: 32px; border-radius: 9px; background: var(--p1); color: #fff; display: grid; place-items: center; font-weight: 800; flex: 0 0 32px; }
.board-row .nm { font-weight: 700; flex: 1; }
.board-row .pt { font-weight: 800; color: var(--p3); }
.board-row.me { background: #EFE9FF; outline: 2px solid var(--p1); }
.board-row:nth-child(1) .pos { background: #F5B301; }
.board-row:nth-child(2) .pos { background: #A7A7B5; }
.board-row:nth-child(3) .pos { background: #C97B3C; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 30px 0; }
.podium .col { text-align: center; color: #fff; }
.podium .bar { background: rgba(255,255,255,.2); border-radius: 14px 14px 0 0; width: clamp(80px, 22vw, 140px); display: grid; place-items: center; font-size: 2rem; font-weight: 900; }
.podium .c1 .bar { height: 180px; background: #F5B301; }
.podium .c2 .bar { height: 135px; background: rgba(255,255,255,.35); }
.podium .c3 .bar { height: 100px; background: rgba(255,255,255,.22); }

/* ------------------------- Instalador --------------------- */
.install-wrap { max-width: 720px; margin: 30px auto; background: #fff; border-radius: 20px; padding: 30px; box-shadow: var(--shadow); }
.brand-title { font-size: 2.2rem; font-weight: 900; letter-spacing: 2px; background: linear-gradient(135deg, var(--p1), var(--p2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.check-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.check-list li.ok { color: #166534; }
.check-list li.bad { color: #991B1B; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; padding-bottom: 40px; }
  .hero-copy { text-align: center; }
  .hero-copy p { margin-inline: auto; }
  .hero-points { text-align: left; max-width: 420px; margin-inline: auto; }
}
