#game-root {
    --de-accent: #10B981;
    --de-accent-dark: #0d9467;
    --de-accent-light: #e2f9f0;
    --de-accent-border: #a7f3d0;
    --de-glass-bg: rgba(255, 255, 255, .78);
    --de-glass-border: rgba(255, 255, 255, .45);
    --de-space-1: #0b1130;
    --de-space-2: #1b1b4a;
    border-radius: var(--kw-radius, 16px);
}

.de-wrap {
    position: relative;
    margin: 0 auto;
}

/* ---------- Loading / error / fallback ---------- */

.de-loading,
.de-error {
    text-align: center;
    padding: 60px 16px;
}

.de-loading-icon,
.de-error-icon {
    font-size: 42px;
    margin-bottom: 12px;
    color: #fff;
}

.de-loading-icon {
    animation: de-pulse 1.2s ease-in-out infinite;
}

.de-loading-text {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.de-loading-bar {
    max-width: 220px;
    height: 8px;
    margin: 16px auto 0;
    border-radius: 999px;
    background: var(--de-accent-light);
    overflow: hidden;
}

.de-loading-bar-fill {
    height: 100%;
    width: 30%;
    border-radius: 999px;
    background: var(--de-accent);
    animation: de-loading-slide 1.1s ease-in-out infinite;
}

.de-error-text {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: #EF4444;
    display: inline-block;
    padding: 8px 18px;
    border-radius: 999px;
    max-width: 420px;
}

.de-error-retry {
    display: block;
    margin: 16px auto 0;
    border: none;
    background: var(--de-accent);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    padding: 10px 22px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--de-accent-dark);
}

/* ---------- Globe canvas frame ---------- */

.de-canvas-frame {
    position: relative;
    border-radius: var(--kw-radius, 16px);
    overflow: hidden;
    aspect-ratio: 4 / 3;
    touch-action: none;
}

@media (min-width: 640px) {
    .de-canvas-frame {
        aspect-ratio: 16 / 10;
    }
}

.de-canvas-frame canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.de-canvas-frame canvas:active {
    cursor: grabbing;
}

/* ---------- Toolbar (floats over the canvas) ---------- */

.de-toolbar {
    position: absolute;
    top: 0px;
    left: 0px;
    right: 0px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    pointer-events: none;
}

.de-toolbar > * {
    pointer-events: auto;
}

.de-toolbar-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.de-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--de-glass-border);
    background: rgba(20, 20, 50, .55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    padding: 8px 14px;
    cursor: pointer;
    transition: transform .12s ease, background .15s ease;
    white-space: nowrap;
}

.de-toolbar-btn:hover {
    background: rgba(20, 20, 50, .75);
    transform: translateY(-1px);
}

.de-toolbar-btn svg {
    width: 15px;
    height: 15px;
}

.de-stats-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(20, 20, 50, .55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #FDE68A;
    border: 1px solid var(--de-glass-border);
    border-radius: 999px;
    font-weight: 800;
    font-size: 13px;
    padding: 8px 14px;
    white-space: nowrap;
}

.de-stats-pill svg {
    width: 15px;
    height: 15px;
}

/* ---------- Zoom controls (Google-Maps-style +/- buttons) ---------- */

.de-zoom-controls {
    position: absolute;
    top: 50%;
    right: 0px;
    transform: translateY(-50%);
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.de-zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--de-glass-border);
    background: rgba(20, 20, 50, .55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    border-radius: 12px;
    cursor: pointer;
    transition: transform .12s ease, background .15s ease;
}

.de-zoom-btn:hover {
    background: rgba(20, 20, 50, .75);
}

.de-zoom-btn:active {
    transform: scale(.92);
}

.de-zoom-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- Bottom sheet / side panel (shared shell for country panel,
   discovery list, discovery detail, continents, search, quiz) ---------- */

.de-sheet-backdrop {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

@media (min-width: 640px) {
    .de-sheet-backdrop {
        align-items: center;
        padding: 20px;
    }
}

.de-sheet {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 88%;
    overflow-y: auto;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 18px 18px 22px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .2);
    animation: de-sheet-up .22s ease;
}

