:root {
  --bg:          #f5f4f0;
  --white:       #ffffff;
  --dark:        #22201F;
  --dark2:       #3a3836;
  --muted:       #888680;
  --border:      rgba(34,32,31,0.1);
  --border2:     rgba(34,32,31,0.18);
  --amarillo:    #EBBC02;
  --amarillo-bg: #fdf6d0;
  --amarillo-dk: #7a5f00;
  --naranja:     #EF7E4C;
  --naranja-bg:  #fde8db;
  --naranja-dk:  #7a2e00;
  --rojo:        #D54755;
  --rojo-bg:     #fad8dc;
  --rojo-dk:     #6e0e17;
  --verde:       #009F97;
  --verde-bg:    #d0f0ee;
  --verde-dk:    #004d49;
  --violeta:     #7474C1;
  --violeta-bg:  #eaeaf8;
  --violeta-dk:  #2e2e7a;
  --radius:      12px;
  --radius-sm:   8px;
  --font-t: 'Montserrat', sans-serif;
  --font-b: 'Open Sans', sans-serif;
}
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html,body { height:100%; font-family:var(--font-b); background:var(--bg); color:var(--dark); }
.app { min-height:100vh; display:flex; flex-direction:column; }
.view { display:none; flex:1; flex-direction:column; overflow:hidden; }
.view.active { display:flex; }

.topbar { background:var(--dark); padding:0 24px; height:56px; display:flex; align-items:center; justify-content:space-between; flex-shrink:0; gap:16px; }
.logo { font-family:var(--font-t); font-weight:800; font-size:19px; color:var(--white); letter-spacing:-0.5px; display:flex; align-items:center; gap:10px; }
.logo-badge { width:32px; height:32px; background:var(--verde); border-radius:6px; display:flex; align-items:center; justify-content:center; font-size:16px; font-weight:800; color:var(--white); }
.tab-row { display:flex; gap:8px; align-items:center; }
.tab-btn { padding:7px 16px; font-family:var(--font-t); font-size:12px; font-weight:700; letter-spacing:0.4px; cursor:pointer; background:transparent; border:1px solid rgba(255,255,255,0.2); border-radius:var(--radius-sm); color:rgba(255,255,255,0.5); transition:all .15s; }
.tab-btn.active { background:var(--violeta); border-color:var(--violeta); color:var(--white); }
.tab-btn:hover:not(.active) { border-color:rgba(255,255,255,0.4); color:rgba(255,255,255,0.85); }
.topbar-actions { display:flex; gap:8px; align-items:center; }
.btn-exit { padding:8px 16px; font-family:var(--font-t); font-size:11px; font-weight:700; letter-spacing:0.3px; cursor:pointer; background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.2); border-radius:var(--radius-sm); color:rgba(255,255,255,0.7); transition:all .15s; display:flex; align-items:center; gap:6px; }
.btn-exit:hover { background:rgba(220,53,69,0.4); border-color:var(--rojo); color:#fff; }
.btn-exit svg { width:14px; height:14px; }
.btn-exit.hidden { display:none; }

.scroll { flex:1; overflow-y:auto; padding:28px 24px; }
.page-host { max-width:860px; margin:0 auto; }

.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:11px 24px; border-radius:var(--radius-sm); font-family:var(--font-t); font-weight:700; font-size:12px; letter-spacing:0.5px; cursor:pointer; border:none; transition:all .15s; text-transform:uppercase; }
.btn-primary { background:var(--violeta); color:var(--white); }
.btn-primary:hover { filter:brightness(1.12); }
.btn-primary:disabled { background:var(--border2); color:var(--muted); cursor:default; filter:none; }
.btn-ghost { background:transparent; color:var(--dark); border:1.5px solid var(--border2); }
.btn-ghost:hover { background:var(--white); border-color:var(--dark2); }
.btn-sm { padding:7px 14px; font-size:11px; }

