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

:root {
    --bg-dark: #0a0e27;
    --bg-darker: #060816;
    --bg-light: #1a1f3a;
    --nano-blue: #4a90e2;
    --nano-green: #7ed321;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border: #2a2f4a;
    --success: #7ed321;
    --warning: #f5a623;
    --error: #d0021b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--nano-blue), var(--nano-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Game Info */
.game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-value.timer {
    color: var(--nano-blue);
    font-family: 'Courier New', monospace;
}

.stat-value.prize {
    color: var(--success);
}

/* Card */
.card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.card h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Instructions */
.instructions {
    list-style-position: inside;
    line-height: 1.8;
    color: var(--text-secondary);
    padding-left: 0;
}

.instructions li {
    margin-bottom: 0.5rem;
}

.instructions strong {
    color: var(--success);
}

/* QR Code & Play Container */
.qr-card {
    text-align: left;
}

.play-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

@media (max-width: 768px) {
    .play-container {
        grid-template-columns: 1fr;
    }
}

.instructions-section {
    padding-right: 1rem;
}

.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-container {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    line-height: 0;
}

#qrcode {
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 0;
}

#qrcode img,
#qrcode canvas {
    max-width: 250px;
    height: auto;
    display: block;
    margin: 0;
}

.game-account {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.account-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-align: center;
}

.account-address {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-darker);
    padding: 1rem;
    border-radius: 8px;
    word-break: break-all;
    margin-bottom: 1rem;
    width: 100%;
    text-align: center;
}

.copy-btn {
    background: var(--nano-blue);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: block;
    margin: 0 auto;
}

.copy-btn:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
}

.copy-btn:active {
    transform: translateY(0);
}

/* Leaderboard */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table thead {
    border-bottom: 2px solid var(--border);
}

.leaderboard-table th {
    padding: 1rem;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
}

.leaderboard-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.leaderboard-table tr.winner {
    background: rgba(126, 211, 33, 0.1);
}

.leaderboard-table tr.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.leaderboard-table tr.clickable-row:hover {
    background: rgba(74, 144, 226, 0.1);
}

.leaderboard-table tr.winner.clickable-row:hover {
    background: rgba(126, 211, 33, 0.2);
}

.rank {
    font-size: 1.2rem;
    font-weight: bold;
}

.account {
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

.time {
    color: var(--success);
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.published {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* History */
.history-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
}

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

.history-item.clickable-history {
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-item.clickable-history:hover {
    background: rgba(74, 144, 226, 0.1);
}

.history-time {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.history-winner {
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

.history-prize {
    color: var(--success);
    font-weight: bold;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.footer p {
    margin-bottom: 0.5rem;
}

.stats-link a {
    color: var(--nano-blue);
    text-decoration: none;
}

.stats-link a:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-right: 2rem;
}

.close {
    color: var(--text-muted);
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--text-primary);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row-label {
    color: var(--text-secondary);
    font-size: 1rem;
}

.stat-row-value {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: bold;
}

.stat-row-label {
    color: var(--text-muted);
}

.stat-row-value {
    color: var(--text-primary);
    font-weight: bold;
}

/* Responsive */
@media (max-width: 768px) {
    .logo {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.5rem;
    }

    .qr-container {
        padding: 1rem;
    }

    /* Convert table to card layout on mobile */
    .leaderboard-table {
        display: block;
    }

    .leaderboard-table thead {
        display: none;
    }

    .leaderboard-table tbody {
        display: block;
    }

    .leaderboard-table tr {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.5rem;
        padding: 1rem;
        margin-bottom: 0.5rem;
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    .leaderboard-table td {
        display: block;
        padding: 0;
        border: none;
    }

    /* First row: Rank, Time, Published */
    .leaderboard-table td.rank {
        grid-column: 1;
        grid-row: 1;
    }

    .leaderboard-table td.time {
        grid-column: 2;
        grid-row: 1;
        text-align: center;
    }

    .leaderboard-table td.published {
        grid-column: 3;
        grid-row: 1;
        text-align: right;
    }

    /* Second row: Account spans all columns */
    .leaderboard-table td.account {
        grid-column: 1 / -1;
        grid-row: 2;
        text-align: center;
        font-size: 0.875rem;
    }

    /* History items - two row layout */
    .history-item {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        gap: 0.5rem;
        padding: 1rem;
    }

    .history-time {
        grid-column: 1;
        grid-row: 1;
        text-align: left;
    }

    .history-prize {
        grid-column: 1;
        grid-row: 1;
        text-align: right;
    }

    .history-winner {
        grid-column: 1;
        grid-row: 2;
        text-align: center;
        font-size: 0.875rem;
    }
}
