:root {
    --bg-start: #000000;
    --bg-end: #000000;
    --bg-glow: transparent;
    --panel: rgba(15, 23, 42, 0.72);
    --panel-strong: rgba(15, 23, 42, 0.9);
    --card: rgba(255, 255, 255, 0.07);
    --line: rgba(255, 255, 255, 0.12);
    --text: #f8fafc;
    --muted: #cbd5e1;
    --primary: #60a5fa;
    --primary-strong: #2563eb;
    --success: #34d399;
    --success-strong: #10b981;
    --danger: #f87171;
    --warning: #facc15;
    --shadow: rgba(15, 23, 42, 0.45);
    --input-bg: rgba(255, 255, 255, 0.92);
    --input-text: #0f172a;
}

body.light-theme {
    --bg-start: #dcecff;
    --bg-end: #f4f7fc;
    --bg-glow: rgba(96, 165, 250, 0.2);
    --panel: rgba(255, 255, 255, 0.72);
    --panel-strong: rgba(255, 255, 255, 0.85);
    --card: rgba(255, 255, 255, 0.68);
    --line: rgba(30, 41, 59, 0.08);
    --text: #1e293b;
    --muted: #475569;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --success: #0f9f6e;
    --success-strong: #047857;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: rgba(148, 163, 184, 0.18);
    --input-bg: #ffffff;
    --input-text: #111827;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: radial-gradient(circle at top, var(--bg-glow), transparent 35%), linear-gradient(135deg, var(--bg-start), var(--bg-end));
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

body.light-theme .title,
body.light-theme .stats,
body.light-theme .card,
body.light-theme .admin-link,
body.light-theme .theme-toggle,
body.light-theme .admin-angka,
body.light-theme .angka-calon,
body.light-theme .angka-total,
body.light-theme h2,
body.light-theme h3,
body.light-theme h1 {
    color: var(--text);
}

body.light-theme .stats {
    color: #334155;
}

body.light-theme .title {
    color: #1f2937;
}

body.light-theme .total-card h2 {
    color: #1f2d3d;
    font-size: clamp(2rem, 2.8vw, 3rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

body.light-theme .angka-total {
    color: #f59e0b;
    text-shadow: 0 4px 18px rgba(245, 158, 11, 0.24);
}

body.light-theme .admin-link,
body.light-theme .theme-toggle {
    background: #111827;
    border-color: #111827;
    color: #ffffff;
}

body.light-theme .card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.78);
}

body.light-theme .total-card {
    background: linear-gradient(135deg, rgba(191, 219, 254, 0.9), rgba(255, 255, 255, 0.78));
    border: 1px solid rgba(37, 99, 235, 0.12);
    background-size: 180% 180%;
    animation: totalCardFlow 8s ease-in-out infinite;
    box-shadow: 0 14px 32px rgba(96, 165, 250, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

body.light-theme .calon-a {
    background: linear-gradient(160deg, rgba(219, 234, 254, 0.92), rgba(255, 255, 255, 0.82));
    border: 1px solid rgba(59, 130, 246, 0.24);
    border-top: 5px solid #3b82f6;
}

body.light-theme .calon-b {
    background: linear-gradient(160deg, rgba(209, 250, 229, 0.88), rgba(255, 255, 255, 0.82));
    border: 1px solid rgba(16, 185, 129, 0.24);
    border-top: 5px solid #10b981;
}

body.light-theme .rusak {
    background: linear-gradient(160deg, rgba(254, 226, 226, 0.9), rgba(255, 255, 255, 0.82));
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-top: 5px solid #ef4444;
}

body.light-theme .calon-a .angka-calon { color: #1d4ed8; }
body.light-theme .calon-b .angka-calon { color: #047857; }
body.light-theme .rusak .angka-calon { color: #b91c1c; }

body.light-theme .progress-container {
    background: rgba(148, 163, 184, 0.22);
}

body.light-theme .btn-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

body.light-theme .btn-danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

body.light-theme .btn-plus {
    background: linear-gradient(135deg, #34d399, #059669);
}

body.light-theme .btn-minus {
    background: linear-gradient(135deg, #f87171, #dc2626);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 50px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 18px;
    box-shadow: 0 10px 30px var(--shadow);
    flex-wrap: wrap;
    gap: 12px;
}

#display-page header {
    justify-content: center;
}

#display-page .title {
    width: 100%;
    text-align: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.title {
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.admin-link,
.theme-toggle,
.btn {
    text-decoration: none;
    font-weight: 700;
    border-radius: 999px;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.admin-link,
.theme-toggle {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    padding: 0.8rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-width: 52px;
    min-height: 52px;
    font-size: 1.4rem;
    line-height: 1;
}

.theme-toggle {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 10;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 50%;
    background: var(--panel-strong);
    box-shadow: 0 10px 26px var(--shadow);
}

.theme-toggle.moon-icon {
    color: #ffffff;
}

body.dark-theme .theme-toggle {
    background: #ffffff;
    border-color: #ffffff;
    color: #facc15;
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.65);
}

.admin-link:hover,
.theme-toggle:hover,
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.12);
}

.card {
    background: var(--card);
    backdrop-filter: blur(12px);
    border-radius: 22px;
    padding: 1.6rem;
    text-align: center;
    box-shadow: 0 12px 35px var(--shadow);
    border: 1px solid var(--line);
}

.announcement-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.75);
    color: white;
    border-radius: 999px;
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.announcement-bar.hidden {
    display: none !important;
}

.announcement-label {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.announcement-track {
    overflow: hidden;
    flex: 1;
    white-space: nowrap;
    position: relative;
}

.announcement-text {
    display: inline-block;
    min-width: 100%;
    padding-left: 100%;
    animation: marquee 18s linear infinite;
    font-weight: 700;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

.announcement-launcher {
    position: relative;
    width: 100%;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    height: 42px;
}

.announcement-icon-button {
    position: relative;
    left: 50%;
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    font-size: 1.05rem;
    line-height: 1;
    transform: translateX(-50%);
}

.announcement-icon-button i {
    display: block;
    line-height: 1;
}

.announcement-icon-button:hover {
    transform: translateX(-50%) translateY(-1px);
}

.announcement-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.announcement-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    resize: vertical;
    min-height: 100px;
    background: var(--input-bg);
    color: var(--input-text);
    font: inherit;
}

.form-status {
    min-height: 1.25rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.form-status.success {
    color: var(--success);
}

.form-status.error {
    color: var(--danger);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.68);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
    padding: 1.6rem;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
    animation: modal-in 0.2s ease-out;
}

.modal-card h3 {
    color: var(--text);
    padding-right: 2rem;
}

.modal-close {
    position: absolute;
    top: 0.8rem;
    right: 0.9rem;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--card);
    color: var(--text);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.reset-modal-card {
    text-align: center;
}

.reset-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(248, 113, 113, 0.16);
    color: var(--danger);
    font-size: 1.35rem;
}

.reset-message {
    margin-top: 0.7rem;
    color: var(--muted);
    line-height: 1.5;
}

.reset-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.4rem;
}

.reset-actions .btn {
    min-width: 120px;
}

.btn-secondary {
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--text);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.total-card {
    margin-bottom: 2rem;
    background: linear-gradient(135deg, rgba(191, 219, 254, 0.9), rgba(255,255,255,0.7));
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.25);
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 28px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
    background-size: 180% 180%;
    animation: totalCardFlow 8s ease-in-out infinite;
}

@keyframes totalCardFlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.total-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent, rgba(255,255,255,0.12), transparent);
    transform: translateX(-100%);
    animation: shimmer 4s linear infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.angka-total {
    font-size: clamp(3rem, 15vw, 10rem);
    font-weight: 900;
    line-height: 1;
    margin: 1rem 0 0.4rem;
    color: var(--warning);
    text-shadow: none;
}

body.dark-theme .angka-total,
body.dark-theme .angka-calon {
    text-shadow: none;
}

body.dark-theme .total-card h2 {
    color: #1e293b;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

body.dark-theme .total-card .angka-total {
    color: #047857;
    text-shadow: 0 4px 18px rgba(4, 120, 87, 0.28);
}

.count-pulse {
    animation: countPulse 0.35s ease;
}

@keyframes countPulse {
    0% { transform: scale(1); }
    35% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.grid-calon {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.calon-card {
    position: relative;
    overflow: hidden;
}

.calon-card h2 {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: 0.8rem;
}

.calon-a {
    border-top: 5px solid var(--primary);
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.18) 0%, transparent 100%);
}

.calon-b {
    border-top: 5px solid var(--success);
    background: linear-gradient(180deg, rgba(52, 211, 153, 0.16) 0%, transparent 100%);
}

.rusak {
    border-top: 5px solid var(--danger);
    background: linear-gradient(180deg, rgba(248, 113, 113, 0.15) 0%, transparent 100%);
}

.angka-calon {
    font-size: clamp(2rem, 8vw, 6rem);
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stats {
    font-size: clamp(1rem, 2vw, 1.7rem);
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--muted);
}

.progress-container {
    width: 100%;
    height: 16px;
    background: rgba(15, 23, 42, 0.2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--line);
}

.progress-bar {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease-in-out;
    border-radius: inherit;
}

.calon-a .progress-bar { background: linear-gradient(90deg, var(--primary), var(--primary-strong)); }
.calon-b .progress-bar { background: linear-gradient(90deg, var(--success), var(--success-strong)); }
.progress-bar.bar-tie { background: linear-gradient(90deg, #facc15, #eab308) !important; }
.progress-bar.bar-winner { background: linear-gradient(90deg, #22c55e, #15803d) !important; }
.progress-bar.bar-loser { background: linear-gradient(90deg, #f87171, #dc2626) !important; }

.hidden { display: none !important; }

.login-card {
    max-width: 420px;
    margin: 50px auto;
    padding: 2rem 1.6rem;
}

input[type="email"], input[type="password"] {
    width: 100%;
    padding: 0.9rem 1rem;
    margin-bottom: 15px;
    border-radius: 12px;
    border: 1px solid var(--line);
    font-size: 16px;
    background: var(--input-bg);
    color: var(--input-text);
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.btn {
    padding: 0.9rem 1.4rem;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    color: white;
}

.btn:active { opacity: 0.92; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    width: 100%;
}
.btn-primary.announcement-icon-button {
    width: 42px;
}
.btn-danger {
    background: linear-gradient(135deg, #ef4444, var(--danger));
}

.control-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.btn-minus, .btn-plus {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 1.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    box-shadow: 0 10px 22px rgba(0,0,0,0.18);
}

.btn-minus { background: linear-gradient(135deg, #f87171, var(--danger)); }
.btn-plus { background: linear-gradient(135deg, var(--success), var(--success-strong)); }

.admin-angka {
    font-size: 2.5rem;
    font-weight: 800;
    min-width: 70px;
}

.admin-controls { margin-bottom: 2rem; }

.reset-section {
    margin-top: 3rem;
    text-align: center;
}
.btn-large {
    font-size: 1.1rem;
    padding: 1rem 2rem;
}
.error-msg {
    color: var(--danger);
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
}

@media (orientation: landscape) and (max-height: 600px) {
    .angka-total { font-size: clamp(2.5rem, 8vw, 5rem); }
    .angka-calon { font-size: clamp(1.8rem, 6vw, 4rem); }
    .card { padding: 1rem; }
    .total-card { margin-bottom: 1rem; }
}

@media (min-width: 1024px) {
    .container { padding: 40px; }
    .grid-calon { gap: 40px; }
}

@media (max-width: 640px) {
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .theme-toggle {
        right: 1rem;
        bottom: 1rem;
    }

    .admin-link {
        flex: 0 0 auto;
        min-width: 42px;
    }
}
