/* --- YLEISET TYYLIT --- */
:root {
    --primary: #d32f2f;
    --primary-hover: #b71c1c;
    --dark: #1a1a1a;
    --light: #ffffff;
    --accent: #f4f4f4;
    --shadow: 0 4px 15px rgba(0,0,0,0.3);
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--dark);
    color: white;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
text-align:center;
}

/* --- HEADER.PHP TYYLIT --- */
.game-header {
    width: 100%;
    background: #111;
    padding: 10px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 15px rgba(0,0,0,0.8);
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 20px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.05);
}

.nav-link:hover, .nav-link.active {
    background: var(--primary);
    transform: translateY(-2px);
}

/* --- TOP_SCORES.PHP TYYLIT --- */
.top-scores-container {
    max-width: 400px;
    margin: 30px auto;
    background: rgba(0,0,0,0.4);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(211, 47, 47, 0.3);
}

.top-scores-container h3 {
    text-align: center;
    margin-top: 0;
    color: var(--primary);
    text-transform: uppercase;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #333;
}

.rank { color: #ffd700; font-weight: bold; margin-right: 10px; }
.points { font-weight: bold; color: #fff; }

/* --- PELIHALLIN (INDEX.PHP) KORTIT --- */
.game-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    max-width: 1000px;
    width: 90%;
    margin: 20px auto;
}

.game-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #333;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(211, 47, 47, 0.4);
}

.play-btn {
    display: inline-block;
    padding: 10px 25px;
    background: var(--primary);
    color: white;
    border-radius: 25px;
    font-weight: bold;
}

/* --- MOBIILIOPTIMOINTI --- */
@media (max-width: 768px) {
    .nav-link span { display: none; }
    .nav-link { font-size: 1.2rem; padding: 10px; }
}
/* --- PELIKOHTAISET TYYLIT (CANVAS JA UI) --- */
canvas { 
    display: block; 
    background: #fff; 
    margin: 0 auto; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5); 
    max-width: 100%;
    height: auto;
}

.ui {
    position: absolute; 
    top: 60px; /* Laskettu alemmas, jotta se ei jää headerin alle */
    left: 50%; 
    transform: translateX(-50%);
    width: 90%; 
    display: flex; 
    justify-content: space-between;
    font-size: 20px; 
    font-weight: bold; 
    pointer-events: none;
    color: var(--dark); 
    text-shadow: 1px 1px 0px white;
    z-index: 5;
}

.game-over {
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95); 
    color: var(--dark); 
    padding: 30px;
    border-radius: 15px; 
    text-align: center; 
    display: none; 
    width: 280px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 100;
}

.btn-game { 
    background: var(--primary); 
    color: white; 
    border: none; 
    padding: 10px 20px; 
    border-radius: 5px; 
    cursor: pointer; 
    font-weight: bold;
    text-transform: uppercase;
    margin-top: 10px;
}
/* --- ONNENPYÖRÄN ERIKOISTYYLIT --- */
.wheel-container { 
    position: relative; 
    width: 350px; 
    height: 350px; 
    margin: 30px auto; 
}

/* Nuoli ylhäällä */
.arrow {
    position: absolute; 
    top: -20px; 
    left: 50%; 
    transform: translateX(-50%);
    width: 0; 
    height: 0; 
    border-left: 20px solid transparent; 
    border-right: 20px solid transparent;
    border-top: 40px solid var(--primary); 
    z-index: 10;
}

#wheelCanvas {
    width: 100%; 
    height: 100%; 
    border-radius: 50%;
    border: 8px solid #444; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 4s cubic-bezier(0.15, 0, 0.15, 1);
    background: #fff; /* Varmistetaan että pohja on valkoinen ennen piirtoa */
}

.controls { 
    text-align: center; 
    margin-top: 20px; 
    padding-bottom: 30px;
}

.btn-spin {
    padding: 15px 40px; 
    font-size: 1.5rem; 
    font-weight: bold;
    background: var(--primary); 
    color: white; 
    border: none;
    border-radius: 50px; 
    cursor: pointer; 
    box-shadow: 0 5px 0 #801313;
    transition: all 0.2s;
}

