@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg:          #f4f0eb;
  --bg2:         #ede8e1;
  --card:        #ffffff;
  --purple:      #a78bfa;
  --purple-soft: #ede9fe;
  --pink:        #f9a8d4;
  --green:       #86efac;
  --green-soft:  #dcfce7;
  --red:         #fca5a5;
  --red-soft:    #fee2e2;
  --gold-soft:   #fef3c7;
  --navy:        #1e1b2e;
  --muted:       #6b7280;
  --border:      #e5e7eb;
  --shadow:      0 4px 24px rgba(0,0,0,.07);
  --shadow-lg:   0 12px 48px rgba(0,0,0,.13);
  --radius:      18px;
  --radius-pill: 999px;
  --font-d:      'Playfair Display', Georgia, serif;
  --font-b:      'DM Sans', system-ui, sans-serif;
  --t:           .22s cubic-bezier(.4,0,.2,1);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-b); background: var(--bg); color: var(--navy); min-height: 100vh; overflow-x: hidden; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(ellipse 80% 60% at 20% 10%, rgba(167,139,250,.07) 0%, transparent 60%),
                    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(249,168,212,.07) 0%, transparent 60%); }

/* ── Topbar ── */
.topbar { position: sticky; top: 0; z-index: 100; background: rgba(244,240,235,.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: .9rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-flag { font-size: 1.6rem; }
.brand-title { display: block; font-family: var(--font-d); font-size: 1.15rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.brand-sub { display: block; font-size: .7rem; font-weight: 500; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1.1rem; border-radius: var(--radius-pill); border: none; cursor: pointer; font-family: var(--font-b); font-size: .82rem; font-weight: 600; text-decoration: none; transition: var(--t); white-space: nowrap; }
.btn-primary  { background: var(--purple); color: #fff; box-shadow: 0 2px 12px rgba(167,139,250,.35); }
.btn-primary:hover { background: #9270e8; transform: translateY(-1px); }
.btn-share    { background: #fff; color: var(--purple); border: 1.5px solid var(--purple); }
.btn-share:hover { background: var(--purple-soft); }
.btn-secondary { background: var(--gold-soft); color: #92400e; border: 1px solid #fde68a; }
.btn-secondary:hover { background: #fde68a; }
.btn-ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg2); color: var(--navy); }
.btn-danger   { background: var(--red-soft); color: #991b1b; border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-whatsapp { background: #25D366; color: #fff; width: 100%; justify-content: center; }
.btn-whatsapp:hover { background: #1da851; }

/* ── Game ── */
.game-main { max-width: 980px; margin: 0 auto; padding: 2rem 1.2rem 8rem; position: relative; z-index: 1; }
.game-header { text-align: center; margin-bottom: 2rem; }
.game-title { font-family: var(--font-d); font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 900; color: var(--navy); margin-bottom: .4rem; }
.game-subtitle { font-size: .95rem; color: var(--muted); font-weight: 300; }

/* ── Progress ── */
.progress-wrap { max-width: 500px; margin: 0 auto 2.5rem; text-align: center; }
.progress-bar-track { height: 8px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: .5rem; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--pink)); border-radius: var(--radius-pill); transition: width .5s ease; width: 0%; }
.progress-label { font-size: .8rem; color: var(--muted); font-weight: 500; }

/* ── Duel ── */
.duel-area { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.5rem; align-items: center; }

.candidate-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 2px solid transparent; cursor: pointer; transition: var(--t); position: relative; overflow: hidden; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.5rem 2.5rem; text-align: center; }
.candidate-card::before { content: ''; position: absolute; inset: 0; opacity: 0; transition: var(--t); background: linear-gradient(135deg, rgba(167,139,250,.06), rgba(249,168,212,.06)); }
.candidate-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--purple); }
.candidate-card:hover::before { opacity: 1; }
.candidate-card:active { transform: scale(.97); }
.card-inner { display: flex; flex-direction: column; align-items: center; gap: .75rem; position: relative; z-index: 1; }
.card-hover-hint { position: absolute; bottom: .8rem; font-size: .72rem; color: var(--purple); font-weight: 600; opacity: 0; transition: var(--t); letter-spacing: .04em; }
.candidate-card:hover .card-hover-hint { opacity: 1; }

/* ── Photo wrap ── */
.photo-wrap { width: 90px; height: 90px; border-radius: 50%; overflow: hidden; position: relative; box-shadow: 0 4px 16px rgba(0,0,0,.15); flex-shrink: 0; }
.candidate-photo { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; position: relative; z-index: 2; }
.candidate-photo.hidden { display: none; }
.fallback-avatar { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; font-family: var(--font-d); font-size: 1.4rem; font-weight: 700; color: #fff; }

/* ── Card text ── */
.card-name  { font-family: var(--font-d); font-size: 1.1rem; font-weight: 700; color: var(--navy); line-height: 1.25; }
.card-desc  { font-size: .82rem; color: var(--muted); font-weight: 400; line-height: 1.4; }
.card-badge { display: inline-block; padding: .25rem .75rem; border-radius: var(--radius-pill); font-size: .72rem; font-weight: 600; letter-spacing: .03em; }

/* ── VS ── */
.vs-separator { display: flex; align-items: center; justify-content: center; width: 60px; }
.vs-text { font-family: var(--font-d); font-size: 2rem; font-weight: 900; color: var(--purple); text-shadow: 0 0 24px rgba(167,139,250,.4); }

/* ── Animations ── */
@keyframes slideInRight { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutLeft { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-60px); } }
@keyframes winnerPulse  { 0% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 6px rgba(134,239,172,.4), var(--shadow-lg); } 100% { box-shadow: var(--shadow); } }
.card-enter  { animation: slideInRight .35s ease forwards; }
.card-exit   { animation: slideOutLeft .25s ease forwards; pointer-events: none; }
.card-winner { animation: winnerPulse .6s ease; border-color: var(--green) !important; }

/* ── Victory ── */
.victory-screen { position: fixed; inset: 0; background: rgba(244,240,235,.95); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1.5rem; overflow-y: auto; }
.victory-card { background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 2.5rem 2.5rem 2rem; text-align: center; max-width: 400px; width: 100%; position: relative; z-index: 1; animation: slideInRight .4s ease; }
.victory-trophy { font-size: 3.5rem; margin-bottom: .5rem; animation: bounce 1s ease infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-8px); } }
.victory-label { font-size: .82rem; color: var(--muted); font-weight: 500; margin-bottom: 1.2rem; letter-spacing: .04em; text-transform: uppercase; }
.victory-photo-wrap { width: 100px; height: 100px; border-radius: 50%; overflow: hidden; margin: 0 auto 1rem; position: relative; border: 3px solid rgba(134,239,172,.4); box-shadow: 0 4px 16px rgba(0,0,0,.15); background: var(--bg2); }
.victory-photo { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; position: relative; z-index: 2; }
.victory-photo.hidden { display: none; }
.victory-avatar { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; font-family: var(--font-d); font-size: 1.8rem; font-weight: 700; color: #fff; }
.victory-name  { font-family: var(--font-d); font-size: 1.7rem; font-weight: 900; margin-bottom: .4rem; }
.victory-desc  { color: var(--muted); font-size: .88rem; margin-bottom: .8rem; }
.victory-badge { margin: 0 auto 1.5rem; display: inline-block; }
.victory-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ── Confetti ── */
.confetti-container { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; border-radius: 2px; animation: confettiFall linear forwards; }
@keyframes confettiFall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* ── Share ── */
.share-overlay { position: fixed; inset: 0; background: rgba(30,27,46,.45); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; z-index: 300; padding: 1rem; }
@media (min-width: 600px) { .share-overlay { align-items: center; } }
.share-panel { background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 2rem 1.75rem 1.75rem; width: 100%; max-width: 420px; position: relative; animation: slideUpPanel .3s ease; }
@keyframes slideUpPanel { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
.share-close { position: absolute; top: 1rem; right: 1rem; background: var(--bg2); border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: .85rem; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.share-close:hover { background: var(--border); }
.share-title { font-family: var(--font-d); font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: .3rem; }
.share-subtitle { font-size: .82rem; color: var(--muted); text-align: center; margin-bottom: 1.25rem; }
.share-options { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1.25rem; }
.share-option { background: var(--bg); border-radius: 14px; border: 2px solid var(--border); padding: 1rem .85rem; text-align: center; cursor: pointer; transition: var(--t); position: relative; }
.share-option.selected { border-color: var(--purple); background: var(--purple-soft); }
.share-option-radio { position: absolute; top: .6rem; right: .6rem; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); }
.share-option-radio.active { background: var(--purple); border-color: var(--purple); display: flex; align-items: center; justify-content: center; }
.share-option-dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.share-option-icon  { font-size: 1.4rem; margin-bottom: .4rem; }
.share-option-label { font-size: .82rem; font-weight: 600; color: var(--navy); margin-bottom: .2rem; }
.share-option-sub   { font-size: .72rem; color: var(--muted); line-height: 1.35; margin-bottom: .65rem; }
.share-preview { background: #fff; border-radius: 8px; padding: .4rem .6rem; display: flex; align-items: center; gap: .5rem; min-height: 32px; }
.share-preview-photo-wrap { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; position: relative; flex-shrink: 0; }
.share-preview-photo { width: 100%; height: 100%; object-fit: cover; display: block; position: relative; z-index: 2; }
.share-preview-photo.hidden { display: none; }
.share-preview-avatar { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; color: #fff; }
.share-preview-avatar.ghost { background: #d1d5db; }
.share-preview-name { font-size: .72rem; font-weight: 600; color: var(--navy); }
.share-preview-ghost-name { height: 10px; width: 80px; background: #d1d5db; border-radius: 4px; }
.share-buttons { display: flex; flex-direction: column; gap: .6rem; }
.share-buttons-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.share-buttons-row .btn { justify-content: center; }
.copy-confirm { text-align: center; font-size: .82rem; font-weight: 600; color: #166534; margin-top: .6rem; min-height: 1.2rem; opacity: 0; transition: opacity .3s; }
.copy-confirm.visible { opacity: 1; }

/* ── Mobile bar ── */
.mobile-bar { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(244,240,235,.95); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: .75rem 1.2rem; justify-content: center; z-index: 99; }

/* ── Stats ── */
.stats-main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.2rem 4rem; position: relative; z-index: 1; display: flex; flex-direction: column; gap: 2.5rem; }
.stats-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.summary-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1rem; text-align: center; }
.summary-value { font-family: var(--font-d); font-size: 1.8rem; font-weight: 900; color: var(--navy); margin-bottom: .25rem; }
.summary-label { font-size: .75rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stats-section-title { font-family: var(--font-d); font-size: 1.5rem; font-weight: 700; margin-bottom: .3rem; }
.stats-section-sub   { font-size: .85rem; color: var(--muted); margin-bottom: 1.2rem; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.stats-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stats-table thead { background: var(--purple-soft); }
.stats-table th { padding: .85rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.stats-table td { padding: .8rem 1rem; font-size: .85rem; border-top: 1px solid var(--border); vertical-align: middle; }
.stats-table tbody tr { transition: var(--t); }
.stats-table tbody tr:hover { background: var(--bg2); }
.stat-rank { font-weight: 700; color: var(--muted); font-size: .8rem; width: 36px; }
.stat-candidate { display: flex; align-items: center; gap: .75rem; min-width: 200px; }
.stat-photo-wrap { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; position: relative; flex-shrink: 0; }
.stat-photo { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; position: relative; z-index: 2; }
.stat-photo.hidden { display: none; }
.stat-avatar { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .7rem; color: #fff; }
.stat-name { font-weight: 600; font-size: .88rem; }
.stat-desc { font-size: .75rem; color: var(--muted); }
.stat-num  { font-weight: 700; font-size: 1rem; color: var(--navy); }
.stat-avg  { font-weight: 600; font-size: .88rem; color: var(--navy); }
.stat-bar-wrap  { min-width: 100px; }
.stat-bar-track { height: 6px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.stat-bar-fill  { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--purple), var(--pink)); transition: width .8s ease; }
.sync-indicator { font-size: .78rem; font-weight: 600; padding: .3rem .75rem; border-radius: var(--radius-pill); background: var(--bg2); border: 1px solid var(--border); }

/* ── Password modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(244,240,235,.92); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 300; padding: 1.5rem; }
.modal-box { background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 3rem 2.5rem; text-align: center; max-width: 380px; width: 100%; animation: slideInRight .35s ease; }
.modal-icon  { font-size: 2.5rem; margin-bottom: .75rem; }
.modal-title { font-family: var(--font-d); font-size: 1.5rem; font-weight: 700; margin-bottom: .4rem; }
.modal-subtitle { font-size: .85rem; color: var(--muted); margin-bottom: 1.5rem; }
.password-field { position: relative; margin-bottom: .75rem; }
.password-input { width: 100%; padding: .75rem 3rem .75rem 1rem; border: 2px solid var(--border); border-radius: var(--radius-pill); font-family: var(--font-b); font-size: .95rem; background: var(--bg); color: var(--navy); transition: var(--t); outline: none; }
.password-input:focus { border-color: var(--purple); }
.eye-toggle { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1.1rem; }
.password-error { font-size: .82rem; color: #ef4444; min-height: 1.2rem; margin-bottom: 1rem; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.shake { animation: shake .4s ease; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 4rem 2rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h2 { font-family: var(--font-d); font-size: 1.5rem; margin-bottom: .5rem; }
.empty-state p { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .duel-area { grid-template-columns: 1fr; gap: 1rem; }
  .vs-separator { transform: rotate(90deg); }
  .candidate-card { min-height: 220px; padding: 1.5rem 1.2rem 2.5rem; }
  .photo-wrap { width: 74px; height: 74px; }
  .mobile-bar { display: flex; }
  .topbar-actions { gap: .35rem; }
  .topbar-actions .btn { padding: .38rem .65rem; font-size: .72rem; }
  .stats-main { gap: 2rem; padding: 1.2rem .8rem 3rem; }
  .stats-summary { grid-template-columns: repeat(3, 1fr); gap: .6rem; }
  .summary-value { font-size: 1.3rem; }
  .stats-table th, .stats-table td { padding: .6rem .7rem; }
  .modal-box { padding: 2rem 1.5rem; }
  .victory-card { padding: 2rem 1.5rem; }
  .game-main { padding: 1.5rem 1rem 7rem; }
  .topbar-inner { padding: .75rem 1rem; }
  .share-options { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 769px) { .mobile-bar { display: none; } }
