/* ===== FIXED LAYOUT DESIGN ===== */

/* Game Completion Screen */
.completion-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    animation: backdropFadeIn 0.3s ease;
}

@keyframes backdropFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.completion-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 32px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: completionFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: #1a1a1a;
}

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

.completion-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.completion-header h2 {
    font-size: 42px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.2;
}

.answers-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.answers-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.section-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
}

.answers-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.answer-item {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.answer-item.correct-item {
    background: #f0f9ff;
    border: 1px solid #e0f2fe;
    color: #1a1a1a;
}

.answer-item.wrong-item {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    color: #1a1a1a;
}

.answer-text {
    font-weight: 500;
    color: #1a1a1a;
}

.answer-guess {
    color: #666;
    font-weight: 400;
}

.answer-separator {
    color: #999;
    font-size: 12px;
}

.answer-correct {
    color: #1a1a1a;
    font-weight: 500;
}

.completion-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
    text-align: center;
}

.play-again-btn {
    background: #1a1a1a;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
    min-width: 120px;
}

.play-again-btn:hover {
    opacity: 0.85;
}

.play-again-btn:active {
    opacity: 0.75;
}

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

/* Force light mode */
* {
    color-scheme: light !important;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff !important;
    color: #1a1a1a !important;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 400;
}

/* Minimalistic Map-Inspired Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s ease-out;
}

.loading-content {
    text-align: center;
    color: #1a1a1a;
}

.logo-container {
    margin-bottom: 40px;
    position: relative;
}

.logo-circle {
    width: 120px;
    height: 120px;
    border: 2px solid #e5e5e5;
    border-radius: 50%;
    position: relative;
    margin: 0 auto;
    animation: mapRotate 3s linear infinite;
    background: #f8f9fa;
}

.logo-inner {
    width: 100px;
    height: 100px;
    background: #1a1a1a;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: mapPulse 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-inner::before {
    content: "🌍";
    font-size: 32px;
    animation: mapGlow 1.5s ease-in-out infinite;
}

.loading-title {
    font-size: 42px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
}

.loading-subtitle {
    font-size: 16px;
    font-weight: 400;
    color: #666;
    font-family: 'Space Grotesk', sans-serif;
}

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

@keyframes mapPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }
}

@keyframes mapGlow {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

/* Hide loading screen when game is ready */
.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* App Container - 20/80 Split */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Map Area (80%) */
.map-area {
    flex: 0 0 80vh;
    position: relative;
    background: #f8f9fa;
}

/* Map Container */
.map-container {
  width: 100%;
  height: 100%;
    position: relative;
}

