* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Fredoka One', cursive, sans-serif;
    user-select: none;
    color: #000;
}

body {
    background-color: #2c3e50;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='8' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='4' fill='red'/%3E%3C/svg%3E") 12 12, crosshair;
    /* High-quality scaling when CSS scales the canvas down for 1080p/1440p displays */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
}

#globeCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass through except on active UI elements */
}

#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('ios_wallpaper_4k_1772902840604.png') no-repeat center center;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: auto;
}

.start-content {
    background: rgba(255, 255, 255, 0.45);
    padding: 60px 80px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 40px;
    width: 95vw;
    max-width: 1200px;
    height: auto;
    min-height: 50vh;
    max-height: 95vh;
    overflow-y: auto;
    border-radius: 40px;
}

/* Enforce black text in start screen */
.start-content,
.start-content *,
.start-content label,
.start-content h1,
.start-content span {
    color: #000 !important;
    text-shadow: none !important;
}

.start-content h1 {
    text-shadow: 4px 4px 0 #ffff00 !important;
    position: relative;
}

.tm-symbol {
    font-size: 0.4em;
    vertical-align: super;
    margin-left: 5px;
    font-family: Arial, sans-serif;
    font-weight: normal;
    background: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.start-content .selected-item {
    background-color: rgba(255, 255, 255, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#game-over-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    padding: 60px;
    border-radius: 40px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    /* Inner and outer shadow for liquid depth */
    text-align: center;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
    z-index: 1100;
    max-height: 90vh;
    overflow-y: auto;
}

h1 {
    font-size: 72px;
    color: #000;
    text-shadow: 6px 6px 0 #ffff00;
    /* Knallgul skugga */
    letter-spacing: 2px;
    margin-bottom: 20px;
    line-height: 1.1;
    text-transform: uppercase;
}

#fail-title {
    color: #ff0000;
    /* Knallrött */
    text-shadow: none !important;
}

.input-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    gap: 8px;
    width: 100%;
}

label {
    font-size: 32px;
    color: #000;
    font-weight: 900;
    text-transform: uppercase;
}

input[type="text"] {
    padding: 15px;
    font-size: 24px;
    border: 6px solid #000;
    border-radius: 0;
    outline: none;
    color: #000;
}

input[type="text"]:focus {
    border-color: #3498db;
}

.pause-icon {
    display: flex;
    gap: 10px;
}

.pause-bar {
    width: 10px;
    height: 32px;
    background: #fff;
    border-radius: 2px;
}

.play-icon {
    width: 0;
    height: 0;
    border-top: 18px solid transparent;
    border-bottom: 18px solid transparent;
    border-left: 28px solid #fff; /* Restored white */
    margin-left: 6px;
}

input[type="color"] {
    width: 100%;
    height: 50px;
    border: 4px solid #2c3e50;
    border-radius: 10px;
    cursor: pointer;
}

button {
    width: 100%;
    padding: 25px 60px;
    font-size: 40px;
    background-color: #2ecc71;
    color: #000;
    border: 6px solid #000;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 10px 0 #27ae60;
    transition: all 0.1s;
    margin-top: 20px;
    font-weight: 900;
    text-transform: uppercase;
}

button:active {
    transform: translateY(6px);
    box-shadow: 0 0px 0 #27ae60;
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 20px;
    pointer-events: none;
}

#hud>div {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: #000 !important;
    padding: 15px 25px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    font-size: 24px;
    box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.2);
    font-weight: 900;
}

#hud>div * {
    color: #000 !important;
}

#fps-counter {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(10, 10, 12, 0.85);
    color: #00ff00;
    padding: 10px 20px;
    border-radius: 8px;
    border: 2px solid #00ff00;
    font-size: 24px;
    font-weight: 900;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
    z-index: 2000;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    width: 100%;
    cursor: pointer;
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
}

.selected-item {
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 25px 40px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    color: #000 !important;
}

.selected-item span {
    color: #000 !important;
}

.selected-item:hover {
    filter: brightness(80%);
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-top: none;
    border-radius: 0 0 15px 15px;
    z-index: 100;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    color: #000 !important;
}

