:root {
    --bg-color: #f0f2f5;
    --primary-color: #cd1a2b;
    --secondary-color: #ffde00;
    --card-back: #b80000;
    --card-front-de: #000077;
    --card-front-zh: #770000;
    --text-light: #ffffff;
    --text-dark: #ffeeee;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}

header {
    text-align: center;
    margin-bottom: 15px;
    width: 100%;
    max-width: 500px;
}

h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stats-container {
    display: flex;
    justify-content: space-between;
    background: white;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.score-val {
    color: var(--primary-color);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 500px;
}

.card {
    aspect-ratio: 1 / 1;
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.15s ease;
}

.card:active {
    transform: scale(0.95); /* Kleiner Druck-Effekt beim Tippen auf dem Handy */
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    padding: 5px;
    text-align: center;
    user-select: none;
}

/* Standardzustand: Rückseite (Fragezeichen) ist sichtbar, Vorderseite versteckt */
.card-back {
    background-color: var(--card-back);
    color: var(--secondary-color);
    font-size: 1.8rem;
    font-weight: bold;
    display: flex;
}

.card-front {
    display: none;
    color: #ffeeee;
    font-size: 0.85rem;
    word-break: break-word;
}

/* Wenn umgedreht oder gelöst: Tausche die Sichtbarkeit komplett flach aus */
.card.flipped .card-back, 
.card.matched .card-back {
    display: none !important;
}

.card.flipped .card-front, 
.card.matched .card-front {
    display: flex !important;
}

/* Transparenz-Effekt NUR für gelöste Trefferkarten */
.card.matched {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
    box-shadow: none;
}

.card-front.de {
    background-color: var(--card-front-de);
    border: 2px solid #ffff00;
}

.card-front.zh {
    background-color: var(--card-front-zh);
    border: 2px solid #ffff00;
}

.zh-char {
    font-size: 1.3rem;
    font-weight: bold;
    display: block;
    margin-bottom: 2px;
}

.zh-pinyin {
    font-size: 0.75rem;
    opacity: 0.9;
}

.btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn:hover {
    background-color: #b01322;
}

.win-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    color: white;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 20px;
    text-align: center;
}

.win-overlay h2 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    font-size: 2rem;
}

.win-overlay p {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

#highscore-msg {
    color: var(--secondary-color);
    font-weight: bold;
    display: none;
    margin-bottom: 20px;
}

#play-again-btn {
    font-size: 1.1rem;
    padding: 12px 25px;
}

@media (max-width: 360px) {
    .card-front {
        font-size: 0.75rem;
    }
    .zh-char {
        font-size: 1.1rem;
    }
    .zh-pinyin {
        font-size: 0.65rem;
    }
}
