@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@400;600&display=swap');

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #06060f;
    font-family: 'Inter', Arial, sans-serif;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Phone-shaped game window ─────────────────────── */
/* 9:16 portrait ratio, capped so it always fits the screen */
#game-container {
    position: relative;
    /* Fixed phone aspect ratio: 9 wide : 16 tall */
    aspect-ratio: 9 / 16;
    /* Take as much vertical room as possible, then width follows ratio */
    height: 100vh;
    width: calc(100vh * 9 / 16);
    /* Safety cap: if viewport is very narrow, fill width instead */
    max-width: 100vw;
    max-height: calc(100vw * 16 / 9);
    flex-shrink: 0;
    border-radius: 28px;
    overflow: hidden;
    box-shadow:
        0 0 0 2px rgba(0, 212, 255, 0.2),
        0 0 60px rgba(0, 212, 255, 0.15),
        0 30px 80px rgba(0, 0, 0, 0.8);
}

/* Decorative "phone notch" feel – subtle top bar */
#game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(0,212,255,0.6), transparent);
    z-index: 10;
    pointer-events: none;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Score Display */
#score-display {
    position: absolute;
    top: 16px;
    left: 14px;
    color: #ffffff;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 0 16px rgba(0, 212, 255, 0.8);
    letter-spacing: 1.5px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    backdrop-filter: blur(10px);
}

/* Health Display */
#health-display {
    position: absolute;
    top: 16px;
    right: 14px;
    color: #ff4757;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 0 16px rgba(255, 71, 87, 0.8);
    letter-spacing: 1.5px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 71, 87, 0.3);
    backdrop-filter: blur(10px);
}

/* Message Overlay */
#message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 82%;
    color: #ffffff;
    pointer-events: auto;
    background: rgba(10, 10, 30, 0.88);
    border: 1px solid rgba(0, 212, 255, 0.4);
    border-radius: 22px;
    padding: 40px 28px;
    backdrop-filter: blur(20px);
    box-shadow:
        0 0 50px rgba(0, 212, 255, 0.15),
        0 0 100px rgba(0, 212, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: overlayFadeIn 0.4s ease-out;
}

@keyframes overlayFadeIn {
    from { opacity: 0; transform: translate(-50%, -46%) scale(0.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#message-overlay.hidden {
    display: none;
}

#message-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 30px;
    font-weight: 900;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #00d4ff 0%, #a855f7 50%, #ff4757 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1.5px;
    line-height: 1.2;
}

#message-subtext {
    font-size: 13px;
    margin-bottom: 28px;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.7;
}

#restart-hint {
    font-size: 13px;
    color: rgba(0, 212, 255, 0.95);
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.4);
    border-radius: 50px;
    padding: 10px 24px;
    display: inline-block;
    letter-spacing: 0.8px;
    animation: pulse 2s ease-in-out infinite;
    font-weight: 600;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.7; transform: scale(0.97); }
}

/* ── Landing Page Styles ──────────────────── */
#landing-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #2b0b3f; /* Deep purple background */
    background-image: radial-gradient(circle at center, #4a154b 0%, #1a0525 100%); /* Purple gradient for depth */
    z-index: 100;
    overflow-y: auto;
    padding: 20px;
}

#landing-page.hidden {
    display: none;
}

.landing-content {
    max-width: 1125px; /* Increased by 25% from 900px */
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.landing-split {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 30px;
}

@media (min-width: 768px) {
    .landing-split {
        flex-direction: row;
        align-items: stretch;
    }
}

.landing-banner {
    width: 100%;
    max-height: 300px; /* Increased by 20% from 250px */
    object-fit: cover;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 212, 255, 0.2);
    border: 2px solid rgba(0, 212, 255, 0.3);
}

.landing-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 48px;
    font-weight: 900;
    text-align: center;
    background: linear-gradient(135deg, #00d4ff 0%, #a855f7 50%, #ff4757 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    text-shadow: 0 0 30px rgba(168, 85, 247, 0.4);
}

.landing-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* ── Leaderboard Styles ── */
#leaderboard-container {
    flex: 1;
    background: rgba(10, 10, 30, 0.6);
    border: 2px solid rgba(168, 85, 247, 0.4);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.lb-header {
    font-family: 'Orbitron', sans-serif;
    color: #a855f7;
    text-align: center;
    margin-bottom: 16px;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
    font-size: 24px;
}

#leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 250px;
    padding-right: 5px;
}

#leaderboard-list::-webkit-scrollbar {
    width: 6px;
}
#leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.5);
    border-radius: 10px;
}

.lb-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    color: white;
    font-weight: 600;
    border-left: 4px solid transparent;
}

.lb-rank {
    width: 40px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.5);
}

.lb-rank.rank-1 { color: #ffd700; text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
.lb-rank.rank-2 { color: #c0c0c0; text-shadow: 0 0 10px rgba(192, 192, 192, 0.5); }
.lb-rank.rank-3 { color: #cd7f32; text-shadow: 0 0 10px rgba(205, 127, 50, 0.5); }

.lb-item:nth-child(1) { border-left-color: #ffd700; background: rgba(255, 215, 0, 0.1); }
.lb-item:nth-child(2) { border-left-color: #c0c0c0; background: rgba(192, 192, 192, 0.1); }
.lb-item:nth-child(3) { border-left-color: #cd7f32; background: rgba(205, 127, 50, 0.1); }

.lb-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

.lb-score {
    font-family: 'Orbitron', sans-serif;
    color: #00d4ff;
    font-weight: bold;
}

.lb-loading, .lb-empty, .lb-error {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 20px 0;
    font-style: italic;
}

#player-name-input {
    width: 100%;
    padding: 16px 24px;
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: rgba(20, 20, 40, 0.8);
    border: 2px solid rgba(0, 212, 255, 0.4);
    border-radius: 16px;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

#player-name-input:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4), inset 0 2px 10px rgba(0, 0, 0, 0.5);
    background: rgba(30, 30, 50, 0.9);
}

#player-name-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.game-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid rgba(0, 212, 255, 0.5);
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.game-thumbnail:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: #00d4ff;
    box-shadow: 0 15px 40px rgba(0, 212, 255, 0.4);
}

.game-thumbnail:active {
    transform: translateY(2px) scale(0.98);
}

.game-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.game-thumbnail:hover img {
    transform: scale(1.1);
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease;
}

.game-thumbnail:hover .play-overlay {
    background: rgba(0, 0, 0, 0.2);
}

.play-overlay span {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 212, 255, 0.8);
    letter-spacing: 4px;
    background: rgba(0, 0, 0, 0.5);
    padding: 12px 30px;
    border-radius: 50px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.game-thumbnail:hover .play-overlay span {
    transform: scale(1.1);
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.8);
    color: #00d4ff;
}

/* Hide utility for game container */
#game-container.hidden {
    display: none;
}
/* ── End of styles ─────────────────────── */
