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

:root {
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --pixel-green: #00ff00;
    --pixel-cyan: #00ffff;
    --pixel-magenta: #ff00ff;
    --pixel-yellow: #ffff00;
    --pixel-red: #ff0040;
    --pixel-orange: #ff8800;
    --pixel-blue: #0088ff;
    --text-primary: #ffffff;
    --text-dim: #666699;
    --border-light: #333366;
    --pixel-size: 4px;
}

/* Scanline effect overlay */
.container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
}

body {
    font-family: 'Press Start 2P', monospace;
    background: var(--bg-dark);
    min-height: 100vh;
    color: var(--text-primary);
    image-rendering: pixelated;
    position: relative;
    overflow-x: hidden;
}

/* Retro TV Swirl Background */
body::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 200vmax;
    height: 200vmax;
    transform: translate(-50%, -50%);
    background:
        repeating-conic-gradient(
            from 0deg at 50% 50%,
            #0f0f23 0deg,
            #1a0a2e 15deg,
            #0f0f23 30deg,
            #0a1a2e 45deg,
            #0f0f23 60deg
        );
    pointer-events: none;
    z-index: 0;
    animation: retro-swirl 60s linear infinite;
}

/* Retro spiral overlay */
body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 250vmax;
    height: 250vmax;
    transform: translate(-50%, -50%);
    background:
        repeating-conic-gradient(
            from 0deg at 50% 50%,
            transparent 0deg,
            rgba(0, 255, 255, 0.04) 5deg,
            transparent 10deg,
            rgba(255, 0, 255, 0.04) 15deg,
            transparent 20deg
        ),
        repeating-radial-gradient(
            circle at 50% 50%,
            transparent 0px,
            transparent 50px,
            rgba(0, 255, 255, 0.02) 52px,
            transparent 54px,
            transparent 100px,
            rgba(255, 0, 255, 0.02) 102px,
            transparent 104px
        );
    pointer-events: none;
    z-index: 0;
    animation: retro-swirl-reverse 45s linear infinite;
}

