@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800;900&display=swap');

:root {
  --orange: #ff6a00;
  --orange-d: #d95700;
  --orange-l: #ff9a3d;
  --red: #e21b3c;    --red-d: #b8132f;
  --blue: #1368ce;   --blue-d: #0d4fa0;
  --yellow: #d89e00; --yellow-d: #a87b00;
  --green: #26890c;  --green-d: #1b6407;
  --purple: #864cbf; --purple-d: #6a3a99;
  --teal: #0aa3a3;   --teal-d: #077d7d;
  --pink: #e8378f;
  --dark: #333;
  --gray: #f2f2f2;
  --font: 'Montserrat', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --radius: 8px;
  --shadow: 0 2px 4px rgba(0,0,0,.15);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--dark); background: #f5f5f7;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 800; }
a { color: var(--blue); }
img { max-width: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- Fondo colorido con figuras ---------- */
.bg-fun {
  position: relative; min-height: 100%; overflow-x: hidden;
  background: linear-gradient(135deg, #ff7a18 0%, #ff6a00 45%, #ff4e00 100%);
}
.bg-fun::before, .bg-fun::after { content: ''; position: fixed; pointer-events: none; z-index: 0; }
.shapes { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.shapes i { position: absolute; display: block; opacity: .9; animation: float 14s ease-in-out infinite; }
.shapes .s1 { width: 38vmin; height: 38vmin; border-radius: 50%; background: rgba(255,255,255,.10); top: -10vmin; left: -8vmin; }
.shapes .s2 { width: 30vmin; height: 30vmin; background: rgba(134,76,191,.55); transform: rotate(45deg); bottom: -12vmin; right: 10vmin; animation-delay: -3s; }
.shapes .s3 { width: 18vmin; height: 18vmin; border-radius: 50%; background: rgba(19,104,206,.6); top: 18vh; right: -5vmin; animation-delay: -6s; }
.shapes .s4 { width: 0; height: 0; border-left: 11vmin solid transparent; border-right: 11vmin solid transparent; border-bottom: 19vmin solid rgba(226,27,60,.55); bottom: 12vh; left: 4vw; animation-delay: -1s; background: none; }
.shapes .s5 { width: 14vmin; height: 14vmin; background: rgba(38,137,12,.6); top: 8vh; left: 32vw; transform: rotate(20deg); animation-delay: -8s; border-radius: 12px; }
.shapes .s6 { width: 12vmin; height: 12vmin; border-radius: 50%; background: rgba(255,210,0,.75); bottom: 6vh; left: 45vw; animation-delay: -4s; }
.shapes .s7 { width: 10vmin; height: 10vmin; background: rgba(10,163,163,.6); top: 60vh; right: 30vw; transform: rotate(45deg); animation-delay: -10s; }
.shapes .s8 { width: 8vmin; height: 8vmin; border-radius: 50%; background: rgba(232,55,143,.6); top: 30vh; left: 14vw; animation-delay: -12s; }
@keyframes float { 0%,100% { translate: 0 0; } 50% { translate: 0 -24px; } }
@media (prefers-reduced-motion: reduce) { .shapes i { animation: none; } }

.rainbow-bar { height: 6px; background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green), var(--teal), var(--blue), var(--purple), var(--pink)); }

/* ---------- Botones estilo Kahoot ---------- */
.btn {
  --c: var(--dark); --cd: #111;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 4px; padding: 0 16px; min-height: 42px;
  background: var(--c); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); text-decoration: none; white-space: nowrap;
  transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: grayscale(.3); }