/* Reset Button (Top Left, below zoom controls) */
.reset-button {
  position: absolute;
    top: 78px;
    left: 10px;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.15s ease;
    z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.reset-button:hover {
    background: rgba(255, 255, 255, 1);
}

.reset-button svg {
    width: 18px;
    height: 18px;
}

/* Progress Circles (Lower Left) */
.progress-circles {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 6px;
    z-index: 1001;
}

.progress-circle {
    stroke-width: 2.5;
    fill: none;
    transition: all 0.3s ease;
}

.progress-circle.correct circle {
    stroke: #16a34a; /* Tailwind green-600 */
    fill: rgba(22, 163, 74, 0.15);
}

.progress-circle.wrong circle {
    stroke: #dc2626; /* Tailwind red-600 */
    fill: rgba(220, 38, 38, 0.15);
}

.progress-circle.empty circle {
    stroke: #d1d5db; /* Tailwind gray-300 */
    stroke-dasharray: 3 3;
}

.progress-circle.current circle {
    stroke: #3b82f6; /* Tailwind blue-500 */
    fill: rgba(59, 130, 246, 0.1);
    stroke-dasharray: none;
}

.progress-circle:hover circle {
    transform: scale(1.1);
    stroke-width: 3;
}

/* Answer Title */
.answer-title {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    text-align: center;
    z-index: 1000;
    max-width: 500px;
}

.answer-title h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.answer-title p {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

/* Country Tooltip */
.country-tooltip {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(59, 130, 246, 0.2);
    z-index: 1001;
    min-width: 180px;
    max-width: 300px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
}

.country-tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tooltip-content {
    padding: 16px 20px;
    text-align: center;
}

.tooltip-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.3;
}

.tooltip-value {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 18px;
    font-family: 'Space Grotesk', sans-serif;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Leaflet Hover Tooltip */
.country-hover-tooltip {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(15px) !important;
    border: 2px solid rgba(59, 130, 246, 0.3) !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
    font-family: 'Space Grotesk', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    padding: 10px 14px !important;
    margin: 0 !important;
    line-height: 1.4 !important;
    min-width: 120px !important;
    text-align: center !important;
}

.country-hover-tooltip .leaflet-popup-content-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 6px !important;
}

.country-hover-tooltip .leaflet-popup-content {
    margin: 0 !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
}

.country-hover-tooltip .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

/* Footer Area (20%) */
.footer-area {
    flex: 0 0 20vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    padding: 12px 20px 16px 20px;
    gap: 4px;
    overflow: hidden;
    min-height: 0;
    justify-content: space-between;
}

/* Game Mode Toggle (Left) */
.game-mode-toggle {
    position: absolute;
    left: 20px;
    top: 16px;
    display: flex;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 1000;
}

.game-mode-toggle:hover {
    border-color: #d0d0d0;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    color: #666;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.toggle-option i {
    width: 12px;
    height: 12px;
}

.toggle-option.active {
    background: #1a1a1a;
    color: white;
}

/* Input Container (Center) */
.input-container {
    display: flex;
    gap: 8px;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    flex-shrink: 0;
}

.guess-input {
    flex: 1;
    padding: 16px 20px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    transition: all 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
    height: 56px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.guess-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.submit-btn {
  display: flex;
    align-items: center;
  justify-content: center;
    width: 56px;
    height: 56px;
    background: #1a1a1a;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.submit-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.submit-btn:disabled {
    background: #e5e5e5;
    cursor: not-allowed;
}

.submit-btn i {
    width: 18px;
    height: 18px;
}

.hint-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: #ffc107;
    border: none;
    border-radius: 6px;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.hint-btn:hover {
    opacity: 0.9;
}

.hint-btn:disabled {
    background: #e5e5e5;
    cursor: not-allowed;
}

.hint-btn i {
    width: 18px;
    height: 18px;
}

/* Control Buttons (Right) */
.control-buttons {
    position: absolute;
    right: 20px;
    top: 16px;
    display: flex;
    gap: 8px;
    z-index: 1000;
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    color: #666;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none;
}

.control-btn:hover {
    opacity: 0.9;
}

.control-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.control-btn.active:hover {
    opacity: 0.9;
}

.control-btn i {
    width: 14px;
    height: 14px;
}

/* Dataset Counter */
.dataset-counter {
    position: absolute;
    left: 20px;
    top: 64px;
    font-size: 11px;
    font-weight: 500;
    color: #666;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 1000;
    display: none; /* Hidden by default, shown in learn mode via JS */
    padding: 6px 10px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: none;
    align-items: center;
    gap: 4px;
}

.dataset-counter i {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.dataset-counter:hover {
    border-color: #d0d0d0;
    background: #ebebeb;
}

/* Source Attribution */
.source-attribution {
    position: absolute;
    left: 20px;
    top: 64px;
    font-size: 11px;
    font-weight: 500;
    color: #666;
    font-family: 'Space Grotesk', sans-serif;
    transition: all 0.15s ease;
    z-index: 1000;
    display: none; /* Hidden by default, shown in play mode via JS */
    padding: 6px 10px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: none;
    align-items: center;
    gap: 4px;
}

.source-attribution i {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.source-attribution a {
    color: #3b82f6;
    text-decoration: none;
    transition: color 0.15s ease;
}

.source-attribution a:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* Feedback */
.feedback {
    text-align: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    margin: 0 auto;
    max-width: 600px;
    transition: background 0.15s ease;
    flex-shrink: 0;
    min-height: 0;
}

.feedback.correct {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.feedback.incorrect {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.feedback.hint {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Color Bar */
.color-bar {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    flex-shrink: 0;
}

.color-bar-gradient {
    height: 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.color-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 500;
    color: #666;
    font-family: 'Space Grotesk', sans-serif;
}

.color-bar-min,
.color-bar-q1,
.color-bar-mid,
.color-bar-q3,
.color-bar-max {
    font-size: 11px;
    font-weight: 500;
    color: #666;
}

/* Game Mode Menu */
.game-mode-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.menu-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 24px;
    max-width: 400px;
    width: 100%;
}

.menu-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 16px;
    text-align: center;
    font-family: 'Space Grotesk', sans-serif;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    color: #1a1a1a;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
    margin-bottom: 6px;
    font-family: 'Space Grotesk', sans-serif;
}

.mode-option:hover {
    background: #e5e5e5;
    border-color: #1a1a1a;
}

.mode-option i {
    width: 14px;
    height: 14px;
}

/* Enhanced Legend */
.legend {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(20px);
    border-radius: 8px !important;
    padding: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    font-family: 'Space Grotesk', sans-serif !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
    max-width: 350px !important;
    position: absolute !important;
    top: 60px !important;
    left: 20px !important;
}

.legend-gradient {
    margin-bottom: 8px;
}

.gradient-bar {
    height: 12px !important;
    border-radius: 6px !important;
    margin-bottom: 6px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
}

.legend-extremes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.extremes-section {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    padding: 8px;
}

.extremes-title {
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #1a1a1a !important;
    margin-bottom: 4px !important;
    text-align: center;
}

.extremes-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.extreme-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    font-size: 10px !important;
    font-weight: 500 !important;
    color: #1a1a1a !important;
    transition: background 0.15s ease;
}

.extreme-item:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateX(1px);
}

.extreme-value {
    font-weight: 600 !important;
    color: #666 !important;
}

/* Enhanced Map Controls */
.leaflet-control-zoom {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-control-zoom a {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    color: #1a1a1a !important;
    font-weight: 500 !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(1.05) !important;
}

/* Dataset Browser Modal */
.dataset-browser {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.dataset-browser-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 95%;
    width: 100%;
    height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dataset-browser-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.dataset-browser-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    font-family: 'Space Grotesk', sans-serif;
}

.dataset-browser-close {
    width: 32px;
    height: 32px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    color: #666;
}

.dataset-browser-close:hover {
    opacity: 0.9;
}

.dataset-browser-close i {
    width: 14px;
    height: 14px;
}
    
.dataset-browser-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
    
.dataset-browser-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.dataset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.dataset-item {
    padding: 10px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    background: white;
}

.dataset-item:hover {
    border-color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dataset-item h3 {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.3;
}

.dataset-item p {
    font-size: 11px;
    color: #666;
    line-height: 1.3;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Main layout adjustments */
    .app-container {
        flex-direction: column;
    }
    
    .map-area {
        flex: 0 0 50vh; /* Reduce map height on mobile */
        min-height: 50vh;
    }
    
    .footer-area {
        flex: 0 0 auto;
        padding: 12px 16px;
        gap: 8px;
    }
    
    /* Game mode toggle */
    .game-mode-toggle {
        position: relative;
        left: auto;
        top: auto;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .toggle-option {
        font-size: 11px;
        padding: 8px 12px;
        flex: 1;
    }
    
    .toggle-option i {
        width: 14px;
        height: 14px;
    }
    
    /* Dataset counter */
    .dataset-counter {
        position: relative;
        left: auto;
        top: auto;
        margin-bottom: 8px;
        width: 100%;
        justify-content: center;
        padding: 8px 12px;
    }
    
    .dataset-counter i {
        width: 14px;
        height: 14px;
    }
    
    /* Source attribution */
    .source-attribution {
        position: relative;
        left: auto;
        top: auto;
        margin-bottom: 8px;
        width: 100%;
        justify-content: center;
        padding: 8px 12px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .source-attribution i {
        width: 14px;
        height: 14px;
    }
    
    .source-attribution span {
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Control buttons */
    .control-buttons {
        position: relative;
        right: auto;
        top: auto;
        justify-content: center;
        margin-top: 8px;
        gap: 8px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    /* Input container */
    .input-container {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        max-width: 100%;
    }
    
    /* Multiple choice */
    .multiple-choice {
        max-width: 100%;
    }
    
    .choice-options {
        gap: 8px;
    }
    
    .choice-btn {
        padding: 12px;
        font-size: 12px;
        min-height: 48px;
        max-height: 60px;
    }
    
    /* Learn mode controls */
    .nav-btn {
        font-size: 12px;
        padding: 10px 12px;
        gap: 6px;
    }
    
    .nav-btn i {
        width: 12px;
        height: 12px;
    }
    
    .learn-info {
        font-size: 14px;
        padding: 8px;
    }
    
    /* Input fields */
    .submit-btn {
        width: 100%;
        height: 48px;
    }
    
    .hint-btn {
        width: 100%;
        height: 48px;
        margin-left: 0;
    }
    
    .guess-input {
        height: 48px;
        font-size: 14px;
    }
    
    /* Color bar */
    .color-bar {
        max-width: 100%;
        margin-top: 8px;
    }
    
    .color-bar-labels {
        font-size: 10px;
    }
    
    /* Progress circles */
    .progress-circles {
        bottom: 10px;
        left: 10px;
        gap: 4px;
    }
    
    .progress-circle {
        width: 20px;
        height: 20px;
    }
    
    /* Legend */
    .new-legend {
        position: fixed;
        top: auto;
        bottom: 60px;
        right: 10px;
        width: 200px;
        max-height: 40vh;
        font-size: 11px;
        padding: 12px;
    }
    
    .legend-header h3 {
        font-size: 13px;
    }
    
    .sort-toggle-btn {
        width: 24px;
        height: 24px;
    }
    
    .sort-toggle-btn i {
        width: 14px;
        height: 14px;
    }
    
    .legend-country {
        font-size: 11px;
    }
    
    .legend-value {
        font-size: 10px;
    }
    
    .legend-item {
        padding: 6px 8px;
    }
    
    /* Reset button */
    .reset-button {
        top: 10px;
        left: 10px;
        width: 32px;
        height: 32px;
    }
    
    .reset-button svg {
        width: 16px;
        height: 16px;
    }
    
    /* Completion screen */
    .completion-screen {
        padding: 24px;
        min-width: 90%;
        max-width: 90%;
        max-height: 85vh;
    }
    
    .completion-header h2 {
        font-size: 36px;
    }
    
    .answers-grid {
        gap: 16px;
    }
    
    .answer-item {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .answer-guess,
    .answer-correct {
        word-break: break-word;
    }
    
    .play-again-btn {
        width: 100%;
        font-size: 14px;
        padding: 14px 24px;
    }
    
    /* Dataset browser */
    .dataset-browser {
        padding: 10px;
    }
    
    .dataset-browser-content {
        width: 100%;
        max-width: 100%;
        height: 95vh;
    }
    
    .dataset-browser-header {
        padding: 12px 16px;
    }
    
    .dataset-browser-title {
        font-size: 16px;
    }
    
    .dataset-browser-list {
        padding: 12px 16px;
    }
    
    .dataset-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }
    
    .dataset-item {
        padding: 8px 10px;
    }
    
    .dataset-item h3 {
        font-size: 12px;
    }
    
    .dataset-item p {
        font-size: 10px;
    }
    
    /* Legacy support */
    .legend {
        max-width: 90vw !important;
        font-size: 10px !important;
    }
    
    .legend-extremes {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* Extra small devices (phones in portrait, less than 576px) */
@media (max-width: 576px) {
    .map-area {
        flex: 0 0 40vh;
        min-height: 40vh;
    }
    
    .choice-btn {
        font-size: 11px;
        padding: 10px;
        min-height: 44px;
    }
    
    .new-legend {
        width: 180px;
        max-height: 35vh;
        font-size: 10px;
        padding: 10px;
    }
    
    .game-mode-toggle {
        font-size: 10px;
    }
    
    .toggle-option {
        padding: 6px 10px;
        font-size: 10px;
    }
}

/* New Top/Bottom 10 Legend */
.new-legend {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 280px;
    max-height: calc(80vh - 40px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
        padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-family: 'Space Grotesk', sans-serif;
    overflow-y: auto;
}

.legend-header {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.legend-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    flex: 1;
}

.sort-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #f5f5f5;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    color: #666;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.sort-toggle-btn:hover {
    background: #e5e5e5;
    color: #1a1a1a;
}

.sort-toggle-btn i {
    width: 16px;
    height: 16px;
}

.legend-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
    cursor: pointer;
}

.legend-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateX(2px);
}

.legend-country {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 13px;
}

.legend-value {
    font-weight: 700;
    color: #007bff;
    font-size: 12px;
}


/* Hide old legend */
.legend {
    display: none !important;
}

/* Learn Mode Controls (within input container) */
.learn-info {
    font-size: 18px;
    color: #1a1a1a;
    font-family: 'Space Grotesk', sans-serif;
    text-align: center;
    font-weight: 600;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.nav-btn:hover {
    background: #f8fafc;
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.nav-btn i {
    width: 14px;
    height: 14px;
}

/* Multiple Choice (within input container) */
.multiple-choice {
    text-align: center;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}
    
.multiple-choice h3 {
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    color: #1a1a1a;
    font-family: 'Space Grotesk', sans-serif;
}

.choice-options {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr; /* 4 columns in one row */
    gap: 8px;
    width: 100%;
    margin: 0 auto;
    padding: 0; /* Remove padding to match color bar exactly */
}

.choice-options-container {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.next-question-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 6px;
    background: #1a1a1a;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 9px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: 'Space Grotesk', sans-serif;
    flex-shrink: 0;
}

.next-question-btn:hover {
    background: #333;
}

.next-question-btn i {
    width: 8px;
    height: 8px;
}

.choice-btn {
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Space Grotesk', sans-serif;
    text-align: center;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 56px;
    max-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.3;
    width: 100%;
    text-indent: 0;
    word-wrap: break-word;
    hyphens: auto;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

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

.choice-btn:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
    z-index: 10;
    position: relative;
}

.choice-btn.correct {
    background: #16a34a !important;
    border-color: #16a34a !important;
    color: white !important;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3) !important;
}

.choice-btn.incorrect {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
    color: white !important;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3) !important;
}

/* Modern button focus state */
.choice-btn:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.choice-btn:active {
    transition: all 0.1s ease;
}