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

:root {
    --primary-blue: #002B7F;
    --primary-yellow: #FCD116;
    --primary-red: #CE1126;
    --dark-bg: #0a0a0f;
    --mystic-purple: #8b5cf6;
    --mystic-blue: #3b82f6;
    --mystic-pink: #ec4899;
    --mystic-cyan: #06b6d4;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--dark-bg);
    color: #ffffff;
    overflow: hidden;
    min-height: 100vh;
    position: relative;
    cursor: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y pinch-zoom;
}

#portal-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 100%);
}

/* Game UI */
.game-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-ui.hidden {
    opacity: 0;
}

.game-ui > * {
    pointer-events: auto;
}

.ui-top {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.score-display,
.size-display,
.health-display {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 20px;
    font-family: 'Rajdhani', sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-display .label,
.size-display .label,
.health-display .label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.7;
}

.score-display .value,
.size-display .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--mystic-purple);
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.health-display {
    flex: 1;
    min-width: 200px;
}

.health-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f59e0b, #10b981);
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.health-display .value {
    font-size: 1rem;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

.ui-bottom {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.ui-toggle-btn {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.5);
    border-radius: 12px;
    padding: 12px 24px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.ui-toggle-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: var(--mystic-purple);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.admin-link a {
    color: var(--mystic-purple);
    text-decoration: none;
    font-family: 'Rajdhani', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 8px 16px;
    border-radius: 8px;
}

.admin-link a:hover {
    color: var(--mystic-pink);
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.1);
}

.restart-btn {
    background: linear-gradient(135deg, var(--mystic-purple), var(--mystic-pink));
    border: none;
    border-radius: 12px;
    padding: 16px 40px;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'Rajdhani', sans-serif;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
    -webkit-tap-highlight-color: transparent;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.6);
}

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

/* Leaderboard */
.leaderboard-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(139, 92, 246, 0.5);
    border-radius: 20px;
    padding: 30px;
    min-width: 350px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    display: none;
}

.leaderboard-panel.show {
    display: block;
    animation: fadeInUp 0.3s ease-out;
}

.leaderboard-panel h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--mystic-purple), var(--mystic-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 10px;
    font-family: 'Rajdhani', sans-serif;
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateX(5px);
}

.leaderboard-item .rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--mystic-purple);
    min-width: 30px;
}

.leaderboard-item .score {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    flex: 1;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 40px 40px 1fr auto auto auto;
    gap: 15px;
    align-items: center;
    padding: 15px;
}

.leaderboard-item .rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--mystic-purple);
    text-align: center;
}

.leaderboard-item .country-flag {
    font-size: 1.5rem;
    text-align: center;
}

.leaderboard-item .player-name {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-item .score {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--mystic-pink);
    text-align: right;
    min-width: 60px;
}

.leaderboard-item .size {
    font-size: 0.85rem;
    opacity: 0.7;
    color: var(--mystic-cyan);
    text-align: right;
    min-width: 50px;
}

.leaderboard-item .date-time {
    font-size: 0.75rem;
    opacity: 0.6;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Inter', monospace;
    text-align: right;
    min-width: 140px;
}

.no-scores {
    text-align: center;
    padding: 40px;
    opacity: 0.6;
    font-style: italic;
}

@media (max-width: 768px) {
    .leaderboard-item {
        grid-template-columns: 30px 30px 1fr;
        grid-template-rows: auto auto;
        gap: 8px;
        padding: 12px;
    }
    
    .leaderboard-item .rank,
    .leaderboard-item .country-flag {
        grid-row: 1 / 3;
    }
    
    .leaderboard-item .player-name {
        grid-column: 3;
        font-size: 0.9rem;
    }
    
    .leaderboard-item .score,
    .leaderboard-item .size {
        grid-column: 3;
        font-size: 0.85rem;
        text-align: left;
    }
    
    .leaderboard-item .date-time {
        grid-column: 1 / 4;
        font-size: 0.7rem;
        text-align: center;
        margin-top: 5px;
        padding-top: 5px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
}

.leaderboard-toggle-btn {
    background: rgba(236, 72, 153, 0.2);
    border: 1px solid rgba(236, 72, 153, 0.5);
    border-radius: 12px;
    padding: 12px 24px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.leaderboard-toggle-btn:hover {
    background: rgba(236, 72, 153, 0.3);
    border-color: var(--mystic-pink);
    box-shadow: 0 0 20px rgba(236, 72, 153, 0.4);
}

.sound-toggle-btn {
    background: rgba(6, 182, 212, 0.2);
    border: 1px solid rgba(6, 182, 212, 0.5);
    border-radius: 12px;
    padding: 12px 24px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.sound-toggle-btn:hover {
    background: rgba(6, 182, 212, 0.3);
    border-color: var(--mystic-cyan);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

.sound-toggle-btn.muted {
    opacity: 0.6;
}

/* Danger Alert */
.danger-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.danger-alert.active {
    opacity: 1;
    animation: dangerPulse 0.5s ease-in-out infinite;
}

.alert-content {
    background: rgba(220, 38, 38, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 20px 40px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 0 40px rgba(220, 38, 38, 0.6);
}

.alert-icon {
    font-size: 2rem;
    animation: shake 0.3s ease-in-out infinite;
}

.alert-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

@keyframes dangerPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-10deg);
    }
    75% {
        transform: rotate(10deg);
    }
}

/* Name Input */
.name-input-group {
    margin: 25px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.name-input-group label {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
}

.name-input-group input {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(139, 92, 246, 0.5);
    border-radius: 10px;
    padding: 12px 16px;
    color: #ffffff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.name-input-group input:focus {
    border-color: var(--mystic-purple);
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.name-input-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Game Over Screen */
.game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
}

.game-over-content {
    text-align: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    max-width: 500px;
}

.game-over-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #ef4444, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-score,
.final-size {
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-family: 'Rajdhani', sans-serif;
    opacity: 0.9;
}

.final-score span,
.final-size span {
    color: var(--mystic-purple);
    font-weight: 700;
    font-size: 1.5rem;
}

/* Animations */
@keyframes glow {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 20px rgba(139, 92, 246, 0.6));
    }
    50% {
        filter: brightness(1.4) drop-shadow(0 0 40px rgba(139, 92, 246, 0.9));
    }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        cursor: auto;
    }
    
    .ui-top {
        top: 10px;
        left: 10px;
        right: 10px;
        gap: 10px;
    }
    
    .score-display,
    .size-display,
    .health-display {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .score-display .value,
    .size-display .value {
        font-size: 1.2rem;
    }
    
    .health-display {
        min-width: auto;
        flex: 1 1 100%;
        order: 3;
    }
    
    .ui-bottom {
        bottom: 10px;
        left: 10px;
        right: 10px;
        flex-direction: column;
        gap: 10px;
    }
    
    .ui-toggle-btn,
    .leaderboard-toggle-btn,
    .sound-toggle-btn {
        width: 100%;
        padding: 14px;
    }
    
    .alert-content {
        padding: 15px 25px;
    }
    
    .alert-text {
        font-size: 1.2rem;
    }
    
    .admin-link {
        width: 100%;
        text-align: center;
    }
    
    .leaderboard-panel {
        min-width: 90%;
        padding: 20px;
    }
    
    .start-content,
    .game-over-content {
        padding: 30px 20px;
    }
    
    .main-title {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }
    
    .instructions {
        font-size: 0.95rem;
    }
}
