* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --success-color: #10b981;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --hover-bg: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0f172a;
    min-height: 100vh;
    color: var(--text-primary);
    padding: 0;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* Modal Styles */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background-color: var(--bg-primary);
    padding: 48px;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 420px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-logo {
    height: 60px;
    width: auto;
    margin-bottom: 24px;
}

.modal-content h2 {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
}

.modal-content p {
    margin-bottom: 32px;
    color: var(--text-secondary);
    font-size: 15px;
}

#usernameForm {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#usernameInput {
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    outline: none;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

#usernameInput:focus {
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#continueBtn {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#continueBtn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#continueBtn:active {
    transform: translateY(0);
}

/* Main Content Container */
#mainContent {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 24px;
}

/* Header Styles */
.header {
    padding: 0 0 32px 0;
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-logo {
    height: 50px;
    width: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

#usernameDisplay {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #f59e0b;
    animation: pulse 2s infinite;
}

.status-indicator.connected .status-dot {
    background-color: var(--success-color);
    animation: none;
}

.status-indicator.disconnected .status-dot {
    background-color: #ef4444;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* Sites Section */
.sites-section {
    padding: 0;
}

.sites-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.site-item {
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.15s ease;
}

.site-item:last-child {
    border-bottom: none;
}


.site-item.unavailable {
    opacity: 0.9;
}

.site-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-name {
    font-size: 17px;
    font-weight: 500;
    color: #ffffff;
}

.site-status-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vote-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: var(--success-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.vote-button:hover {
    background: #059669;
}

.vote-button.unavailable-button {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: not-allowed;
}

.vote-button.unavailable-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.vote-icon {
    font-size: 16px;
}

.unavailable-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.clock-icon {
    font-size: 16px;
}

.countdown {
    font-weight: 500;
}

.countdown-text {
    color: var(--success-color);
    font-weight: 600;
}

/* QR Code Section */
.qr-section {
    padding: 0 0 32px 0;
    margin-bottom: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: block;
}

/* Hide QR section in mobile PWA mode */
@media (max-width: 768px) {
    body.pwa-mode .qr-section {
        display: none;
    }
}

.qr-content {
    display: flex;
    align-items: center;
    gap: 24px;
}

#qrcode {
    flex-shrink: 0;
    background: white;
    padding: 16px;
    border-radius: 8px;
    width: 182px;
    height: 182px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-text {
    color: #ffffff;
    padding: 24px 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.qr-text-subtitle {
    margin-bottom: 0 !important;
}

.nowrap {
    white-space: nowrap;
}

.qr-text p {
    margin: 0 0 8px 0;
    line-height: 1.6;
}

.qr-text strong {
    font-size: 18px;
    color: var(--success-color);
}

.qr-text-desktop {
    display: block;
}

.qr-text-mobile {
    display: none;
}

.phone-vote-image {
    height: 200px;
    width: auto;
    flex-shrink: 0;
    margin-left: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    #qrcode {
        display: none;
    }

    .phone-vote-image {
        display: none;
    }

    .qr-text {
        text-align: center;
    }

    .qr-text-desktop {
        display: none;
    }

    .qr-text-mobile {
        display: block;
    }

    .qr-content {
        justify-content: center;
    }
    #mainContent {
        padding: 20px 16px;
    }

    .header {
        padding: 24px 20px;
        flex-direction: column;
        align-items: flex-start;
        align-items: center;
    }

    .header h1 {
        font-size: 24px;
    }

    .progress-section {
        padding: 24px 20px;
    }

    .site-item {
        padding: 20px;
    }

    .site-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .site-status-wrapper {
        width: 100%;
        justify-content: flex-start;
    }

    .vote-button {
        width: 100%;
        justify-content: center;
    }

    .modal-content {
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 20px;
    }

    .site-name {
        font-size: 16px;
    }
}

/* Stats Button Section */
.stats-button-section {
    padding: 32px 0;
    margin-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
}

.show-stats-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.show-stats-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Stats View */
.stats-view {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 24px;
}

.stats-container {
    width: 100%;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.back-to-voting-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-to-voting-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Stats Navigation */
.stats-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-tab {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stats-tab:hover {
    color: rgba(255, 255, 255, 0.9);
}

.stats-tab.active {
    color: #ffffff;
    border-bottom-color: var(--success-color);
}

/* Stats Tab Content */
.stats-tab-content {
    display: none;
}

.stats-tab-content.active {
    display: block;
}

/* Time Period Selector */
.time-period-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.period-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

.period-btn.active {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

/* Chart Container */
.chart-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.chart-container h3 {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.chart-container canvas {
    max-height: 400px;
}

/* Player Stats Input */
.player-stats-input {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
}

.player-stats-input input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    outline: none;
}

.player-stats-input input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.player-stats-input input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.load-stats-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--success-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-stats-btn:hover {
    background: #059669;
}

.player-stats-charts {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Voters List */
.voters-list-container {
    margin-bottom: 24px;
}

.voters-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.voter-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.voter-item:last-child {
    border-bottom: none;
}

.voter-rank {
    font-size: 16px;
    font-weight: 700;
    color: var(--success-color);
    min-width: 40px;
}

.voter-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.voter-name {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vote-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.vote-status-indicator.can-vote {
    background-color: #10b981; /* green */
}

.vote-status-indicator.cannot-vote {
    background-color: #6b7280; /* gray */
}

.voter-votes {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

.no-voters {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    padding: 48px;
    font-size: 16px;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
}

.pagination-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* Responsive Stats */
@media (max-width: 768px) {
    .stats-view {
        padding: 20px 16px;
    }

    .stats-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .stats-header h1 {
        font-size: 24px;
    }

    .stats-nav {
        flex-wrap: wrap;
    }

    .stats-tab {
        padding: 10px 16px;
        font-size: 14px;
    }

    .time-period-selector {
        justify-content: center;
    }

    .player-stats-input {
        flex-direction: column;
    }

    .player-stats-input input,
    .load-stats-btn {
        width: 100%;
    }

    .chart-container {
        padding: 16px;
    }

    .voter-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    .voter-rank {
        min-width: auto;
    }
}

/* Link Discord Page Styles */
.link-discord-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #0f172a;
}

.link-discord-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.link-discord-logo {
    width: 120px;
    height: auto;
    margin-bottom: 24px;
}

.link-discord-card h1 {
    color: #ffffff;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}

.link-discord-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    margin-bottom: 32px;
}

.link-discord-form {
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 24px;
    text-align: left;
}

.form-group label {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.link-discord-submit-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.link-discord-submit-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.link-discord-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.link-discord-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 16px;
}

.link-discord-message.success {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #10b981;
}

.link-discord-message.error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
}
