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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #000;
    color: #fff;
    overflow: hidden; /* Prevent scrolling */
}

#globeViz {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* Using 100vh, later upgraded to 100dvh for mobile if supported */
    height: 100dvh;
    z-index: 1;
}

/* Mobile-first UI at the bottom */
#ui-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 80%, transparent 100%);
    padding: 20px 15px;
    padding-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Let clicks pass through to the globe when not on inputs */
}

#guess-list {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    pointer-events: auto; /* Re-enable pointer events for the scrollable area */
}

.guess-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    backdrop-filter: blur(4px);
}

#guess-form {
    display: flex;
    gap: 10px;
    pointer-events: auto; /* Re-enable pointer events */
}

#guess-input {
    flex-grow: 1;
    padding: 12px 16px;
    border-radius: 20px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    font-size: 16px; /* 16px prevents iOS zoom on focus */
    outline: none;
}

button {
    padding: 12px 20px;
    border-radius: 20px;
    border: none;
    background: #007aff;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

button:active {
    background: #005bb5;
}

/* Theme Selector */
#theme-selector-container {
    position: absolute;
    top: -40px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 15px;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    pointer-events: auto;
}

#theme-select {
    background: transparent;
    color: white;
    border: none;
    outline: none;
    font-size: 12px;
    cursor: pointer;
}

#theme-select option {
    background: #222;
    color: white;
}

/* Win Overlay & Modals */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    text-align: center;
    padding: 20px;
}

.overlay.hidden {
    display: none;
}

#win-overlay h2 {
    font-size: 32px;
    margin-bottom: 15px;
    color: #34c759;
}

#win-overlay p {
    font-size: 18px;
    margin-bottom: 15px;
}

#stats-container {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 25px;
    width: 100%;
    max-width: 320px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#stats-container h3 {
    margin-bottom: 15px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    border: none;
    padding-bottom: 0;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    padding: 12px 16px;
    border-radius: 12px;
}

.stat-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #34c759;
}

/* Help & Stats Buttons */
#how-to-play-btn, #stats-btn {
    position: absolute;
    top: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: bold;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    cursor: pointer;
    backdrop-filter: blur(4px);
    padding: 0;
    border: none;
    outline: none;
}

#how-to-play-modal, #stats-modal {
    z-index: 200;
}

#how-to-play-btn {
    right: 20px;
}

#stats-btn {
    right: 70px;
}

#how-to-play-btn:active, #stats-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

.modal-content #stats-container {
    margin-bottom: 20px;
    max-width: none;
    background: rgba(255, 255, 255, 0.03);
}

/* Modal Content */
.modal-content {
    background: #1c1c1e;
    padding: 25px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    text-align: left;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #fff;
    text-align: center;
}

.modal-content p {
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 15px;
    color: #ddd;
}

#close-how-to-play-btn, #close-stats-btn {
    display: block;
    margin: 15px auto 0;
    min-width: 120px;
}
