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

html {
    /* Prevent scrolling on the html element */
    overflow: hidden;
    height: 100%;
    touch-action: manipulation;
}

body {
    font-family: 'Helvetica Neue', 'Arial', 'Verdana', sans-serif;
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    margin: 0;
    /* PWA and anti-scroll styles */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    /* Prevent elastic scrolling on iOS */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

/* Standalone mode adjustments */
@media all and (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top, 10px);
        padding-bottom: env(safe-area-inset-bottom, 10px);
        padding-left: env(safe-area-inset-left, 10px);
        padding-right: env(safe-area-inset-right, 10px);
    }
    
    .container {
        height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    }
}

.container {
    text-align: center;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

h1 {
    color: white;
    font-size: 4vw;
    margin-bottom: 2vh;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    flex-shrink: 0;
}


.game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2vw;
    background: rgba(255,255,255,0.9);
    padding: 2vw;
    border-radius: 15px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    width: 95vw;
    height: 75vh;
    max-height: 80vh;
    flex-grow: 1;
}

.card {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    border-radius: 2vw;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12vw;
    transition: all 0.3s ease;
    position: relative;
    transform-style: preserve-3d;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    touch-action: manipulation;
    width: 100%;
    height: 100%;
}

.card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 20px rgba(0,0,0,0.25);
}

.card:active {
    transform: translateY(-1px) scale(0.98);
    transition: all 0.1s ease;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    cursor: pointer;
}

.card.matched.flipped {
    transform: rotateY(180deg) scale(0.95);
}

.card.matched:hover {
    transform: translateY(0);
}

.card.matched.flipped:hover {
    transform: rotateY(180deg) scale(0.95);
}

.card.matched .card-front {
    background: linear-gradient(135deg, #00b894, #55a3ff);
    border: 3px solid #00b894;
    box-shadow: 0 0 15px rgba(0, 184, 148, 0.4);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.card-back {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    color: white;
    font-size: 6vw;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.card-front {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    transform: rotateY(180deg);
    font-size: 12vw;
}

.game-complete {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #fff, #f8f9fa);
    padding: 8vw;
    border-radius: 4vw;
    box-shadow: 0 30px 60px rgba(0,0,0,0.4);
    text-align: center;
    z-index: 1000;
    width: 85vw;
    max-width: 600px;
    border: 4px solid #00b894;
}

.game-complete h2 {
    color: #00b894;
    margin-bottom: 4vw;
    font-size: 8vw;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    font-weight: bold;
}

.game-complete p {
    color: #2d3436;
    font-size: 5vw;
    margin-bottom: 6vw;
    font-weight: 500;
    line-height: 1.4;
}

.game-complete .restart-btn {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
    border: none;
    padding: 4vw 8vw;
    border-radius: 3vw;
    font-size: 6vw;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 3px solid transparent;
}

.game-complete .restart-btn:hover {
    background: linear-gradient(135deg, #00a085, #00b894);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 184, 148, 0.6);
    border: 3px solid #00b894;
}

.game-complete .restart-btn:active {
    transform: translateY(-1px) scale(1.02);
}

/* iPad Landscape und Desktop */
@media (min-width: 1024px) {
    h1 {
        font-size: 3vw;
        max-font-size: 4rem;
    }
    
    .card {
        font-size: 10vw;
    }
    
    .card-front {
        font-size: 10vw;
    }
    
    .card-back {
        font-size: 6vw;
    }
    
    .game-complete {
        padding: 60px;
        border-radius: 30px;
        width: 70vw;
    }
    
    .game-complete h2 {
        font-size: 4rem;
        margin-bottom: 30px;
    }
    
    .game-complete p {
        font-size: 2rem;
        margin-bottom: 40px;
    }
    
    .game-complete .restart-btn {
        padding: 20px 40px;
        font-size: 2rem;
        border-radius: 20px;
    }
}

/* iPad Portrait */
@media (max-width: 1023px) and (min-width: 768px) {
    h1 {
        font-size: 5vw;
    }
    
    .card {
        font-size: 11vw;
    }
    
    .card-front {
        font-size: 11vw;
    }
    
    .card-back {
        font-size: 7vw;
    }
    
    .game-complete {
        padding: 50px;
        border-radius: 25px;
        width: 80vw;
    }
    
    .game-complete h2 {
        font-size: 6vw;
        margin-bottom: 25px;
    }
    
    .game-complete p {
        font-size: 4vw;
        margin-bottom: 30px;
    }
    
    .game-complete .restart-btn {
        padding: 15px 30px;
        font-size: 4vw;
        border-radius: 15px;
    }
}

/* Kleinere Tablets und Smartphones */
@media (max-width: 767px) {
    h1 {
        font-size: 6vw;
    }
    
    .game-board {
        gap: 1.5vw;
        padding: 1.5vw;
    }
    
    .card {
        font-size: 14vw;
        border-radius: 3vw;
    }
    
    .card-front {
        font-size: 14vw;
    }
    
    .card-back {
        font-size: 10vw;
    }
}

/* Sehr kleine Smartphones */
@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(5, 1fr);
        gap: 1vw;
        padding: 1vw;
    }
    
    h1 {
        font-size: 8vw;
    }
    
    .card {
        font-size: 16vw;
        border-radius: 4vw;
    }
    
    .card-front {
        font-size: 16vw;
    }
    
    .card-back {
        font-size: 12vw;
    }
}