/* Continent list opens upward so ANTARKTIS stays on screen */
#continent-list {
    top: auto;
    bottom: 100%;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-bottom: none;
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
}

.dropdown-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    transition: background-color 0.1s;
    color: #000 !important;
    font-size: 28px;
    text-shadow: none !important;
}

.dropdown-item * {
    color: #000 !important;
}

.dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#settings-modal .custom-dropdown {
    font-size: 44px;
}

#settings-modal .dropdown-item {
    padding: 20px 16px;
    font-size: 44px;
    gap: 20px;
}

.dropdown-item.unsupported {
    color: #888 !important;
    opacity: 0.6;
    pointer-events: none;
}

/* Fix for icons inside dropdown */
.dropdown-item canvas,
.selected-item canvas {
    display: block;
    position: static;
    width: 80px;
    height: 60px;
    border: 2px solid #bdc3c7;
    flex-shrink: 0;
}

.dropdown-item:hover {
    background-color: #ecf0f1;
}

/* Anpassa scrollbar för dropdown */
.dropdown-list::-webkit-scrollbar {
    width: 10px;
}

.dropdown-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 5px;
}

.dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #34495e;
}

/* UI Overlay Elements */
#settings-toggle:active, #pause-toggle:active {
    transform: scale(0.9);
}

.glass-toggle {
    position: fixed;
    bottom: 30px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.01); /* 99% Clear */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    cursor: pointer;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.2), 
        inset 0 0 10px rgba(255, 255, 255, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.glass-toggle:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 1);
}

#settings-toggle {
    right: 30px;
}

#pause-toggle {
    right: 150px; 
}

#globe-toggle {
    right: 270px;
}

/* Globe Icon Refinement */
.globe-icon {
    width: 50px;
    height: 50px;
    border: 3px solid #fff;
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.globe-meridian {
    position: absolute;
    width: 20px;
    height: 100%;
    border: 2px solid #fff;
    border-radius: 50%;
}

.globe-equator {
    position: absolute;
    width: 100%;
    height: 2px;
    background: #fff;
}

.rotation-off .globe-icon {
    opacity: 0.4;
    filter: grayscale(1);
}

.rotation-off .globe-icon::after {
    content: '';
    position: absolute;
    width: 120%;
    height: 3px;
    background: #ff0000;
    transform: rotate(45deg);
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Gear Icon Refinement */
.gear-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1); /* Transparent gear body */
    position: relative;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

.gear-tooth {
    position: absolute;
    width: 14px;
    height: 72px;
    background: #fff; /* Restored white for visibility on clear glass */
    border-radius: 3px;
    left: 50%;
    top: 50%;
    margin-left: -7px;
    margin-top: -36px;
    z-index: 1;
}

.gear-inner {
    width: 36px;
    height: 36px;
    background: #fff;
    position: absolute;
    z-index: 4;
    border-radius: 50%;
}

.gear-icon::after {
    content: '';
    width: 18px;
    height: 18px;
    background: #e0e0e0; /* Restored light hole */
    border-radius: 50%;
    z-index: 5;
    box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.gear-tooth:nth-child(2) {
    transform: rotate(0deg);
}

.gear-tooth:nth-child(3) {
    transform: rotate(30deg);
}

.gear-tooth:nth-child(4) {
    transform: rotate(60deg);
}

.gear-tooth:nth-child(5) {
    transform: rotate(90deg);
}

.gear-tooth:nth-child(6) {
    transform: rotate(120deg);
}

.gear-tooth:nth-child(7) {
    transform: rotate(150deg);
}

.gear-tooth:nth-child(8) {
    transform: rotate(180deg);
}

.gear-tooth:nth-child(9) {
    transform: rotate(210deg);
}

.gear-tooth:nth-child(10) {
    transform: rotate(240deg);
}

.gear-tooth:nth-child(11) {
    transform: rotate(270deg);
}

.gear-tooth:nth-child(12) {
    transform: rotate(300deg);
}

.gear-tooth:nth-child(13) {
    transform: rotate(330deg);
}


/* Settings Modal */
#settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    pointer-events: auto;
}

.modal-content {
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    padding: 30px 50px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border-radius: 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 85vw;
    max-width: 1300px;
    max-height: 90vh;
    overflow-y: auto;
    color: #000 !important;
}

.modal-content *,
.modal-content span,
.modal-content label,
.modal-content h2 {
    color: #000 !important;
    text-shadow: none !important;
}

.input-group-header {
    font-size: 32px;
    font-weight: bold;
    text-align: left;
    margin-top: 10px;
    border-bottom: 4px solid #000;
    padding-bottom: 5px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    text-align: left;
}

#fail-title {
    color: #ff0000 !important;
    font-size: 80px;
    margin-bottom: 20px;
}

