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

html, body {
    width: 100%;
    height: 100%;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* ===== HOME / INTRO SCREEN ===== */
#intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    min-height: 100vh;
    padding: 30px 20px;
    background: radial-gradient(ellipse at center, #001133 0%, #000011 100%);
    color: white;
    text-align: center;
    overflow-y: auto;
}

#back-home {
    position: absolute;
    top: 16px;
    left: 16px;
    color: #aaa;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 12px;
    border: 1px solid #444;
    border-radius: 4px;
    transition: color 0.2s, border-color 0.2s;
}

#back-home:hover {
    color: #FFD700;
    border-color: #FFD700;
}

#dev-credit {
    font-size: 0.85rem;
    color: #777;
    font-weight: normal;
}

#intro h1 {
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    color: #FFD700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    letter-spacing: 2px;
}

#name-section {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

#name-section p {
    width: 100%;
    color: #aaa;
    font-size: 0.95rem;
}

#PlayerName {
    padding: 10px 15px;
    font-size: 1rem;
    border-radius: 8px;
    border: 2px solid #FFD700;
    background: rgba(255, 255, 255, 0.07);
    color: white;
    outline: none;
    min-width: 180px;
}

#PlayerName::placeholder {
    color: #555;
}

#savedNames {
    padding: 10px;
    font-size: 1rem;
    border-radius: 8px;
    border: 2px solid #444;
    background: #111;
    color: white;
    cursor: pointer;
}

#StartGame {
    padding: 12px 28px;
    font-size: 1.1rem;
    font-weight: bold;
    background: #FFD700;
    color: #000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.35);
    transition: transform 0.1s, box-shadow 0.1s;
}

#StartGame:hover,
#StartGame:active {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.65);
}

/* ===== LEADERBOARD ===== */
#leaderboard-section {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 14px;
    padding: 20px 28px;
    width: min(420px, 90vw);
}

#leaderboard-section h2 {
    color: #FFD700;
    font-size: 1.2rem;
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.leaderboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.small-btn {
    padding: 6px 10px;
    font-size: 0.85rem;
    background: rgba(255,215,0,0.12);
    color: #FFD700;
    border: 1px solid rgba(255,215,0,0.25);
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s, background 0.2s;
}

.small-btn:hover { background: rgba(255,215,0,0.18); }

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

.small-btn.loading::after {
    content: ' ⟳';
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#leaderboard-list {
    list-style: none;
    padding: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    font-size: 0.95rem;
    color: #ccc;
}

#leaderboard-list li:nth-child(1) { color: #FFD700; font-weight: bold; }
#leaderboard-list li:nth-child(2) { color: #C0C0C0; }
#leaderboard-list li:nth-child(3) { color: #CD7F32; }

/* ===== CONTROLS SECTION ===== */
#controls-section {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 14px;
    padding: 20px 28px;
    width: min(420px, 90vw);
}

#controls-section h3 {
    color: #FFD700;
    font-size: 1.1rem;
    margin-bottom: 14px;
    letter-spacing: 1px;
    text-align: center;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 8px;
}

.control-key {
    color: #FFD700;
    font-weight: bold;
    font-size: 0.85rem;
    padding: 4px 8px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    min-width: 50px;
    text-align: center;
}

.control-label {
    color: #aaa;
    font-size: 0.8rem;
    text-align: center;
}

/* ===== GAME SCREEN ===== */
#Game {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

#GamePlay {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    background: #000;
    margin: 0 auto;
}

/* ===== TOUCH CONTROLS ===== */
#touch-controls {
    position: absolute;
    bottom: 24px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 24px;
    pointer-events: none;
}

#dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: auto;
}

#dpad-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

#dpad-center {
    width: clamp(32px, 6vw, 48px);
    height: clamp(32px, 6vw, 48px);
}

.dpad-btn {
    width: clamp(40px, 8vw, 58px);
    height: clamp(40px, 8vw, 58px);
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: white;
    font-size: clamp(0.9rem, 3vw, 1.3rem);
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#btn-shoot {
    width: clamp(60px, 12vw, 88px);
    height: clamp(60px, 12vw, 88px);
    background: rgba(220, 40, 40, 0.4);
    border: 3px solid rgba(255, 80, 80, 0.65);
    border-radius: 50%;
    color: white;
    font-size: clamp(0.65rem, 2vw, 0.85rem);
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Hide touch controls on desktop (mouse + hover capable devices) */
@media (hover: hover) and (pointer: fine) {
    #touch-controls {
        display: none;
    }
}