@media (min-width: 640px) {
    .de-sheet {
        border-radius: var(--kw-radius, 16px);
        max-height: 85vh;
        animation: de-pop .22s ease;
    }
}

.de-sheet-close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: var(--de-accent-light);
    color: var(--de-accent-dark);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.de-sheet-close svg {
    width: 16px;
    height: 16px;
}

.de-sheet-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    color: var(--de-accent-dark);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 10px;
}

.de-sheet-back svg {
    width: 14px;
    height: 14px;
}

/* ---------- Country panel ---------- */

.de-country-header {
    text-align: center;
    margin-bottom: 14px;
    padding-right: 30px;
}

.de-country-flag {
    font-size: 44px;
    line-height: 1;
    margin-bottom: 4px;
}

.de-country-name {
    font-size: 20px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
}

.de-country-capital {
    font-size: 13px;
    font-weight: 700;
    color: var(--de-accent-dark);
    background: var(--de-accent-light);
    display: inline-block;
    padding: 2px 12px;
    border-radius: 999px;
    margin-top: 6px;
}

.de-country-desc {
    font-size: 14px;
    color: #555;
    text-align: center;
    margin: 10px 0 16px;
    line-height: 1.5;
}

.de-category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.de-category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--de-accent), var(--de-accent-dark));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
    transition: transform .12s ease;
    position: relative;
}

.de-category-btn:hover {
    transform: translateY(-2px);
}

.de-category-icon {
    font-size: 24px;
}

.de-category-label {
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.de-category-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #fff;
    color: var(--de-accent-dark);
    font-size: 11px;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.de-category-count.de-count-zero {
    background: #eee;
    color: #999;
}

/* ---------- Discovery list / cards ---------- */

.de-list-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
    margin-bottom: 12px;
    padding-right: 30px;
}

.de-discovery-list {
    display: grid;
    gap: 10px;
}

.de-discovery-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid #eee;
    background: #fafafa;
    border-radius: 14px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    transition: transform .1s ease, background .15s ease;
}

.de-discovery-card:hover {
    background: var(--de-accent-light);
    transform: translateY(-1px);
}

.de-discovery-card.de-discovered {
    border-color: var(--de-accent-border);
    background: var(--de-accent-light);
}

.de-discovery-card-emoji {
    font-size: 28px;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.de-discovery-card-body {
    flex: 1;
    min-width: 0;
}

.de-discovery-card-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
}

.de-discovery-card-desc {
    font-size: 12px;
    color: #777;
    margin-top: 2px;
}

.de-discovery-card-check {
    color: var(--de-accent);
    flex-shrink: 0;
}

.de-discovery-card-check svg {
    width: 20px;
    height: 20px;
}

/* ---------- Discovery detail ---------- */

.de-detail-emoji {
    font-size: 56px;
    text-align: center;
    margin-bottom: 8px;
}

.de-detail-title {
    font-size: 19px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
    text-align: center;
    margin-bottom: 4px;
    padding-right: 30px;
}

.de-detail-category {
    font-size: 12px;
    font-weight: 700;
    color: var(--de-accent-dark);
    background: var(--de-accent-light);
    display: block;
    width: fit-content;
    margin: 0 auto 14px;
    padding: 3px 12px;
    border-radius: 999px;
}

.de-detail-desc {
    font-size: 14px;
    color: #444;
    line-height: 1.5;
    margin-bottom: 14px;
}

.de-detail-fact {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 13px;
    color: #7c5e10;
    line-height: 1.5;
    display: flex;
    gap: 8px;
}

.de-detail-fact-icon {
    flex-shrink: 0;
}

.de-detail-earned {
    text-align: center;
    margin-top: 14px;
    font-weight: 800;
    font-size: 14px;
    color: var(--de-accent-dark);
    animation: de-pop .3s ease;
}

/* ---------- Continents overview ---------- */

.de-continent-grid {
    display: grid;
    gap: 10px;
}

.de-continent-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid #eee;
    background: #fafafa;
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    text-align: left;
}

.de-continent-card:hover {
    background: var(--de-accent-light);
}