.modal-content h2 {
    font-size: 48px;
    margin-bottom: 20px;
    text-transform: uppercase;
    color: #000;
}

#close-settings {
    background: #e74c3c;
    box-shadow: 0 10px 0 #c0392b;
}

#close-settings:active {
    box-shadow: 0 0px 0 #c0392b;
}

/* Resolution Dropdown specific */
#resolution-dropdown .selected-item {
    font-size: 28px;
    padding: 20px 30px;
}

#resolution-dropdown .dropdown-item {
    font-size: 24px;
    padding: 15px;
}

/* Mobile Controls System */
#joystick-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60%;
    height: 100%;
    z-index: 1500;
    pointer-events: none;
}

#joystick-base {
    position: absolute;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: none;
    /* Controlled by JS initially */
    pointer-events: auto;
}

/* Make joystick faintly visible on mobile devices even before touch */
@media (pointer: coarse) {
    #joystick-base {
        display: block;
        left: 80px !important;
        bottom: 80px !important;
        top: auto !important;
        opacity: 0.6;
    }
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

#mobile-shoot-btn {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 180px;
    height: 180px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 80px;
    cursor: pointer;
    z-index: 2001;
    pointer-events: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#mobile-shoot-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.4);
}

@media (pointer: coarse) {
    #mobile-shoot-btn {
        display: flex;
    }
}

/* --- Responsive Adjustments for Mobile Screens --- */
@media (max-width: 800px) {

    .start-content,
    .modal-content {
        padding: 30px 15px;
        width: 95vw;
        gap: 20px;
    }

    h1 {
        font-size: 48px;
        letter-spacing: 1px;
    }

    label {
        font-size: 20px;
    }

    button {
        padding: 15px 20px;
        font-size: 32px;
        border-width: 4px;
        margin-top: 10px;
    }

    .custom-dropdown,
    .selected-item,
    .dropdown-item {
        font-size: 20px !important;
    }

    .selected-item {
        padding: 15px 15px;
        gap: 15px;
    }

    .dropdown-item canvas,
    .selected-item canvas {
        width: 50px;
        height: 38px;
        border-width: 1px;
    }

    #settings-modal .custom-dropdown,
    #settings-modal .dropdown-item {
        font-size: 24px !important;
    }
}

/* --- Responsive Adjustments for Short Screens (Landscape/Small Mobile) --- */
@media (max-height: 900px) {
    .start-content {
        gap: 10px;
        padding: 20px 15px;
    }

    h1 {
        font-size: 36px;
        margin-bottom: 5px;
    }

    label {
        font-size: 16px;
    }

    button {
        padding: 10px 20px;
        font-size: 24px;
        border-width: 3px;
        margin-top: 5px;
    }

    .selected-item {
        padding: 10px 15px;
    }

    .custom-dropdown,
    .selected-item,
    .dropdown-item {
        font-size: 18px !important;
    }

    .dropdown-item canvas,
    .selected-item canvas {
        width: 40px;
        height: 30px;
    }

    #settings-toggle, #pause-toggle {
        width: 60px;
        height: 60px;
        bottom: 15px;
    }
    #settings-toggle { right: 15px; }
    #pause-toggle { right: 85px; }

    .pause-bar {
        height: 24px;
        width: 8px;
    }
    .play-icon {
        border-top-width: 12px;
        border-bottom-width: 12px;
        border-left-width: 20px;
    }

    .gear-icon {
        width: 45px;
        height: 45px;
    }

    .gear-tooth {
        width: 10px;
        height: 54px;
        margin-left: -5px;
        margin-top: -27px;
    }

    .gear-icon::after {
        width: 14px;
        height: 14px;
    }
}