.btn-spin:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #801313;
}

.btn-spin:disabled { 
    background: #666; 
    box-shadow: 0 5px 0 #333; 
    cursor: not-allowed; 
}

#resultText {
    margin-top: 20px; 
    color: #ffd700; /* Kullanvärinen voittoilmoitus */
    min-height: 1.5em;
}
/* --- SLOT-PELIN (KASINO) TYYLIT --- */
.slot-machine {
    background: #444;
    border: 10px solid #222;
    border-radius: 20px;
    padding: 20px;
    display: inline-block;
    box-shadow: 0 0 50px rgba(211, 47, 47, 0.5);
    margin: 20px auto;
}

.slots-container {
    display: flex;
    gap: 10px;
    background: #eee;
    padding: 10px;
    border-radius: 10px;
    border: 5px solid #111;
}

.reel {
    width: 100px;
    height: 100px;
    background: white;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.reel img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

/* Voittoanimaatio rullille */
.reel.winner {
    animation: blink 0.5s infinite alternate;
    border: 3px solid var(--primary);
}

@keyframes blink {
    from { background: white; }
    to { background: #ffcdd2; }
}

.slot-controls {
    margin-top: 20px;
    text-align: center;
}

.balance-display {
    font-size: 1.5rem;
    color: #ffd700;
    margin-bottom: 10px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

.btn-slot {
    padding: 15px 50px;
    font-size: 1.8rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #801313;
}

.btn-slot:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #801313;
}

.btn-slot:disabled {
    background: #666;
    box-shadow: 0 6px 0 #333;
}
/* --- SLOT-PELIN (KASINO) TYYLIT --- */
.slot-machine {
    background: #444;
    border: 10px solid #222;
    border-radius: 20px;
    padding: 20px;
    display: inline-block; /* Pitää koneen keskellä ja oikean kokoisena */
    box-shadow: 0 0 50px rgba(211, 47, 47, 0.5);
    margin: 20px auto;
    text-align: center;
}

.slots-container {
    display: flex; /* TÄMÄ ON KRIITTINEN: Asettaa lapset vierekkäin */
    flex-direction: row; /* Varmistaa, että ne ovat rivissä, ei sarakkeessa */
    justify-content: center; /* Keskittää rullat säiliön sisällä */
    gap: 10px; /* Jättää pienen raon rullien väliin */
    background: #eee;
    padding: 10px;
    border-radius: 10px;
    border: 5px solid #111;
    overflow: hidden; /* Estää symboleita vuotamasta yli */
}

.reel {
    width: 100px; /* Kiinteä koko rullalle */
    height: 100px;
    background: white;
    border-radius: 5px;
    display: flex;
    align-items: center; /* Keskittää symbolin pystysuunnassa */
    justify-content: center; /* Keskittää symbolin vaakasuunnassa */
    overflow: hidden;
    position: relative; /* Tarvitaan animaatioita varten myöhemmin */
}

.reel img {
    width: 80%; /* Symboli vie 80% rullan koosta */
    height: 80%;
    object-fit: contain; /* Varmistaa, että kuva ei veny oudosti */
}
/* --- MUISTIPELIN TYYLIT --- */
.memory-game {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 saraketta */
    gap: 10px;
    max-width: 400px;
    margin: 20px auto;
    padding: 10px;
}

.memory-card {
    aspect-ratio: 1 / 1; /* Tekee korteista neliöitä */
    background-color: var(--primary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    transition: transform 0.3s, background-color 0.3s;
    position: relative;
    box-shadow: var(--shadow);
}

.memory-card.flipped {
    background-color: white;
    transform: rotateY(180deg);
}

.memory-card img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    display: none; /* Piilotettu oletuksena */
}

.memory-card.flipped img {
    display: block; /* Näytetään kun kortti on käännetty */
    transform: rotateY(180deg); /* Korjataan peilikuva */
}

/* Mobiilioptimointi muistipelille */
@media (max-width: 450px) {
    .memory-game {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
    }
}