.screen-center { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:60vh; gap:16px; text-align:center; padding:24px; }
.spinner { width:40px; height:40px; border:3px solid var(--border); border-top-color:var(--violeta); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.error-box { background:var(--rojo-bg); border:1px solid rgba(213,71,85,0.3); border-radius:var(--radius); padding:24px 28px; max-width:480px; }
.error-title { font-family:var(--font-t); font-size:15px; font-weight:800; color:var(--rojo-dk); margin-bottom:8px; }
.error-msg { font-size:13px; color:var(--rojo-dk); line-height:1.6; font-family:var(--font-b); }

.lobby-wrap { text-align:center; padding:40px 20px; }
.code-label { font-family:var(--font-t); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:3px; color:var(--muted); margin-bottom:10px; }
.code-display { font-family:var(--font-t); font-size:68px; font-weight:800; letter-spacing:12px; color:var(--dark); line-height:1; border-bottom:4px solid var(--verde); display:inline-block; padding-bottom:8px; margin-bottom:16px; }
.lobby-hint { font-size:14px; color:var(--muted); max-width:360px; margin:0 auto 32px; line-height:1.6; }
.quiz-meta { display:inline-flex; align-items:center; gap:6px; padding:5px 14px; background:var(--violeta-bg); border-radius:40px; font-family:var(--font-t); font-size:12px; font-weight:700; color:var(--violeta-dk); margin-bottom:28px; }
.players-wrap { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:20px; margin-bottom:24px; }
.players-title { font-family:var(--font-t); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:2px; color:var(--muted); margin-bottom:14px; text-align:left; }
.players-grid { display:flex; flex-wrap:wrap; gap:8px; min-height:40px; }
.chip { padding:6px 14px; background:var(--verde-bg); border:1px solid rgba(0,159,152,0.3); border-radius:40px; font-family:var(--font-t); font-size:13px; font-weight:700; color:var(--verde-dk); animation:chipIn .25s ease; }
@keyframes chipIn { from{opacity:0;transform:scale(0.75)} to{opacity:1;transform:scale(1)} }

.q-header { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:18px; }
.q-meta { font-family:var(--font-t); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:2px; color:var(--muted); margin-bottom:10px; }
.q-bubble { background:var(--dark); border-radius:var(--radius); padding:28px 32px; flex:1; }
.q-text { font-family:var(--font-t); font-size:20px; font-weight:800; color:var(--white); line-height:1.45; }
.q-id { font-size:11px; color:rgba(255,255,255,0.35); font-family:var(--font-b); margin-bottom:8px; }

.timer-wrap { display:flex; flex-direction:column; align-items:center; gap:10px; padding-top:4px; flex-shrink:0; }
.timer-ring { position:relative; width:64px; height:64px; }
.timer-ring svg { transform:rotate(-90deg); }
.t-bg { fill:none; stroke:rgba(34,32,31,0.1); stroke-width:5; }
.t-fill { fill:none; stroke:var(--violeta); stroke-width:5; stroke-linecap:round; transition:stroke-dashoffset .9s linear, stroke .3s; }
.t-fill.urgent { stroke:var(--rojo); }
.timer-num { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-family:var(--font-t); font-size:22px; font-weight:800; color:var(--dark); }

.ans-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:16px; }
.ans-card { display:flex; align-items:center; gap:14px; padding:16px 18px; border-radius:var(--radius); border:2px solid transparent; transition:all .2s; min-height:72px; }
.ans-card.c0 { background:var(--amarillo-bg); border-color:rgba(235,188,2,0.4); }
.ans-card.c1 { background:var(--naranja-bg);  border-color:rgba(239,126,76,0.4); }
.ans-card.c2 { background:var(--rojo-bg);     border-color:rgba(213,71,85,0.4); }
.ans-card.c3 { background:var(--verde-bg);    border-color:rgba(0,159,152,0.4); }
.ans-card.correct   { border-color:var(--verde) !important; background:var(--verde-bg) !important; }
.ans-card.wrong-dim { opacity:0.28; }
.ans-letter { width:32px; height:32px; flex-shrink:0; border-radius:6px; display:flex; align-items:center; justify-content:center; font-family:var(--font-t); font-size:13px; font-weight:800; }
.ans-card.c0 .ans-letter { background:var(--amarillo); color:var(--amarillo-dk); }
.ans-card.c1 .ans-letter { background:var(--naranja);  color:var(--naranja-dk); }
.ans-card.c2 .ans-letter { background:var(--rojo);     color:#fff; }
.ans-card.c3 .ans-letter { background:var(--verde);    color:#fff; }
.ans-card.correct .ans-letter { background:var(--verde); color:#fff; }
.ans-text { font-size:14px; font-weight:600; line-height:1.4; }
.ans-card.c0 .ans-text { color:var(--amarillo-dk); }
.ans-card.c1 .ans-text { color:var(--naranja-dk); }
.ans-card.c2 .ans-text { color:var(--rojo-dk); }
.ans-card.c3 .ans-text { color:var(--verde-dk); }

.live-row { display:flex; align-items:center; gap:10px; margin:4px 0 12px; }
.live-bar-outer { flex:1; height:6px; background:var(--border); border-radius:3px; overflow:hidden; }
.live-bar-fill { height:100%; background:var(--violeta); border-radius:3px; transition:width .4s; }
.live-label { font-size:12px; color:var(--muted); white-space:nowrap; }

.two-col { display:grid; grid-template-columns:1fr 1fr; gap:24px; }
.section-title { font-family:var(--font-t); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:2px; color:var(--muted); margin-bottom:12px; margin-top:24px; }
.res-row { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.res-lbl { font-family:var(--font-t); font-size:11px; font-weight:800; width:18px; flex-shrink:0; }
.res-lbl.c0{color:var(--amarillo-dk)} .res-lbl.c1{color:var(--naranja-dk)} .res-lbl.c2{color:var(--rojo-dk)} .res-lbl.c3{color:var(--verde-dk)}
.res-outer { flex:1; height:40px; background:var(--border); border-radius:6px; overflow:hidden; position:relative; }
.res-inner { height:100%; border-radius:6px; display:flex; align-items:center; padding:0 10px; font-family:var(--font-t); font-size:11px; font-weight:700; white-space:nowrap; overflow:hidden; transition:width .7s cubic-bezier(.16,1,.3,1); min-width:0; }
.res-inner.c0{background:var(--amarillo);color:var(--amarillo-dk)}
.res-inner.c1{background:var(--naranja);color:#fff}
.res-inner.c2{background:var(--rojo);color:#fff}
.res-inner.c3{background:var(--verde);color:#fff}
.res-count { font-size:12px; color:var(--muted); width:24px; text-align:right; flex-shrink:0; }
.res-count.num { font-family:var(--font-t); font-weight:700; color:var(--dark); font-size:14px; }

.res-bar-container { display:flex; align-items:center; gap:12px; margin-bottom:12px; }
.res-bar-label { width:24px; height:24px; border-radius:6px; display:flex; align-items:center; justify-content:center; font-family:var(--font-t); font-size:12px; font-weight:800; flex-shrink:0; }
.res-bar-label.l0 { background:var(--amarillo); color:var(--amarillo-dk); }
.res-bar-label.l1 { background:var(--naranja); color:#fff; }
.res-bar-label.l2 { background:var(--rojo); color:#fff; }
.res-bar-label.l3 { background:var(--verde); color:#fff; }
.res-bar-text { flex:1; font-size:14px; font-weight:600; color:var(--dark); line-height:1.3; min-width:0; word-wrap:break-word; }
.res-bar-outer { flex:1; height:40px; background:var(--bg); border:2px solid var(--border2); border-radius:8px; overflow:hidden; }
.res-bar-fill { height:100%; border-radius:6px; min-width:4px; }
.res-bar-fill.b0{background:var(--amarillo)}
.res-bar-fill.b1{background:var(--naranja)}
.res-bar-fill.b2{background:var(--rojo)}
.res-bar-fill.b3{background:var(--verde)}
.res-bar-count { width:40px; text-align:right; font-family:var(--font-t); font-size:16px; font-weight:800; color:var(--dark); flex-shrink:0; }

.rank-row { display:flex; align-items:center; gap:14px; padding:10px 16px; background:var(--white); border:1px solid var(--border); border-radius:var(--radius-sm); margin-bottom:6px; }
.rank-pos { font-family:var(--font-t); font-size:18px; font-weight:800; width:28px; color:var(--muted); }
.rank-pos.gold   { color:var(--amarillo-dk); }
.rank-pos.silver { color:#888; }
.rank-pos.bronze { color:var(--naranja-dk); }
.rank-name { flex:1; font-family:var(--font-t); font-size:14px; font-weight:700; }
.rank-pts  { font-family:var(--font-t); font-size:14px; font-weight:800; color:var(--violeta); }
.divider { height:1px; background:var(--border); margin:20px 0; }

.final-hero { background:var(--dark); border-radius:var(--radius); padding:48px 32px 36px; text-align:center; margin-bottom:28px; }
.final-title { font-family:var(--font-t); font-size:36px; font-weight:800; color:var(--white); margin-bottom:6px; }
.final-sub { font-size:14px; color:rgba(255,255,255,0.5); }
.winner-pill { display:inline-block; margin-top:20px; padding:8px 24px; background:var(--verde); border-radius:40px; font-family:var(--font-t); font-size:13px; font-weight:700; color:#fff; }

.mobile-device { max-width:400px; margin:0 auto; }
.m-card { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:24px; animation:fadeUp .25s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.m-topbar { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; padding-bottom:14px; border-bottom:1px solid var(--border); }
.m-name { font-family:var(--font-t); font-size:15px; font-weight:800; color:var(--dark); }
.m-timer-num { font-family:var(--font-t); font-size:20px; font-weight:800; color:var(--violeta); background:var(--violeta-bg); width:42px; height:42px; border-radius:50%; display:flex; align-items:center; justify-content:center; }
.m-timer-num.urgent { background:var(--rojo-bg); color:var(--rojo-dk); animation:pulse .5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.m-q { font-family:var(--font-t); font-size:14px; font-weight:700; line-height:1.5; color:var(--dark); background:var(--bg); border-radius:var(--radius-sm); padding:14px 16px; margin-bottom:16px; text-align:center; }
.m-btn { width:100%; display:flex; align-items:center; gap:12px; padding:14px 16px; border:none; border-radius:var(--radius-sm); font-family:var(--font-b); font-size:14px; font-weight:600; cursor:pointer; margin-bottom:10px; text-align:left; transition:all .12s; line-height:1.4; }
.m-btn:hover:not(:disabled) { filter:brightness(.93); transform:translateY(-1px); }
.m-btn:active:not(:disabled) { transform:translateY(0); }
.m-btn:disabled { cursor:default; opacity:.5; transform:none; }
.m-btn.b0{background:var(--amarillo);color:var(--amarillo-dk)}
.m-btn.b1{background:var(--naranja);color:var(--naranja-dk)}
.m-btn.b2{background:var(--rojo);color:#fff}
.m-btn.b3{background:var(--verde);color:#fff}
.m-lbl { width:26px; height:26px; border-radius:5px; flex-shrink:0; background:rgba(0,0,0,0.12); display:flex; align-items:center; justify-content:center; font-family:var(--font-t); font-size:12px; font-weight:800; color:rgba(0,0,0,0.4); }
.m-btn.b2 .m-lbl, .m-btn.b3 .m-lbl { color:rgba(255,255,255,0.5); }
.m-status { text-align:center; padding:32px 16px; color:var(--muted); font-size:14px; line-height:1.7; }
.m-status strong { color:var(--dark); }
.m-score-box { background:var(--bg); border-radius:var(--radius-sm); padding:14px; text-align:center; margin-top:16px; }
.m-score-num { font-family:var(--font-t); font-size:38px; font-weight:800; color:var(--dark); }
.m-score-lbl { font-size:11px; text-transform:uppercase; letter-spacing:1.5px; color:var(--muted); margin-top:2px; }
.m-result-wrap { text-align:center; padding:16px 0; }
.m-result-icon { width:60px; height:60px; border-radius:50%; display:flex; align-items:center; justify-content:center; margin:0 auto 12px; font-size:26px; font-weight:800; font-family:var(--font-t); }
.m-result-icon.ok { background:var(--verde-bg); color:var(--verde); }
.m-result-icon.ko { background:var(--rojo-bg);  color:var(--rojo); }
.m-result-title { font-family:var(--font-t); font-size:17px; font-weight:800; margin-bottom:4px; }

.field-label { font-family:var(--font-t); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:1.5px; color:var(--muted); margin-bottom:6px; display:block; }
input[type=text] { width:100%; padding:11px 14px; background:var(--bg); border:1.5px solid var(--border2); border-radius:var(--radius-sm); color:var(--dark); font-family:var(--font-b); font-size:15px; margin-bottom:14px; outline:none; transition:border-color .15s; }
input[type=text]:focus  { border-color:var(--violeta); background:var(--white); }
input[type=text].error  { border-color:var(--rojo); }
.btn-join { width:100%; padding:13px; }

@media(max-width:600px) {
  .two-col { grid-template-columns:1fr; }
  .ans-grid { grid-template-columns:1fr; }
  .code-display { font-size:44px; letter-spacing:8px; }
  .q-text { font-size:16px; }
  .scroll { padding:20px 16px; }
}
::-webkit-scrollbar { width:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border2); border-radius:3px; }

.join-form { max-width:400px; margin:0 auto; }
.join-card { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:32px; }
.join-title { font-family:var(--font-t); font-size:22px; font-weight:800; text-align:center; margin-bottom:8px; }
.join-subtitle { font-size:14px; color:var(--muted); text-align:center; margin-bottom:24px; }
