:root {
  --blue-950: #00204A;
  --blue-900: #002D6B;
  --blue-800: #003D87;
  --blue-700: #0051BC;
  --blue-600: #005EAE;
  --blue-500: #1A78D4;
  --ink: #1d2030;
  --muted: #687082;
  --surface: #ffffff;
  --surface-soft: #f5f9fd;
  --line: #dce6f0;
  --success: #198754;
  --danger: #c9374d;
  --shadow: 0 15px 46px rgba(0, 51, 111, .18);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;
  color-scheme: light;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: #f2f6fb; color: var(--ink); overflow-x: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid rgba(255,255,255,.88); outline-offset: 3px; }
input:focus-visible { outline: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell, .screen { min-height: 100vh; min-height: 100dvh; }
.screen { position: relative; }


.top-controls {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 80;
  display: flex;
  gap: 10px;
}
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.30);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0,45,107,.24);
  backdrop-filter: blur(12px);
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}
.icon-button:hover { transform: translateY(-1px); background: rgba(0,45,107,.40); }
.icon-button svg { display: block; width: 19px; height: 19px; fill: currentColor; flex: none; }
.top-controls.game-active #adminButton { display: none; }

/* Entrada */
.join-screen {
  isolation: isolate;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 30px 18px 68px;
  background:
    radial-gradient(circle at 15% 18%, rgba(0,112,216,.88), transparent 42%),
    linear-gradient(132deg, #00377D 0%, #005EAE 46%, #00285F 100%);
}
.join-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -4;
  background: linear-gradient(90deg, rgba(255,255,255,.025), transparent 35%, rgba(0,0,0,.05));
}
.join-orb, .join-ribbon { position: absolute; z-index: -2; pointer-events: none; }
.join-orb-one {
  width: min(58vw, 920px);
  aspect-ratio: 1;
  right: -8vw;
  top: -26vw;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(34,139,230,.72), rgba(0,81,188,.52));
  box-shadow: inset 30px -40px 80px rgba(0,43,96,.18);
}
.join-orb-two {
  width: min(42vw, 650px);
  aspect-ratio: 1;
  left: -21vw;
  bottom: -26vw;
  border-radius: 50%;
  background: rgba(0, 38, 86, .26);
}
.join-ribbon {
  width: 74vw;
  height: 140vh;
  left: 19vw;
  top: -22vh;
  transform: rotate(-34deg);
  background: linear-gradient(90deg, rgba(0,49,111,.38), rgba(0,112,216,.08));
  border-radius: 45%;
}
.join-content { width: min(100%, 360px); text-align: center; animation: riseIn .52s cubic-bezier(.2,.8,.2,1) both; }
.vetaquiz-logo, .mini-brand {
  display: inline-flex;
  align-items: baseline;
  color: #fff;
  font-weight: 900;
  letter-spacing: -2.8px;
  user-select: none;
}
.vetaquiz-logo { font-size: clamp(38px, 6vw, 56px); line-height: .95; text-shadow: 0 8px 25px rgba(0,35,78,.25); }
.vetaquiz-logo strong, .mini-brand strong { font-weight: 950; }
.vetaquiz-logo b, .mini-brand b { font-size: 1.13em; transform: rotate(-5deg); display: inline-block; }
.join-subtitle { margin: 8px 0 12px; color: rgba(255,255,255,.86); font-size: 12.5px; font-weight: 650; letter-spacing: .01em; }
.join-subtitle:empty { display: none; }
.join-card {
  padding: 16px 16px 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 0 rgba(0, 42, 94, .16), 0 22px 60px rgba(0,39,86,.23);
}
.join-input {
  width: 100%;
  height: 48px;
  border: 2px solid #c9c8cc;
  border-radius: 5px;
  padding: 0 14px;
  color: #2b2b32;
  background: #fff;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.join-input::placeholder { color: #77777b; opacity: 1; }
#nameInput { margin-top: 6px; }
.join-input:focus,
.join-input:focus-visible {
  border-color: #005EAE !important;
  box-shadow: none !important;
  outline: none !important;
}
.name-input { font-size: 13px; font-weight: 720; text-transform: uppercase; }
.name-input.autofilled { background: #f5f9ff; }
.join-button {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 0;
  border-radius: 5px;
  color: #fff;
  background: #2f3033;
  box-shadow: 0 4px 0 #171719;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, opacity .14s ease;
}
.join-button:hover:not(:disabled) { background: #242527; transform: translateY(-1px); }
.join-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #171719; }
.join-button:disabled { cursor: not-allowed; opacity: 1; }
.join-button.no-session { background: #99999b; box-shadow: 0 4px 0 #7d7d80; }
.join-button.needs-data { background: #5f6064; box-shadow: 0 4px 0 #3f4043; }
.form-error { min-height: 18px; margin: 12px 2px 0; color: #a51d32; font-size: 12px; font-weight: 700; }
.form-error:empty { display: none; }
.availability-message { min-height: 14px; margin: 12px 4px 0; color: #0051BC; font-size: 9.5px; font-weight: 750; line-height: 1.35; text-transform: uppercase; }
.availability-message:empty { display: none; }
.data-notice { margin: 4px 6px 0; color: #74747d; font-size: 9.5px; line-height: 1.38; }
.join-footer { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); }
.join-footer img { display: block; width: 122px; filter: brightness(0) invert(1); opacity: .9; }

/* Juego */
.quiz-screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px clamp(12px, 2.2vw, 30px) 24px;
  background: linear-gradient(180deg, #f7fafe 0%, #eaf1f8 100%);
}
.quiz-header {
  width: min(1040px, 100%);
  margin: 0 auto;
  min-height: 50px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding-right: 58px;
}
.mini-brand { width: fit-content; color: #0051BC; font-size: 22px; letter-spacing: -1.1px; }
.mini-brand.light { color: #fff; }
.player-chip, .score-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid rgba(0,81,188,.1);
  border-radius: 14px;
  background: rgba(255,255,255,.84);
  box-shadow: 0 8px 24px rgba(0,55,119,.07);
}
.player-avatar { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg,#1675D1,#00438F); font-size: 10px; font-weight: 900; }
.player-meta { display: grid; line-height: 1.15; max-width: min(32vw, 300px); }
.player-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.player-meta small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.score-chip { min-width: 100px; display: grid; justify-items: end; gap: 0; }
.score-chip span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.score-chip strong { color: #0051BC; font-size: 17px; line-height: 1.05; }
.progress-zone { width: min(1040px, 100%); margin: 10px auto 13px; }
.progress-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: #4d4960; font-size: 12px; }
.progress-meta strong { font-size: 13px; }
.progress-track { height: 7px; border-radius: 999px; overflow: hidden; background: #d8e3ef; }
.progress-track span { display: block; width: 10%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#0051BC,#1A78D4); transition: width .35s ease; }
.quiz-main { width: min(1040px, 100%); margin: 0 auto; }
.question-panel {
  position: relative;
  min-height: clamp(155px, 25vh, 230px);
  display: grid;
  place-items: center;
  padding: 44px clamp(22px,4vw,66px) 32px;
  border-radius: var(--radius-xl);
  color: #fff;
  background:
    radial-gradient(circle at 88% 12%, rgba(43,145,232,.54), transparent 34%),
    linear-gradient(135deg, #00336F 0%, #0051BC 54%, #0069C9 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.question-panel::after { content:""; position:absolute; width:420px; height:420px; border-radius:50%; left:-170px; bottom:-290px; background:rgba(255,255,255,.055); }
.question-topline { position: absolute; top: 18px; left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
.category-label { padding: 7px 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; background: rgba(255,255,255,.1); backdrop-filter: blur(8px); font-size: 11px; font-weight: 850; letter-spacing: .035em; }
.timer-ring {
  --timer-progress: 1;
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#fff calc(var(--timer-progress) * 1turn), rgba(255,255,255,.19) 0);
  transition: background .1s linear;
}
.timer-ring::after { content:""; position:absolute; inset:5px; border-radius:50%; background:#004891; }
.timer-ring span { position:relative; z-index:1; color:#fff; font-size:20px; font-weight:950; }
.timer-ring.warning { background: conic-gradient(#ffd463 calc(var(--timer-progress) * 1turn), rgba(255,255,255,.19) 0); }
.timer-ring.danger { animation: pulse .7s ease infinite alternate; background: conic-gradient(#ff7c83 calc(var(--timer-progress) * 1turn), rgba(255,255,255,.19) 0); }
.question-panel h1 { position: relative; z-index: 1; max-width: 780px; margin: 0; text-align: center; font-size: clamp(20px, 2.4vw, 32px); line-height: 1.13; letter-spacing: -.015em; }
.answers-grid { margin-top: 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.answer-button {
  --answer-bg: #cb3f4d;
  position: relative;
  min-height: clamp(72px, 11vh, 100px);
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--answer-bg);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--answer-bg) 78%, #000), 0 12px 22px rgba(33,18,50,.1);
  text-align: left;
  font-size: clamp(13px, 1.25vw, 16px);
  font-weight: 780;
  line-height: 1.28;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease, opacity .2s ease;
  animation: answerIn .32s ease both;
}
.answer-button:nth-child(1) { --answer-bg:#c84451; animation-delay:.02s; }
.answer-button:nth-child(2) { --answer-bg:#2968bd; animation-delay:.06s; }
.answer-button:nth-child(3) { --answer-bg:#b77a00; animation-delay:.10s; }
.answer-button:nth-child(4) { --answer-bg:#18816f; animation-delay:.14s; }
.answer-button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.05); }
.answer-button:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--answer-bg) 78%, #000); }
.answer-button:disabled { cursor: default; }
.answer-button.dimmed { opacity: .32; filter: grayscale(.35); }
.answer-button.correct { outline: 5px solid rgba(255,255,255,.86); outline-offset: -8px; }
.answer-button.incorrect { animation: shake .32s ease; }
.answer-letter { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: rgba(0,0,0,.15); border: 1px solid rgba(255,255,255,.2); font-size: 16px; font-weight: 950; }
.feedback-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(0,30,67,.66); backdrop-filter: blur(8px); animation: fadeIn .18s ease both; }
.feedback-card { width: min(100%, 430px); border-radius: 20px; padding: 26px 26px 23px; text-align: center; color: var(--ink); background:#fff; box-shadow:0 28px 80px rgba(0,0,0,.28); animation: popIn .28s cubic-bezier(.2,.8,.2,1) both; }
.feedback-card.correct-state { border-top: 8px solid #1f9662; }
.feedback-card.incorrect-state { border-top: 8px solid #ce3e53; }
.feedback-symbol { width: 66px; height: 66px; margin: -3px auto 17px; border-radius: 50%; display:grid; place-items:center; color:#fff; font-size:36px; font-weight:950; }
.correct-state .feedback-symbol { background:#1f9662; }
.incorrect-state .feedback-symbol { background:#ce3e53; }
.feedback-card h2 { margin:0; font-size:24px; letter-spacing:-.02em; }
.feedback-card p { margin:13px auto 0; max-width:470px; color:#5f6675; line-height:1.55; font-size:14px; }
.feedback-points { margin:19px 0 22px; color:#727887; font-size:13px; font-weight:800; text-transform:uppercase; letter-spacing:.05em; }
.feedback-points span { color:#004891; font-size:26px; }
.next-button { min-width:190px; min-height:52px; border:0; border-radius:12px; color:#fff; background:linear-gradient(135deg,#00438F,#006DCA); box-shadow:0 5px 0 #002F68; font-weight:900; cursor:pointer; }

/* Resultado */
.result-screen { min-height:100vh; min-height:100dvh; padding:12px clamp(12px,2.2vw,28px) 22px; background:linear-gradient(160deg,#002A60,#0051BC 54%,#006DCA); overflow:auto; }
.result-backdrop { position:absolute; inset:0; pointer-events:none; background:radial-gradient(circle at 90% -10%,rgba(44,148,235,.48),transparent 40%),radial-gradient(circle at -10% 100%,rgba(0,33,74,.52),transparent 42%); }
.result-backdrop::after { content:""; position:absolute; width:520px; height:520px; border-radius:50%; right:-220px; bottom:-330px; background:rgba(255,255,255,.05); }
.result-header, .result-layout { position:relative; z-index:1; width:min(820px,100%); margin:0 auto; }
.result-header { height:34px; display:flex; align-items:center; }
.result-layout { display:grid; grid-template-columns:minmax(0,1.02fr) minmax(300px,.86fr); gap:16px; align-items:stretch; margin-top:10px; }
.result-card, .ranking-card { border:1px solid rgba(255,255,255,.22); border-radius:16px; box-shadow:0 16px 48px rgba(0,35,78,.21); }
.result-card { padding:clamp(18px,2.6vw,30px); background:#fff; text-align:center; }
.result-kicker { color:#0051BC; font-size:9px; font-weight:900; text-transform:uppercase; letter-spacing:.09em; }
.result-card h1 { margin:7px 0 3px; font-size:clamp(24px,3vw,34px); line-height:1.08; letter-spacing:-.02em; }
.result-participant { margin:0; color:var(--muted); font-size:12px; font-weight:650; }
.score-hero { margin:18px auto 16px; width:min(100%,300px); padding:18px 16px; border-radius:16px; color:#fff; background:linear-gradient(135deg,#003D87,#0070D8); box-shadow:0 9px 22px rgba(0,81,188,.22); }
.score-hero span { display:block; font-size:9px; font-weight:800; text-transform:uppercase; letter-spacing:.07em; opacity:.78; }
.score-hero strong { display:block; margin-top:3px; font-size:clamp(34px,5.2vw,50px); line-height:1; }
.result-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.result-stats div { padding:11px 8px; border:1px solid var(--line); border-radius:12px; background:#f8fbfe; }
.result-stats span { display:block; color:var(--muted); font-size:8px; font-weight:800; text-transform:uppercase; letter-spacing:.05em; }
.result-stats strong { display:block; margin-top:3px; color:#003D7E; font-size:18px; }
.sync-message { min-height:0; margin:14px 0 0; padding:8px 10px; border-radius:9px; color:#4f5665; background:#f1f6fb; font-size:11px; line-height:1.35; }
.sync-message.synced { color:#17603f; background:#edf8f2; }
.sync-message.pending { color:#7d5705; background:#fff7df; }
.result-actions { display:flex; gap:8px; margin-top:14px; }
.result-actions button { flex:1; min-height:42px; border-radius:10px; font-size:13px; font-weight:800; cursor:pointer; }
.primary-action { border:0; color:#fff; background:linear-gradient(135deg,#003D87,#006DCA); box-shadow:0 5px 0 #002A60; }
.secondary-action { border:1px solid var(--line); color:#3a3c48; background:#fff; }
.ranking-card { padding:18px; color:#fff; background:rgba(0,42,96,.62); backdrop-filter:blur(16px); }
.ranking-heading { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.ranking-heading span { font-size:8px; font-weight:800; text-transform:uppercase; letter-spacing:.07em; color:rgba(255,255,255,.67); }
.ranking-heading h2 { margin:4px 0 0; font-size:19px; }
.session-label { max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:5px 8px; border-radius:999px; border:1px solid rgba(255,255,255,.15); }
.ranking-list { list-style:none; padding:0; margin:16px 0 0; display:grid; gap:7px; }
.ranking-item { display:grid; grid-template-columns:28px minmax(0,1fr) auto; align-items:center; gap:8px; min-height:42px; padding:7px 9px; border-radius:11px; background:rgba(255,255,255,.09); border:1px solid rgba(255,255,255,.09); }
.ranking-item.current { background:rgba(255,255,255,.19); border-color:rgba(255,255,255,.38); }
.ranking-position { width:25px; height:25px; display:grid; place-items:center; border-radius:8px; background:rgba(255,255,255,.13); font-weight:900; font-size:11px; }
.ranking-name { min-width:0; }
.ranking-name strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; }
.ranking-name small { display:block; margin-top:1px; color:rgba(255,255,255,.62); font-size:9px; }
.ranking-score { font-size:12px; font-weight:900; }
.ranking-empty { margin:20px 6px; color:rgba(255,255,255,.64); font-size:11px; line-height:1.45; }

.toast { position:fixed; left:50%; bottom:max(22px,env(safe-area-inset-bottom)); z-index:100; transform:translate(-50%,24px); max-width:min(90vw,500px); padding:12px 16px; border-radius:12px; color:#fff; background:#26222d; box-shadow:0 16px 40px rgba(0,0,0,.25); font-size:13px; font-weight:750; opacity:0; pointer-events:none; transition:opacity .2s ease, transform .2s ease; }
.toast.show { opacity:1; transform:translate(-50%,0); }

@keyframes riseIn { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:none} }
@keyframes answerIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:none} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes popIn { from{opacity:0;transform:scale(.94) translateY(10px)} to{opacity:1;transform:none} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }
@keyframes pulse { from{transform:scale(1)} to{transform:scale(1.08)} }

@media (max-width: 840px) {
  .quiz-header { grid-template-columns:1fr auto; }
  .player-chip { grid-row:2; grid-column:1 / -1; justify-self:stretch; }
  .score-chip { grid-column:2; grid-row:1; }
  .player-meta { max-width:calc(100vw - 110px); }
  .answers-grid { grid-template-columns:1fr; }
  .answer-button { min-height:72px; grid-template-columns:38px 1fr; padding:13px 15px; border-radius:12px; }
  .answer-letter { width:36px; height:36px; border-radius:10px; }
  .result-layout { grid-template-columns:1fr; }
}

@media (max-width: 560px) {
  .top-controls { top:max(12px,env(safe-area-inset-top)); right:max(12px,env(safe-area-inset-right)); gap:8px; }
  .icon-button { width:36px; height:36px; }
  .join-screen { padding-inline:16px; }
  .join-card { padding:16px 16px 18px; }
  .join-input, .join-button { height:48px; min-height:48px; }
  .vetaquiz-logo { font-size:42px; }
  .quiz-screen { padding:12px 12px 24px; }
  .mini-brand { font-size:21px; }
  .quiz-header { gap:9px; }
  .question-panel { min-height:185px; border-radius:18px; padding:54px 18px 28px; }
  .question-panel h1 { font-size:21px; }
  .question-topline { top:14px; left:14px; right:14px; }
  .timer-ring { width:44px; height:44px; }
  .timer-ring span { font-size:17px; }
  .answers-grid { gap:10px; margin-top:12px; }
  .answer-button { font-size:13.5px; min-height:70px; box-shadow:0 5px 0 color-mix(in srgb,var(--answer-bg) 78%,#000),0 10px 20px rgba(33,18,50,.1); }
  .feedback-card { padding:27px 20px 22px; border-radius:22px; }
  .feedback-card h2 { font-size:23px; }
  .result-screen { padding:12px 12px 24px; }
  .result-layout { margin-top:6px; }
  .result-card, .ranking-card { border-radius:16px; }
  .result-card { padding:20px 16px; }
  .result-card h1 { font-size:25px; }
  .score-hero { margin:16px auto 14px; padding:16px 14px; }
  .result-stats { gap:6px; }
  .result-stats div { padding:10px 6px; }
  .result-stats strong { font-size:18px; }
  .result-actions { flex-direction:column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:.001ms !important; animation-iteration-count:1 !important; scroll-behavior:auto !important; transition-duration:.001ms !important; }
}