.de-continent-emoji {
    font-size: 30px;
    width: 42px;
    text-align: center;
    flex-shrink: 0;
}

.de-continent-body {
    flex: 1;
    min-width: 0;
}

.de-continent-name {
    font-size: 15px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
}

.de-continent-desc {
    font-size: 12px;
    color: #777;
    margin: 2px 0 6px;
}

.de-continent-progress {
    height: 6px;
    border-radius: 999px;
    background: #e5e5e5;
    overflow: hidden;
}

.de-continent-progress-fill {
    height: 100%;
    background: var(--de-accent);
    border-radius: 999px;
}

.de-continent-stat {
    font-size: 11px;
    font-weight: 700;
    color: var(--de-accent-dark);
    margin-top: 4px;
}

.de-country-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.de-country-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #eee;
    background: #fafafa;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--kw-text, #2D2A32);
    cursor: pointer;
}

.de-country-chip:hover {
    background: var(--de-accent-light);
}

.de-country-chip.de-discovered {
    border-color: var(--de-accent-border);
}

/* ---------- Search ---------- */

.de-search-input {
    width: 100%;
    border: 2px solid #eee;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    margin-bottom: 14px;
    box-sizing: border-box;
}

.de-search-input:focus {
    outline: none;
    border-color: var(--de-accent);
}

.de-search-results {
    display: grid;
    gap: 8px;
}

.de-search-empty {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 20px 0;
}

.de-search-result {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 1px solid #eee;
    background: #fafafa;
    border-radius: 12px;
    padding: 9px 12px;
    cursor: pointer;
    text-align: left;
}

.de-search-result:hover {
    background: var(--de-accent-light);
}

.de-search-result-emoji {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.de-search-result-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--kw-text, #2D2A32);
}

.de-search-result-meta {
    font-size: 11px;
    color: #999;
}

/* ---------- Quiz ---------- */

.de-quiz-question {
    font-size: 16px;
    font-weight: 700;
    color: var(--kw-text, #2D2A32);
    text-align: center;
    margin: 4px 0 18px;
    padding-right: 20px;
    line-height: 1.4;
}

.de-quiz-choices {
    display: grid;
    gap: 10px;
}

.de-quiz-choice {
    border: 2px solid #eee;
    background: #fafafa;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--kw-text, #2D2A32);
    cursor: pointer;
    text-align: left;
    transition: transform .1s ease;
}

.de-quiz-choice:hover:not(:disabled) {
    border-color: var(--de-accent);
    transform: translateY(-1px);
}

.de-quiz-choice:disabled {
    cursor: default;
}

.de-quiz-choice.de-correct {
    border-color: var(--de-accent);
    background: var(--de-accent-light);
}

.de-quiz-choice.de-incorrect {
    border-color: #FCA5A5;
    background: #FEF2F2;
}

.de-quiz-feedback {
    margin-top: 16px;
    text-align: center;
    font-weight: 800;
    font-size: 14px;
    border-radius: 12px;
    padding: 10px;
    animation: de-pop .25s ease;
}

.de-quiz-feedback.de-correct {
    color: var(--de-accent-dark);
    background: var(--de-accent-light);
}

.de-quiz-feedback.de-incorrect {
    color: #7c5e10;
    background: #FFFBEB;
}

.de-quiz-next-btn {
    display: block;
    margin: 16px auto 0;
    border: none;
    background: var(--de-accent);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    padding: 10px 24px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--de-accent-dark);
}

/* ---------- WebGL / CDN fallback ---------- */

.de-fallback {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px 20px;
}

.de-fallback-card {
    color: #fff;
    max-width: 320px;
}

.de-fallback-emoji {
    font-size: 44px;
    margin-bottom: 10px;
}

.de-fallback-text {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    opacity: .9;
}

/* ---------- Animations ---------- */

@keyframes de-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: .7; }
}

@keyframes de-loading-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(430%); }
}

@keyframes de-pop {
    0% { transform: scale(.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes de-sheet-up {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@media (max-width: 380px) {
    .de-category-grid {
        grid-template-columns: 1fr 1fr;
    }

    .de-toolbar-btn span.de-toolbar-label {
        display: none;
    }
}
