/* ==========================================================================
 AI:ta käytetty nopeuttamaan CSS tiedoston ja ulkoasun tekemisesssä.
    ==========================================================================
    MODERNISOITU POHJA & TYPOGRAFIA
   ========================================================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 40px auto;
    max-width: 1200px;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

.box {
    background: #ffffff;
    padding: 25px;
    margin-bottom: 25px;
    border-radius: 12px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.box:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

pre {
    background: #1e1e1e;
    color: #76c7c0;
    padding: 12px;
    border-radius: 6px;
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: 13px;
}

/* Oikeuksien hallinnan piilotukset */
.admin-only, .user-only, .logged-in { display: none; }
.logged-out { display: block; }

/* ==========================================================================
    TAULUKOT & LOMAKKEET (Hall of Fame & Käyttäjät)
   ========================================================================== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eef2f5;
}

th {
    background: #eef2f5;
    color: #495057;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

/* Lomakkeiden syötekentät */
.form-inline {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.form-inline input, 
.form-inline select {
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-inline input:focus, 
.form-inline select:focus {
    border-color: #007bff;
}

/* ==========================================================================
    PREMIUM PAINIKKEET (Pehmeät hoverit ja klikkaus-efektit)
   ========================================================================== */
button, .btn {
    cursor: pointer;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:active, .btn:active {
    transform: scale(0.97);
}

.btn-success { background: #2ecc71; color: white; }
.btn-success:hover { background: #27ae60; box-shadow: 0 4px 10px rgba(46,204,113,0.3); }

.btn-primary { background: #3498db; color: white; }
.btn-primary:hover { background: #2980b9; box-shadow: 0 4px 10px rgba(52,152,219,0.3); }

.btn-edit { background: #f39c12; color: white; }
.btn-edit:hover { background: #d35400; }

.btn-del { background: #e74c3c; color: white; }
.btn-del:hover { background: #c0392b; box-shadow: 0 4px 10px rgba(231,76,60,0.3); }

.btn-logout { background: #95a5a6; color: white; }
.btn-logout:hover { background: #7f8c8d; }

/* ==========================================================================
    REAKTIOHASTE-PELI 
   ========================================================================== */
#game-container {
    max-width: 650px;
    margin: 30px auto;
    padding: 30px;
    border-radius: 16px;
    background: #ffffff;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.game-instructions {
    background: #f4f6ff;
    border-left: 5px solid #3498db;
    padding: 15px;
    border-radius: 0 8px 8px 0;
    margin: 20px 0;
    text-align: left;
    font-size: 15px;
}

/* Peliajan ja pisteiden HUD-palkki */
.game-hud {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 16px;
    background: #1e272e;
    color: #fff;
    padding: 12px;
    border-radius: 10px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.game-hud span {
    color: #00d8d6;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 20px;
}

/* Tumma pelialue */
#game-area {
    width: 100%;
    height: 380px;
    background: #0f172a; 
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: crosshair;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.6), 0 4px 10px rgba(0,0,0,0.1);
}

/* Syntyvien pallojen animaatio (ilmestyy pehmeästi ja suurenee) */
#game-area div {
    animation: spawnPop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: transform 0.1s ease;
}

#game-area div:active {
    transform: scale(0.8);
}

@keyframes spawnPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-over-title {
    font-size: 32px;
    color: #e74c3c;
    margin-bottom: 10px;
    font-weight: bold;
}

.game-final-score {
    font-size: 26px;
    margin: 20px 0;
    color: #2c3e50;
}

.game-actions {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
}

.back-link {
    color: #7f8c8d;
    text-decoration: none;
    font-weight: 600;
}
.back-link:hover {
    color: #34495e;
    text-decoration: underline;
}

/* ==========================================================================
   HALL OF FAME SIJOITUKSET
   ========================================================================== */
#leaderboard-container table {
    border-collapse: separate;
    border-spacing: 0 4px; /* Ohut korttimainen rako rivien välillä */
    background: transparent;
    width: 100%;
}

#leaderboard-container th {
    color: #8fa0dd; 
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 15px;
}

#leaderboard-container tbody tr {
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#leaderboard-container tbody tr:hover {
    cursor: pointer;
    transform: translateY(-1px);
}

.rank-1 {
    background-color: #23272a !important; 
    color: #ffffff !important;
}
.rank-1 td {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
/* Hoverissa hieman vaaleampi tummanharmaa */
.rank-1:hover {
    background-color: #2e3337 !important;
}


.rank-2 {
    background-color: #1a2436 !important; 
    color: #ffffff !important;
}
.rank-2 td {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
/* Hoverissa hieman vaaleampi tummansininen */
.rank-2:hover {
    background-color: #243147 !important;
}

.rank-3 {
    background-color: #21192e !important; 
    color: #ffffff !important;
}
.rank-3 td {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.rank-3:hover {
    background-color: #2d223f !important;
}


/* --- SIJAT 4+ (TAVALLISET RIVIT LAATIKON SISÄLLÄ) --- */
#leaderboard-container tbody tr:not(.rank-1):not(.rank-2):not(.rank-3) {
    background-color: transparent;
    color: #565b61; 
}
#leaderboard-container tbody tr:not(.rank-1):not(.rank-2):not(.rank-3) td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
#leaderboard-container tbody tr:not(.rank-1):not(.rank-2):not(.rank-3):hover {
    background-color: rgba(255, 255, 255, 0.07) !important;
}


/* --- SOLUJEN REUNAT JA ASENTELU --- */
#leaderboard-container td {
    padding: 14px 15px;
    vertical-align: middle;
}

#leaderboard-container td:first-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
    text-align: center;
    width: 60px;
}

#leaderboard-container td:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

#leaderboard-container td:nth-child(3) {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 600;
}

#leaderboard-container td:nth-child(4) {
    color: #64748b; /* Päivämäärä vähän himmeämpänä */
}
/*END USE AI*/