.btn.big { min-height: 54px; font-size: 18px; padding: 0 28px; }
.btn.block { width: 100%; }
.btn.orange { --c: var(--orange); }
.btn.green  { --c: var(--green); }
.btn.blue   { --c: var(--blue); }
.btn.red    { --c: var(--red); }
.btn.purple { --c: var(--purple); }
.btn.yellow { --c: var(--yellow); }
.btn.teal   { --c: var(--teal); }
.btn.light  { --c: #fff; color: var(--dark); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12); }
.btn.ghost  { background: transparent; color: inherit; box-shadow: none; }
.btn.ghost:hover { background: rgba(0,0,0,.06); }
.btn.icon { padding: 0; width: 42px; }

/* ---------- Formularios ---------- */
.field { display: block; margin-bottom: 14px; text-align: left; }
.field > span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: #444; }
.input, select.input, textarea.input {
  width: 100%; border: 2px solid #ccc; border-radius: 4px; padding: 11px 12px; font-size: 16px; font-weight: 600;
  background: #fff; color: var(--dark); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,106,0,.18); }
.input.center { text-align: center; }
.hint { font-size: 13px; color: #666; margin-top: 6px; }
.error-msg { background: #ffe3e6; color: #a30f27; border-left: 4px solid var(--red); padding: 10px 12px; border-radius: 4px; font-weight: 600; font-size: 14px; margin-bottom: 14px; white-space: pre-line; text-align: left; }
.ok-msg { background: #e3f7dd; color: #1b6407; border-left: 4px solid var(--green); padding: 10px 12px; border-radius: 4px; font-weight: 600; font-size: 14px; margin-bottom: 14px; text-align: left; }

/* ---------- Tarjeta central (login, registro, unirse) ---------- */
.center-page { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; margin-bottom: 26px; }
.brand img { width: 74px; height: 74px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.18)); background: #fff; border-radius: 50%; padding: 3px; }
.brand b { font-size: 64px; font-weight: 900; letter-spacing: -2px; text-shadow: 0 4px 0 rgba(0,0,0,.15); }
.card {
  background: #fff; border-radius: 8px; box-shadow: 0 4px 0 rgba(0,0,0,.18), 0 10px 30px rgba(0,0,0,.12);
  padding: 22px; width: 100%; max-width: 380px; text-align: center;
}
.card h2 { font-size: 22px; margin-bottom: 16px; }
.card .sub { color: #666; font-size: 14px; margin: -8px 0 16px; }
.links { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 700; }
.links a { color: var(--blue); text-decoration: none; }
.links a:hover { text-decoration: underline; }
.foot-note { color: rgba(255,255,255,.95); margin-top: 22px; font-size: 14px; font-weight: 600; text-align: center; }
.foot-note a { color: #fff; font-weight: 800; }
.pw-rules { list-style: none; padding: 0; margin: 4px 0 14px; text-align: left; font-size: 13px; font-weight: 600; }
.pw-rules li { padding: 3px 0 3px 24px; position: relative; color: #888; }
.pw-rules li::before { content: '✕'; position: absolute; left: 4px; color: var(--red); font-weight: 900; }
.pw-rules li.ok { color: var(--green); }
.pw-rules li.ok::before { content: '✓'; color: var(--green); }

/* ---------- Barra superior del panel ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; background: #fff; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; box-shadow: 0 2px 6px rgba(0,0,0,.1); min-height: 60px; flex-wrap: wrap;
}
.topbar .logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--orange); font-weight: 900; font-size: 26px; letter-spacing: -1px; }
.topbar .logo img { width: 38px; height: 38px; }
.topbar .spacer { flex: 1; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 10px 14px; border-radius: 6px; font-weight: 700; color: #555; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 15px; }
.tab:hover { background: #f2f2f2; }
.tab.active { color: var(--orange); background: #fff1e6; box-shadow: inset 0 -3px 0 var(--orange); }
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; background: var(--purple); flex-shrink: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; color: #fff; background: #888; vertical-align: middle; }
.badge.admin { background: var(--purple); }
.badge.docente { background: var(--blue); }
.badge.super { background: linear-gradient(90deg, var(--red), var(--orange)); }
.badge.active { background: var(--green); }
.badge.invited { background: #999; }
.badge.pending, .badge.confirmed { background: var(--yellow); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 28px; flex: 1; min-width: 200px; }

.hero {
  border-radius: 12px; padding: 26px; color: #fff; margin-bottom: 26px; position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--orange) 0%, #ff3d6e 55%, var(--purple) 100%);
  box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.hero h1 { font-size: 30px; font-weight: 900; }
.hero p { margin: 8px 0 18px; font-weight: 600; opacity: .95; max-width: 560px; }
.hero::after { content: ''; position: absolute; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.12); right: -50px; top: -60px; }
.hero::before { content: ''; position: absolute; width: 120px; height: 120px; background: rgba(255,210,0,.35); right: 120px; bottom: -50px; transform: rotate(45deg); }

/* ---------- Tarjetas de quiz ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.qcard { position: relative; background: #fff; border-radius: 8px; box-shadow: 0 2px 0 rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.06); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.qcard:hover { transform: translateY(-3px); box-shadow: 0 4px 0 rgba(0,0,0,.08), 0 10px 22px rgba(0,0,0,.1); }
.qcard:has(.menu-list:not([hidden])) { z-index: 10; }
.qcard .cover { border-radius: 8px 8px 0 0; overflow: hidden; aspect-ratio: 16/9; background-size: cover; background-position: center; position: relative; display: grid; place-items: center; }
.qcard .cover .count { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #fff; font-weight: 800; font-size: 12px; padding: 4px 8px; border-radius: 4px; }
.qcard .cover .warn { position: absolute; left: 8px; top: 8px; background: var(--red); color: #fff; font-weight: 800; font-size: 11px; padding: 4px 8px; border-radius: 4px; }
.qcard .body { padding: 12px 14px 4px; flex: 1; }
.qcard h3 { font-size: 17px; line-height: 1.25; word-break: break-word; }
.qcard .meta { color: #777; font-size: 12px; font-weight: 600; margin-top: 4px; }
.qcard .actions { display: flex; gap: 6px; padding: 12px 14px 14px; align-items: center; }
.qcard .actions .btn.play { flex: 1; }

.empty { text-align: center; padding: 50px 20px; color: #666; background: #fff; border-radius: 10px; border: 3px dashed #ddd; }
.empty .big-emoji { font-size: 54px; }
.empty h3 { margin: 10px 0 6px; color: #333; }

/* Temas de color de los quizzes */
.th-naranja { background: linear-gradient(135deg, #ff9a3d, #ff4e00); }
.th-morado  { background: linear-gradient(135deg, #a46ee0, #5b2a92); }
.th-azul    { background: linear-gradient(135deg, #3fa2ff, #0d4fa0); }
.th-verde   { background: linear-gradient(135deg, #58c23b, #1b6407); }
.th-rosa    { background: linear-gradient(135deg, #ff6fb1, #c2185b); }
.th-noche   { background: linear-gradient(135deg, #3a3f63, #12142a); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; background: #fff; border-radius: 8px; box-shadow: 0 2px 0 rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; padding: 12px; background: #fafafa; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: #666; border-bottom: 2px solid #eee; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.tbl tr:hover td { background: #fffaf5; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.panel-box { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 2px 0 rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05); margin-bottom: 18px; }
.panel-box h3 { font-size: 18px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 160px; }
.row > .btn { flex: 0 0 auto; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); animation: pop .2s; }
.modal.wide { max-width: 900px; }
.modal header { padding: 18px 20px 0; display: flex; align-items: center; gap: 10px; }
.modal header h2 { font-size: 20px; flex: 1; }
.modal .content { padding: 16px 20px; }
.modal footer { padding: 0 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #333; color: #fff; padding: 12px 18px; border-radius: 6px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.25); animation: pop .2s; max-width: 90vw; white-space: pre-line; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------- Figuras de respuesta ---------- */
.shape { width: 1em; height: 1em; display: inline-block; flex-shrink: 0; }
.shape svg { width: 100%; height: 100%; display: block; fill: #fff; filter: drop-shadow(0 2px 0 rgba(0,0,0,.15)); }
.c0 { --c: var(--red);    --cd: var(--red-d); }
.c1 { --c: var(--blue);   --cd: var(--blue-d); }
.c2 { --c: var(--yellow); --cd: var(--yellow-d); }
.c3 { --c: var(--green);  --cd: var(--green-d); }
.c4 { --c: var(--purple); --cd: var(--purple-d); }
.c5 { --c: var(--teal);   --cd: var(--teal-d); }

/* ---------- Toggle ---------- */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; font-weight: 700; cursor: pointer; text-align: left; }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 99px; background: #ccc; position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; margin: 0; }
.switch input::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { left: 23px; }
.switch small { display: block; font-weight: 500; color: #777; font-size: 12px; }

.spinner { width: 46px; height: 46px; border-radius: 50%; border: 6px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; margin: 0 auto; }
.spinner.dark { border-color: rgba(0,0,0,.1); border-top-color: var(--orange); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .brand b { font-size: 48px; }
  .brand img { width: 56px; height: 56px; }
  .topbar .logo span { display: none; }
  .tab .lbl { display: none; }
  .hero h1 { font-size: 24px; }
}
