/* Memory Match — Tema neon */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #0a0a1a;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px;
}

/* Schermate */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.95);
    z-index: 10;
    padding: 20px;
    text-align: center;
}

.screen h1 {
    color: #ff00ff;
    font-size: 2.5rem;
    text-shadow: 0 0 20px #ff00ff;
    margin-bottom: 10px;
}

.screen h2 {
    color: #00ffff;
    font-size: 1.8rem;
    text-shadow: 0 0 15px #00ffff;
    margin-bottom: 10px;
}

.screen p {
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    margin-bottom: 20px;
}

.win-stats {
    font-size: 1.1rem !important;
    color: rgba(255,255,255,0.8) !important;
}

.final-score {
    color: #ffd700 !important;
    font-size: 1.5rem !important;
    font-weight: 700;
}

.game-btn {
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    border: 2px solid #ff00ff;
    background: transparent;
    color: #ff00ff;
    border-radius: 30px;
    cursor: pointer;
    margin: 6px;
    transition: all 0.3s;
    min-width: 180px;
}

.game-btn:hover, .game-btn:active {
    background: #ff00ff;
    color: #0a0a1a;
    box-shadow: 0 0 20px rgba(255,0,255,0.5);
}

.controls-hint {
    margin-top: 16px;
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
}

/* HUD */
#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 8px 4px;
    margin-bottom: 8px;
}

.hud-left, .hud-center, .hud-right {
    text-align: center;
    flex: 1;
}

.hud-label {
    display: block;
    color: rgba(255,255,255,0.4);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hud-value {
    display: block;
    color: #00ffff;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Griglia carte */
#gameBoard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
}

/* Carta */
.memory-card {
    position: relative;
    cursor: pointer;
    perspective: 800px;
    aspect-ratio: 1;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
    border-radius: 10px;
}

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

.memory-card.matched .card-inner {
    transform: rotateY(180deg);
}

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

.card-back {
    background: linear-gradient(135deg, #1a1040, #2a1060);
    border: 2px solid rgba(255,0,255,0.3);
    font-size: 1.5rem;
    color: rgba(255,0,255,0.4);
}

.card-back::after {
    content: '?';
    font-weight: 700;
    font-size: 1.8rem;
}

.card-front {
    background: linear-gradient(135deg, #1a1a3a, #0d0d2b);
    border: 2px solid rgba(0,255,255,0.3);
    transform: rotateY(180deg);
    font-size: 2.2rem;
}

.memory-card.matched .card-front {
    border-color: #39ff14;
    box-shadow: 0 0 15px rgba(57,255,20,0.3);
}

.memory-card.matched .card-back {
    border-color: #39ff14;
}

/* Animazione match */
@keyframes matchPulse {
    0%, 100% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.08); }
}

.memory-card.matched .card-inner {
    animation: matchPulse 0.4s ease;
}

/* Responsive */
@media (max-width: 400px) {
    #gameBoard { gap: 6px; max-width: 340px; }
    .card-front { font-size: 1.8rem; }
    .card-back::after { font-size: 1.4rem; }
}

@media (max-height: 600px) {
    #gameBoard { max-width: 300px; }
}

.hidden { display: none !important; }
