:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --accent-color: #FFC107;
    --bg-color: #f0f9ff;
    --text-color: #333;
    --white: #ffffff;
    --correct-color: #4CAF50;
    --wrong-color: #f44336;
    --xp-color: #9C27B0;
    --fibi-color: #FF5722;
    --locked-color: #9e9e9e;
    --challenge-color: #f44336;
}

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

body {
    font-family: 'Comic Neue', cursive, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
}

#app {
    background: var(--white);
    width: 100%;
    max-width: 1100px;
    min-height: 850px;
    border-radius: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    padding: 20px;
    position: relative;
    border: 8px solid #e0f2fe;
    overflow: hidden;
}

.screen { display: none; flex-direction: column; align-items: center; text-align: center; animation: fadeIn 0.4s ease-out; width: 100%; }
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Header & Stats */
header { width: 100%; margin-bottom: 20px; position: relative; display: flex; flex-direction: column; gap: 10px; }
.player-stats-header { display: flex; align-items: center; gap: 12px; justify-content: flex-end; font-weight: bold; font-size: 0.85rem; }
.xp-mini-bar { width: 80px; height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
#xp-mini-fill { height: 100%; background: var(--xp-color); width: 0%; transition: width 0.5s; }

.map-header { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.island-banner {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 5 / 2;
    margin: 0 auto 12px;
    border: 4px solid #90caf9;
    border-radius: 18px;
    overflow: hidden;
    background: #e3f2fd;
    box-shadow: 0 8px 20px rgba(33,150,243,0.14);
}

.island-banner img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Klassenauswahl */
.grade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; width: 100%; max-width: 500px; }
.grade-btn { background: var(--secondary-color); color: white; border: none; padding: 30px; border-radius: 20px; font-size: 1.5rem; cursor: pointer; transition: transform 0.2s, background 0.2s; font-family: inherit; }
.grade-btn:hover { transform: scale(1.05); background: #1976D2; }

/* Weltkarte (17 Orte) */
.world-map {
    width: 100%;
    height: 600px;
    background: #e3f2fd;
    border-radius: 20px;
    position: relative;
    margin: 10px 0;
    background-image: radial-gradient(#bbdefb 2px, transparent 2px);
    background-size: 20px 20px;
    border: 4px solid #90caf9;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

/* Wir nutzen Flexbox für die Orte, um bei 17 Orten die Übersicht zu behalten */
.world-map {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: 30px 20px;
}

.map-location {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s;
    z-index: 2;
    width: 110px;
    position: relative;
}

.map-location:hover:not(.locked) { transform: scale(1.15); }

.map-location.locked { cursor: not-allowed; filter: grayscale(1); opacity: 0.7; }
.map-location.locked .loc-icon { border-color: #999; }
.loc-lock { position: absolute; top: -10px; right: 0; background: #333; color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 8px; font-weight: bold; z-index: 3; }

.loc-icon { background: white; border-radius: 50%; width: 62px; height: 62px; display: flex; justify-content: center; align-items: center; box-shadow: 0 5px 15px rgba(0,0,0,0.1); border: 4px solid var(--secondary-color); overflow: hidden; }
.loc-icon img { width: 100%; height: 100%; display: block; }
.world-symbol {
    position: absolute;
    top: 42px;
    right: 18px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
    overflow: hidden;
}
.world-symbol img { width: 100%; height: 100%; display: block; }
.loc-label { font-weight: bold; margin-top: 5px; background: rgba(255,255,255,0.9); padding: 4px 8px; border-radius: 10px; font-size: 0.75rem; white-space: nowrap; text-align: center; width: 100%; overflow: hidden; text-overflow: ellipsis; border: 2px solid var(--secondary-color); }
.loc-stars { color: #5f6b7a; font-size: 0.8rem; height: 1.2rem; font-weight: bold; }

/* Missionen */
.mission-panel { width: 100%; background: #fff9c4; padding: 12px; border-radius: 15px; border: 2px solid #fff176; text-align: left; margin-top: 10px; }
.mission-panel h3 { margin-bottom: 5px; color: #fbc02d; font-size: 1rem; }
#mission-list { list-style: none; font-size: 0.9rem; }
.mission-item { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #ffe082; }
.mission-done { text-decoration: line-through; color: #999; }

/* Fibi der Fuchs */
#fibi-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: flex-end;
    pointer-events: none;
    z-index: 10;
}

.fibi-bubble {
    background: white;
    border: 3px solid var(--fibi-color);
    padding: 8px 12px;
    border-radius: 15px 15px 0 15px;
    margin-right: 5px;
    max-width: 160px;
    font-size: 0.8rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    position: relative;
    pointer-events: auto;
}

.fibi-avatar { font-size: 3.5rem; filter: drop-shadow(0 5px 5px rgba(0,0,0,0.1)); }

/* Buttons */
.btn-main { background: var(--primary-color); color: white; padding: 12px 24px; font-size: 1rem; border-radius: 15px; border: none; cursor: pointer; transition: background 0.2s; font-family: inherit; }
.btn-main:hover { background: #45a049; }
.btn-main:disabled { background: #ccc; cursor: not-allowed; }
.btn-secondary { background: var(--secondary-color); color: white; padding: 8px 16px; border-radius: 10px; border: none; cursor: pointer; font-family: inherit; }
.btn-small { background: #eee; padding: 6px 10px; font-size: 0.75rem; border-radius: 8px; border: none; cursor: pointer; width: fit-content; font-family: inherit; }

.btn-challenge { background: #eee; border: 2px solid #ccc; padding: 8px 15px; border-radius: 12px; cursor: pointer; font-weight: bold; font-family: inherit; transition: all 0.2s; }
.btn-challenge.active { background: var(--challenge-color); color: white; border-color: #b71c1c; box-shadow: 0 0 10px rgba(244, 67, 54, 0.4); }

/* Game Elements */
.game-header-top { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.timer { font-size: 1.2rem; font-weight: bold; color: var(--challenge-color); background: #ffebee; padding: 5px 12px; border-radius: 10px; border: 2px solid #ffcdd2; }
.timer.warning { animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.1); color: #d32f2f; } }

#game-container { width: 100%; margin: 20px 0; min-height: 200px; }
.progress-container { width: 100%; height: 10px; background: #eee; border-radius: 5px; margin-top: 10px; overflow: hidden; }
#progress-bar { height: 100%; background: var(--primary-color); width: 0%; transition: width 0.3s; }

.choice-container { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.choice-btn { padding: 10px 20px; font-size: 1.1rem; background: #f8f9fa; border: 3px solid #dee2e6; border-radius: 12px; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.choice-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--secondary-color); }
.choice-btn:disabled { cursor: not-allowed; opacity: 0.8; }

.gap-text { font-size: 1.4rem; margin: 20px 0; line-height: 1.6; }
.gap-input { border: 2px solid #ddd; border-radius: 8px; text-align: center; font-family: inherit; outline: none; font-size: 1.2rem; }
.gap-input:focus { border-color: var(--secondary-color); }

.drop-zone { min-height: 80px; width: 100%; border: 3px dashed #ccc; border-radius: 15px; margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; padding: 15px; justify-content: center; background: #fafafa; transition: background 0.2s; }
.drop-zone.active { background: #e8f5e9; border-color: var(--primary-color); }
.draggable-word { padding: 8px 15px; background: white; border: 2px solid var(--secondary-color); border-radius: 10px; cursor: grab; font-size: 1.1rem; user-select: none; }

#feedback { margin: 20px 0; padding: 15px; border-radius: 15px; background: #f9f9f9; width: 100%; }
.hidden { display: none; }
.success { color: var(--correct-color); font-weight: bold; font-size: 1.2rem; }
.error { color: var(--wrong-color); font-weight: bold; font-size: 1.1rem; }

/* Player Cards */
.player-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; margin: 20px 0; }
.player-card { border: 2px solid #ddd; border-radius: 15px; padding: 15px; cursor: pointer; transition: all 0.2s; min-width: 150px; }
.player-card:hover { border-color: var(--primary-color); background: #f1f8e9; }

/* Bestenliste Table */
.highscore-table-container { width: 100%; max-height: 400px; overflow-y: auto; margin: 20px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #eee; }
th { background: #f8f9fa; }

/* Responsive */
@media (max-width: 768px) {
    .world-map { height: auto; max-height: 600px; }
    .grade-grid { grid-template-columns: 1fr; }
    #app { min-height: auto; }
}