@keyframes retro-swirl {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes retro-swirl-reverse {
    from { transform: translate(-50%, -50%) rotate(360deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); }
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px;
    position: relative;
    z-index: 1;
}

/* Pixel border mixin via box-shadow */
header {
    text-align: center;
    margin-bottom: 32px;
    padding: 24px 0 28px 0;
    border-bottom: var(--pixel-size) solid var(--border-light);
}

h1 {
    font-size: 2.2rem;
    color: var(--pixel-cyan);
    margin-bottom: 8px;
    text-shadow:
        var(--pixel-size) var(--pixel-size) 0 var(--pixel-magenta),
        calc(var(--pixel-size) * -1) calc(var(--pixel-size) * -1) 0 var(--pixel-green);
    animation: glitch 3s infinite;
    letter-spacing: 4px;
}

@keyframes glitch {
    0%, 90%, 100% {
        text-shadow:
            var(--pixel-size) var(--pixel-size) 0 var(--pixel-magenta),
            calc(var(--pixel-size) * -1) calc(var(--pixel-size) * -1) 0 var(--pixel-green);
    }
    92% {
        text-shadow:
            calc(var(--pixel-size) * -1) var(--pixel-size) 0 var(--pixel-red),
            var(--pixel-size) calc(var(--pixel-size) * -1) 0 var(--pixel-cyan);
    }
    94% {
        text-shadow:
            var(--pixel-size) calc(var(--pixel-size) * -1) 0 var(--pixel-yellow),
            calc(var(--pixel-size) * -1) var(--pixel-size) 0 var(--pixel-blue);
    }
}

h1::before {
    content: '💰 ';
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
}

.btn-how {
    width: auto;
    padding: 14px 28px;
    background: var(--pixel-magenta);
    border: none;
    color: #fff;
    font-size: 0.65rem;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #660066,
        0 0 20px rgba(255, 0, 255, 0.5);
    animation: how-pulse 2s ease-in-out infinite;
}

@keyframes how-pulse {
    0%, 100% { box-shadow: var(--pixel-size) var(--pixel-size) 0 #660066, 0 0 20px rgba(255, 0, 255, 0.5); }
    50% { box-shadow: var(--pixel-size) var(--pixel-size) 0 #660066, 0 0 35px rgba(255, 0, 255, 0.8); }
}

.btn-how:hover {
    background: #ff66ff;
    color: #000;
    box-shadow: var(--pixel-size) var(--pixel-size) 0 #660066, 0 0 40px rgba(255, 0, 255, 0.9);
    animation: none;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.7rem;
    letter-spacing: 2px;
    margin-top: 8px;
}

.network-badge {
    display: inline-block;
    background: var(--pixel-green);
    color: #000;
    padding: 8px 16px;
    font-size: 0.6rem;
    margin: -8px 0 12px 0;
    text-transform: uppercase;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #008800;
    animation: blink 1s steps(1) infinite;
}

@keyframes blink {
    0%, 70% { opacity: 1; }
    71%, 100% { opacity: 0.7; }
}

/* Pixel Card Style */
.card {
    background: var(--bg-card);
    padding: 16px;
    margin-bottom: 16px;
    border: var(--pixel-size) solid var(--border-light);
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #000,
        inset 0 0 0 var(--pixel-size) rgba(255,255,255,0.05);
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--pixel-size);
    background: linear-gradient(90deg, var(--pixel-cyan), var(--pixel-magenta));
}

.card:hover {
    border-color: var(--pixel-cyan);
}

.card-title {
    font-size: 0.5rem;
    color: var(--pixel-yellow);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

/* Jackpot Display */
.jackpot-card {
    background: linear-gradient(180deg, #1a0a2e 0%, #2a1a4e 100%);
    border-color: var(--pixel-magenta);
    text-align: center;
    padding: 24px 16px;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #440066,
        0 0 20px rgba(255, 0, 255, 0.3),
        inset 0 0 40px rgba(255, 0, 255, 0.1);
}

.jackpot-card::before {
    background: var(--pixel-magenta);
}

.jackpot-label {
    color: var(--pixel-magenta);
    font-size: 0.5rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.jackpot-amount {
    font-size: 1.8rem;
    color: var(--pixel-yellow);
    text-shadow:
        var(--pixel-size) var(--pixel-size) 0 var(--pixel-orange),
        0 0 20px var(--pixel-yellow);
    animation: jackpot-glow 1.5s ease-in-out infinite alternate;
}

@keyframes jackpot-glow {
    from {
        text-shadow:
            var(--pixel-size) var(--pixel-size) 0 var(--pixel-orange),
            0 0 10px var(--pixel-yellow);
    }
    to {
        text-shadow:
            var(--pixel-size) var(--pixel-size) 0 var(--pixel-orange),
            0 0 30px var(--pixel-yellow),
            0 0 50px var(--pixel-orange);
    }
}

.jackpot-amount .sol {
    font-size: 0.8rem;
    color: var(--pixel-cyan);
    margin-left: 8px;
}

/* Countdown Timer */
.countdown-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid rgba(255, 0, 255, 0.3);
}

.countdown-label {
    font-size: 0.5rem;
    color: var(--pixel-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.countdown-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 12px 16px;
    border: 2px solid var(--pixel-magenta);
    min-width: 70px;
}

.countdown-value {
    font-size: 1.4rem;
    color: var(--pixel-green);
    text-shadow: 0 0 15px var(--pixel-green);
    animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.countdown-unit-label {
    font-size: 0.4rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.countdown-separator {
    font-size: 1.4rem;
    color: var(--pixel-magenta);
    text-shadow: 0 0 10px var(--pixel-magenta);
    animation: blink 1s steps(1) infinite;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: #0a0a1a;
    padding: 12px;
    border: 2px solid var(--border-light);
    text-align: center;
    box-shadow: inset 0 0 10px rgba(0, 255, 255, 0.1);
}

.stat-item:hover {
    border-color: var(--pixel-cyan);
    box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.2);
}

.stat-value {
    font-size: 1.2rem;
    color: var(--pixel-green);
    text-shadow: 0 0 10px var(--pixel-green);
}

.stat-label {
    font-size: 0.4rem;
    color: var(--text-dim);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Wallet Section */
.wallet-section {
    text-align: center;
}

.wallet-address {
    font-family: 'Press Start 2P', monospace;
    background: #000;
    padding: 10px 12px;
    font-size: 0.5rem;
    color: var(--pixel-green);
    border: 2px solid var(--pixel-green);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

/* Pixel Buttons */
.btn {
    width: 100%;
    padding: 16px 20px;
    border: none;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    transition: transform 0.1s;
}

.btn:active:not(:disabled) {
    transform: translate(var(--pixel-size), var(--pixel-size));
}

.btn:active:not(:disabled)::after {
    transform: translate(calc(var(--pixel-size) * -1), calc(var(--pixel-size) * -1));
}

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

.btn-primary {
    background: var(--pixel-cyan);
    color: #000;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #006666,
        0 0 20px rgba(0, 255, 255, 0.4);
}

.btn-primary:hover:not(:disabled) {
    background: #66ffff;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #006666,
        0 0 30px rgba(0, 255, 255, 0.6);
}

.btn-success {
    background: var(--pixel-green);
    color: #000;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #006600,
        0 0 20px rgba(0, 255, 0, 0.4);
}

.btn-success:hover:not(:disabled) {
    background: #66ff66;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #006600,
        0 0 30px rgba(0, 255, 0, 0.6);
}

.btn-warning {
    background: var(--pixel-orange);
    color: #000;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #664400,
        0 0 20px rgba(255, 136, 0, 0.4);
}

.btn-warning:hover:not(:disabled) {
    background: #ffaa44;
}

.btn-secondary {
    background: var(--border-light);
    color: var(--text-primary);
    box-shadow: var(--pixel-size) var(--pixel-size) 0 #1a1a33;
}

.btn-slim {
    padding: 10px 16px;
    font-size: 0.5rem;
}

.btn-connected {
    background: var(--pixel-green) !important;
    color: #000 !important;
    box-shadow: var(--pixel-size) var(--pixel-size) 0 #006600 !important;
}

/* Ticket Input */
.ticket-input-group {
    margin-bottom: 12px;
}

.ticket-input {
    width: 100%;
    padding: 14px;
    border: var(--pixel-size) solid var(--pixel-cyan);
    background: #000;
    color: var(--pixel-cyan);
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    text-align: center;
    box-shadow:
        inset 0 0 20px rgba(0, 255, 255, 0.1),
        0 0 10px rgba(0, 255, 255, 0.3);
}

.ticket-input:focus {
    outline: none;
    border-color: var(--pixel-yellow);
    box-shadow:
        inset 0 0 20px rgba(255, 255, 0, 0.1),
        0 0 20px rgba(255, 255, 0, 0.5);
}

.ticket-input::placeholder {
    color: #336666;
}

.cost-display {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 12px;
    font-size: 0.5rem;
    padding: 8px;
    background: rgba(0, 255, 255, 0.05);
    border: 2px solid var(--border-light);
}

.cost-display .amount {
    color: var(--pixel-yellow);
}

/* Status Messages */
.status-message {
    text-align: center;
    padding: 12px;
    margin-bottom: 16px;
    display: none;
    font-size: 0.5rem;
    border: var(--pixel-size) solid;
    animation: message-flash 0.5s;
}

@keyframes message-flash {
    0%, 50% { opacity: 0; }
    51%, 100% { opacity: 1; }
}

.status-message.show {
    display: block;
}

.status-message.error {
    background: rgba(255, 0, 64, 0.2);
    border-color: var(--pixel-red);
    color: var(--pixel-red);
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #660020,
        0 0 20px rgba(255, 0, 64, 0.3);
}

.status-message.success {
    background: rgba(0, 255, 0, 0.1);
    border-color: var(--pixel-green);
    color: var(--pixel-green);
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #006600,
        0 0 20px rgba(0, 255, 0, 0.3);
}

.status-message.info {
    background: rgba(0, 255, 255, 0.1);
    border-color: var(--pixel-cyan);
    color: var(--pixel-cyan);
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #006666,
        0 0 20px rgba(0, 255, 255, 0.3);
}

/* Players List */
.players-list {
    max-height: 180px;
    overflow-y: auto;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #0a0a1a;
    border: 2px solid var(--border-light);
    margin-bottom: 8px;
}

.player-item:hover,
.player-item.player-highlighted {
    border-color: var(--pixel-cyan);
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.player-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
    box-shadow: 0 0 5px currentColor;
}

.player-address {
    font-size: 0.45rem;
    color: var(--text-dim);
    flex: 1;
}

.player-chance {
    font-size: 0.5rem;
    color: var(--pixel-cyan);
    text-shadow: 0 0 5px var(--pixel-cyan);
    min-width: 45px;
    text-align: right;
}

.player-tickets {
    font-size: 0.5rem;
    color: var(--pixel-green);
    text-shadow: 0 0 5px var(--pixel-green);
    min-width: 70px;
    text-align: right;
}

.authority-badge {
    display: inline-block;
    background: var(--pixel-yellow);
    color: #000;
    padding: 2px 6px;
    font-size: 0.35rem;
    margin-left: 6px;
}

.fee-wallet-label {
    color: var(--pixel-yellow);
    text-shadow: 0 0 10px var(--pixel-yellow);
    font-weight: bold;
}

.player-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s, text-shadow 0.2s;
}

.player-link:hover {
    color: var(--pixel-cyan);
    text-shadow: 0 0 10px var(--pixel-cyan);
}

/* Winner Section */
.winner-section {
    text-align: center;
    padding: 24px 16px;
    background: linear-gradient(180deg, #1a2a0a 0%, #2a4a1a 100%);
    border-color: var(--pixel-green);
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #004400,
        0 0 30px rgba(0, 255, 0, 0.4);
}

.winner-section::before {
    background: var(--pixel-green);
}

.winner-section h2 {
    color: var(--pixel-green);
    font-size: 1rem;
    margin-bottom: 12px;
    text-shadow: 0 0 20px var(--pixel-green);
    animation: winner-blink 0.5s steps(1) infinite;
}

@keyframes winner-blink {
    0%, 70% { opacity: 1; }
    71%, 100% { opacity: 0.5; }
}

.winner-address {
    font-size: 0.4rem;
    color: var(--pixel-cyan);
    word-break: break-all;
    background: #000;
    padding: 10px;
    border: 2px solid var(--pixel-green);
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Loading Spinner - Pixel Style */
.loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: currentColor;
    animation: pixel-spin 0.5s steps(8) infinite;
    margin-right: 8px;
}

@keyframes pixel-spin {
    to { transform: rotate(360deg); }
}

/* Chart Styles */
.chart-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
}

.chart-arrow {
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 20px solid var(--pixel-yellow);
    z-index: 10;
    margin-bottom: -4px;
    filter: drop-shadow(0 0 10px var(--pixel-yellow));
}

.chart-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

#winChanceChart {
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #0a0a1a;
    border: 2px solid var(--border-light);
    font-size: 0.4rem;
}

.legend-item:hover {
    border-color: var(--pixel-cyan);
}

.legend-item.legend-you {
    background: rgba(0, 255, 0, 0.1);
    border-color: var(--pixel-green);
}

.legend-item.legend-hovered {
    background: rgba(0, 255, 255, 0.1);
    border-color: var(--pixel-cyan);
}

.legend-color {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.legend-address {
    flex: 1;
    font-size: 0.35rem;
    color: var(--text-dim);
}

.legend-item.legend-you .legend-address {
    color: var(--pixel-green);
}

.legend-percent {
    color: var(--pixel-yellow);
    font-size: 0.45rem;
}

/* Spin Button */
.btn-spin {
    margin-top: 16px;
    background: var(--pixel-magenta);
    color: #fff;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #660066,
        0 0 20px rgba(255, 0, 255, 0.4);
}

.btn-spin:hover:not(:disabled) {
    background: #ff66ff;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #660066,
        0 0 30px rgba(255, 0, 255, 0.6);
}

/* Winner Announcement */
.winner-announcement {
    animation: winner-pop 0.3s steps(5);
}

@keyframes winner-pop {
    0% { transform: scale(0.5); }
    100% { transform: scale(1); }
}

/* Three Column Layout */
.three-columns {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 16px;
    align-items: start;
}

.three-columns .card {
    margin-bottom: 0;
    height: 100%;
}

.three-columns .players-list,
.three-columns .history-list {
    max-height: 350px;
}

.three-columns .chart-legend {
    max-height: 150px;
    overflow-y: auto;
}

@media (max-width: 900px) {
    .three-columns {
        grid-template-columns: 1fr 1fr;
    }

    .three-columns #chartCard {
        grid-column: span 2;
        order: -1;
    }
}

@media (max-width: 600px) {
    .three-columns {
        grid-template-columns: 1fr;
    }

    .three-columns #chartCard {
        grid-column: span 1;
    }

    .three-columns .card {
        margin-bottom: 16px;
    }
}

/* Game History */
.history-card {
    background: var(--bg-card);
}

.history-list {
    max-height: 250px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #0a0a1a;
    margin-bottom: 8px;
    border-left: var(--pixel-size) solid var(--pixel-magenta);
    border-top: 2px solid var(--border-light);
    border-bottom: 2px solid var(--border-light);
    border-right: 2px solid var(--border-light);
}

.history-item:hover {
    border-left-color: var(--pixel-cyan);
    background: rgba(0, 255, 255, 0.05);
}

.history-winner {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-winner-label {
    font-size: 0.3rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.history-winner-address {
    font-size: 0.4rem;
    color: var(--pixel-cyan);
}

.history-winner-percent {
    font-size: 0.35rem;
    color: var(--pixel-green);
    text-shadow: 0 0 5px var(--pixel-green);
}

.history-details {
    text-align: right;
}

.history-prize {
    color: var(--pixel-yellow);
    font-size: 0.5rem;
    text-shadow: 0 0 5px var(--pixel-yellow);
}

.history-time {
    font-size: 0.3rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.history-link {
    display: inline-block;
    font-size: 0.35rem;
    color: var(--pixel-cyan);
    text-decoration: none;
    margin-top: 4px;
    padding: 2px 6px;
    border: 1px solid var(--pixel-cyan);
    transition: all 0.1s;
}

.history-link:hover {
    background: var(--pixel-cyan);
    color: #000;
    text-shadow: none;
}

.history-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 20px;
    font-size: 0.5rem;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 24px;
    padding: 16px 0;
    border-top: var(--pixel-size) solid var(--border-light);
    color: var(--text-dim);
    font-size: 0.4rem;
}

footer a {
    color: var(--pixel-cyan);
    text-decoration: none;
}

footer a:hover {
    color: var(--pixel-yellow);
    text-shadow: 0 0 10px var(--pixel-yellow);
}

/* Scrollbar - Pixel Style */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #0a0a1a;
    border: 2px solid var(--border-light);
}

::-webkit-scrollbar-thumb {
    background: var(--pixel-cyan);
    border: 2px solid var(--border-light);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--pixel-magenta);
}

/* Responsive Design */
@media (max-width: 500px) {
    .container {
        padding: 12px 8px;
    }

    h1 {
        font-size: 0.9rem;
    }

    .jackpot-amount {
        font-size: 1.4rem;
    }

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

    .btn {
        padding: 12px 16px;
        font-size: 0.5rem;
    }

    .ticket-input {
        font-size: 0.8rem;
    }

    #winChanceChart {
        width: 220px !important;
        height: 220px !important;
    }
}

/* CRT Screen Effect */
@keyframes flicker {
    0% { opacity: 0.97; }
    50% { opacity: 1; }
    100% { opacity: 0.98; }
}

.container {
    animation: flicker 0.15s infinite;
}

/* Pixel cursor */
.btn, .ticket-input, a {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><rect x="0" y="0" width="4" height="4" fill="%2300ffff"/><rect x="4" y="4" width="4" height="4" fill="%2300ffff"/><rect x="8" y="8" width="4" height="4" fill="%2300ffff"/></svg>'), pointer;
}

/* ============ CUSTODIAL WALLET SYSTEM STYLES ============ */

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

.modal-content {
    background: var(--bg-card);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    border: var(--pixel-size) solid var(--pixel-red);
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #660020,
        0 0 40px rgba(255, 0, 64, 0.5);
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--pixel-size);
    background: var(--pixel-red);
}

.modal-title {
    color: var(--pixel-red);
    font-size: 0.7rem;
    text-align: center;
    margin-bottom: 12px;
    text-shadow: 0 0 20px var(--pixel-red);
    animation: warning-pulse 1s infinite;
}

@keyframes warning-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.modal-warning {
    color: var(--pixel-yellow);
    font-size: 0.5rem;
    text-align: center;
    margin-bottom: 16px;
}

.private-key-box {
    background: #000;
    padding: 16px;
    border: 2px solid var(--pixel-red);
    margin-bottom: 16px;
    word-break: break-all;
    max-height: 120px;
    overflow-y: auto;
}

.private-key-box code {
    color: var(--pixel-cyan);
    font-size: 0.4rem;
    font-family: 'Press Start 2P', monospace;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.modal-buttons .btn {
    flex: 1;
}

/* How it Works Modal */
.how-modal {
    border-color: var(--pixel-cyan) !important;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #006666,
        0 0 40px rgba(0, 255, 255, 0.5) !important;
    max-width: 550px;
}

.how-modal::before {
    background: var(--pixel-cyan) !important;
}

.how-modal .modal-title {
    color: var(--pixel-cyan);
    text-shadow: 0 0 20px var(--pixel-cyan);
    animation: none;
}

.how-steps {
    margin: 20px 0;
}

.how-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: #0a0a1a;
    border: 2px solid var(--border-light);
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.how-step:hover {
    border-color: var(--pixel-cyan);
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--pixel-cyan);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    box-shadow: 2px 2px 0 #006666;
}

.step-content h3 {
    color: var(--pixel-yellow);
    font-size: 0.5rem;
    margin-bottom: 8px;
}

.step-content p {
    color: var(--text-dim);
    font-size: 0.4rem;
    line-height: 1.6;
}

.how-example {
    background: rgba(255, 255, 0, 0.1);
    border: 2px solid var(--pixel-yellow);
    padding: 12px;
    margin-bottom: 16px;
}

.how-example p {
    color: var(--pixel-yellow);
    font-size: 0.4rem;
    text-align: center;
    line-height: 1.6;
}

.how-example strong {
    color: var(--pixel-green);
}

/* Deposit Card */
.deposit-card {
    text-align: center;
    background: linear-gradient(180deg, #0a1a2a 0%, #1a2a3e 100%);
    border-color: var(--pixel-cyan);
}

.deposit-card::before {
    background: var(--pixel-cyan);
}

.deposit-address-box {
    display: flex;
    align-items: center;
    background: #000;
    padding: 12px;
    border: 2px solid var(--pixel-cyan);
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.deposit-address-box code {
    flex: 1;
    color: var(--pixel-green);
    font-size: 0.4rem;
    font-family: 'Press Start 2P', monospace;
    word-break: break-all;
    text-align: left;
}

.btn-copy {
    background: transparent;
    border: 2px solid var(--pixel-cyan);
    padding: 8px 12px;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.1s;
}

.btn-copy:hover {
    background: var(--pixel-cyan);
}

.btn-copy:hover .copy-icon {
    color: #000;
}

.copy-icon {
    color: var(--pixel-cyan);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
}

.balance-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid var(--pixel-green);
    margin-bottom: 12px;
}

.balance-label {
    color: var(--text-dim);
    font-size: 0.45rem;
}

.balance-value {
    color: var(--pixel-green);
    font-size: 0.7rem;
    text-shadow: 0 0 10px var(--pixel-green);
}

.deposit-hint {
    color: var(--text-dim);
    font-size: 0.4rem;
    margin-top: 12px;
    text-align: center;
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--pixel-cyan);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
    cursor: pointer;
    margin-top: 12px;
    padding: 8px;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--pixel-yellow);
    text-shadow: 0 0 10px var(--pixel-yellow);
}

/* Withdraw Card */
.withdraw-card {
    margin-top: 16px;
    background: linear-gradient(180deg, #1a1a0a 0%, #2a2a1a 100%);
    border-color: var(--pixel-orange);
}

.withdraw-card::before {
    background: var(--pixel-orange);
}

.withdraw-hint {
    color: var(--text-dim);
    font-size: 0.4rem;
    text-align: center;
    margin-bottom: 12px;
}

.withdraw-input-group {
    margin-bottom: 12px;
}

.withdraw-input {
    width: 100%;
    padding: 12px;
    border: var(--pixel-size) solid var(--pixel-orange);
    background: #000;
    color: var(--pixel-orange);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    box-shadow: inset 0 0 10px rgba(255, 136, 0, 0.1);
}

.withdraw-input:focus {
    outline: none;
    border-color: var(--pixel-yellow);
    box-shadow:
        inset 0 0 10px rgba(255, 255, 0, 0.1),
        0 0 15px rgba(255, 255, 0, 0.3);
}

.withdraw-input::placeholder {
    color: #665533;
    font-size: 0.4rem;
}

/* Authority Card */
.authority-card {
    background: linear-gradient(180deg, #2a1a2a 0%, #3a2a3a 100%);
    border-color: var(--pixel-magenta);
    text-align: center;
}

.authority-card::before {
    background: var(--pixel-magenta);
}

.authority-card .btn-secondary {
    background: var(--pixel-magenta);
    color: #fff;
    box-shadow:
        var(--pixel-size) var(--pixel-size) 0 #660066,
        0 0 15px rgba(255, 0, 255, 0.3);
}

.authority-card .btn-secondary:hover:not(:disabled) {
    background: #ff66ff;
}

.authority-card #authoritySection {
    margin-top: 12px;
}

/* Generate Wallet Card */
.generate-card {
    text-align: center;
    background: linear-gradient(180deg, #1a2a1a 0%, #2a3a2a 100%);
    border-color: var(--pixel-green);
    padding: 32px 16px;
}

.generate-card::before {
    background: var(--pixel-green);
}

.generate-hint {
    color: var(--text-dim);
    font-size: 0.45rem;
    margin-bottom: 20px;
}

.join-options {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.join-options .btn {
    width: 100%;
    min-width: 150px;
}

#generateBtnWrapper,
#phantomBtnWrapper {
    flex: 1;
    min-width: 150px;
    max-width: 200px;
}

.join-or {
    color: var(--text-dim);
    font-size: 0.5rem;
    padding: 0 8px;
}

.phantom-deposit-group {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.phantom-deposit-group .btn {
    flex: 0 0 120px;
}

.phantom-input {
    flex: 1;
    padding: 12px;
    border: var(--pixel-size) solid var(--pixel-cyan);
    background: #000;
    color: var(--pixel-cyan);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    text-align: center;
    box-shadow: inset 0 0 10px rgba(0, 255, 255, 0.1);
}

.phantom-input:focus {
    outline: none;
    border-color: var(--pixel-yellow);
    box-shadow: inset 0 0 10px rgba(255, 255, 0, 0.1);
}

.phantom-input::placeholder {
    color: #336666;
    font-size: 0.45rem;
}

/* Confetti Canvas */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000;
}

/* VRF Styles */
.vrf-info {
    font-size: 0.5rem;
    color: var(--pixel-cyan);
    margin-bottom: 0.8rem;
    text-align: center;
}

.vrf-status {
    padding: 0.6rem;
    margin-bottom: 0.8rem;
    border: 2px solid var(--border-light);
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.55rem;
    text-align: center;
}

.vrf-pending {
    color: var(--pixel-yellow);
    animation: pulse 1.5s ease-in-out infinite;
}

.vrf-fulfilled {
    color: var(--pixel-green);
}

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

.btn-vrf {
    background: linear-gradient(180deg, #8800ff 0%, #5500aa 100%);
    color: var(--text-primary);
    border: 3px solid #aa00ff;
    box-shadow:
        0 4px 0 #440088,
        0 0 20px rgba(136, 0, 255, 0.5);
}

.btn-vrf:hover {
    background: linear-gradient(180deg, #aa22ff 0%, #7722cc 100%);
    box-shadow:
        0 4px 0 #550099,
        0 0 30px rgba(136, 0, 255, 0.7);
    transform: translateY(-2px);
}

.btn-vrf:active {
    transform: translateY(2px);
    box-shadow: 0 0 20px rgba(136, 0, 255, 0.5);
}

/* VRF Verification Card */
.vrf-verification-card {
    background: linear-gradient(180deg, rgba(136, 0, 255, 0.2) 0%, rgba(26, 26, 46, 0.98) 100%);
    border: 4px solid #8800ff;
    box-shadow: 0 0 30px rgba(136, 0, 255, 0.4);
    padding: 1.5rem;
    position: relative;
}

.vrf-close-btn {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    background: transparent;
    border: 2px solid #ff0040;
    color: #ff0040;
    font-size: 1.2rem;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-family: Arial, sans-serif;
}

.vrf-close-btn:hover {
    background: #ff0040;
    color: white;
}

.vrf-logo {
    text-align: center;
    font-size: 1.5rem;
    color: var(--pixel-cyan);
    text-shadow: 0 0 20px var(--pixel-cyan), 0 0 40px var(--pixel-magenta);
    margin-bottom: 1rem;
    letter-spacing: 2px;
}

.vrf-verification-card .card-title {
    font-size: 0.8rem;
    color: #aa44ff;
    margin-bottom: 0.5rem;
}

/* VRF Payout Section */
.vrf-payout {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(255, 215, 0, 0.1);
    border: 4px solid #ffd700;
    border-radius: 6px;
}

.vrf-payout-title {
    font-size: 1rem;
    color: #ffd700;
    margin-bottom: 1.2rem;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.vrf-payout-winner,
.vrf-payout-fee {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.vrf-payout-winner {
    border: 2px solid var(--pixel-green);
}

.vrf-payout-fee {
    border: 2px solid var(--pixel-magenta);
}

.payout-label {
    font-size: 0.6rem;
    color: var(--text-dim);
    min-width: 80px;
}

.payout-address {
    font-size: 0.45rem;
    color: var(--pixel-cyan);
    flex: 1;
    text-align: center;
    text-decoration: none;
    word-break: break-all;
    transition: color 0.2s, text-shadow 0.2s;
}

.payout-address:hover {
    color: var(--pixel-yellow);
    text-shadow: 0 0 10px var(--pixel-cyan);
}

.payout-amount {
    font-size: 0.7rem;
    color: var(--pixel-yellow);
    font-weight: bold;
    min-width: 120px;
    text-align: right;
}

.vrf-subtitle {
    font-size: 0.55rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    text-align: center;
}

.vrf-data {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.vrf-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border-light);
    border-radius: 4px;
}

.vrf-label {
    font-size: 0.6rem;
    color: var(--pixel-cyan);
    min-width: 180px;
    font-weight: bold;
}

.vrf-value {
    font-size: 0.55rem;
    color: var(--pixel-yellow);
    word-break: break-all;
    flex: 1;
    font-family: monospace;
}

.vrf-value-long {
    font-size: 0.45rem;
    max-height: 80px;
    overflow-y: auto;
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-light);
}

.vrf-link {
    color: var(--pixel-magenta);
    text-decoration: none;
    flex: 1;
}

.vrf-link:hover {
    color: var(--pixel-cyan);
    text-decoration: underline;
}

.vrf-link code {
    font-size: 0.5rem;
    word-break: break-all;
}

.btn-copy-small {
    background: transparent;
    border: 2px solid var(--pixel-cyan);
    color: var(--pixel-cyan);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy-small:hover {
    background: var(--pixel-cyan);
    color: var(--bg-dark);
}

.vrf-calculation {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(0, 255, 0, 0.15);
    border: 4px solid var(--pixel-green);
    border-radius: 6px;
}

.vrf-calc-title {
    font-size: 1rem;
    color: var(--pixel-green);
    margin-bottom: 1.2rem;
    text-align: center;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.vrf-calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 2px solid rgba(0, 255, 0, 0.2);
}

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

.vrf-calc-row span {
    font-size: 0.7rem;
    color: var(--pixel-cyan);
}

.vrf-calc-row code {
    font-size: 0.65rem;
    color: var(--pixel-yellow);
    font-family: monospace;
    text-align: right;
    max-width: 65%;
    word-break: break-all;
}

.vrf-calc-formula {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 3px solid rgba(0, 255, 0, 0.4);
}

.vrf-calc-formula code {
    color: var(--pixel-cyan);
    font-size: 0.6rem;
}

.vrf-raw-data {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--border-light);
    max-height: 250px;
    overflow-y: auto;
    border-radius: 4px;
}

.vrf-raw-data pre {
    font-size: 0.45rem;
    color: var(--pixel-green);
    white-space: pre-wrap;
    word-break: break-all;
    font-family: monospace;
    line-height: 1.6;
}

/* History Buttons */
.history-buttons {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.history-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
    padding: 0.3rem 0.5rem;
    border: 2px solid var(--pixel-cyan);
    background: transparent;
    color: var(--pixel-cyan);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.history-btn:hover {
    background: var(--pixel-cyan);
    color: var(--bg-dark);
}

.history-vrf-btn {
    border-color: #8800ff;
    color: #aa44ff;
    background: rgba(136, 0, 255, 0.2);
}

.history-vrf-btn:hover {
    background: #8800ff;
    color: white;
}
