/* ============================================================
   pasianssi-tilastot.css
   Tilasto- ja TOP30-dialogien tyylit
   ============================================================ */

/* Lisää nämä olemassa olevien tyylien jatkoksi */
.row { display: flex; width: 100%; margin-bottom: 20px; }

.deck-area, .foundation-area {
    display: flex;
    gap: 1.5vw; /* Skaalautuva väli korttien välillä */
}

/* Pakka-kortin ulkoasu (deck) */
.card-slot.deck {
    background-color: #004488 !important;
    border: 2px solid #fff !important;
    cursor: pointer;
    box-shadow: 0.3vw 0.3vw 0.8vw rgba(0,0,0,0.5);
}

/* Lisätään kuvio pakkaan, jotta se näyttää korttipakan selältä */
.card-back-pattern {
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,0.1) 10px, rgba(255,255,255,0.1) 20px);
    border-radius: 0.8vw;
}

.top-row {
    display: flex;
    justify-content: space-between; /* Pakottaa ryhmät eri laitoihin */
    width: 90vw;                   /* Leveys suhteessa ikkunaan */
    max-width: 1200px;
    margin: 2vh auto 5vh auto;     /* Keskittää koko rivin ja antaa tilaa alas */
    z-index: 1000;
}

/* Ylärivi ja sarakkeet skaalautuvat leveyssuunnassa */
.top-row, .tableau-container {
    display: flex;
    justify-content: center;
    gap: 1.5vw; /* Väli skaalautuu ikkunan mukaan */
    width: 100%;
    max-width: 95vw;
}

.row.top-row {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-bottom: 30px;
            width: 100%;
}

.tableau-row { height: 500px; gap: 15px; }

/* Pelialueen pääsäiliö */
#game-canvas {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2vh 2vw;
    width: 100%;
    height: calc(100vh - 40px); /* Vähennetään yläpalkin korkeus */
    box-sizing: border-box;
}

/* Foundation-kehykset selkeämmäksi */
.foundation {
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    background: rgba(0, 0, 0, 0.2) !important;
}

.foundation::after {
    content: 'A';
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 50px;
    color: rgba(255, 255, 255, 0.15);
    font-weight: bold;
    pointer-events: none;
}

/* KORTIN JA PAIKAN KOKO */
.card-slot, .card {
    width: 11vw;       /* n. 1/9 ikkunan leveydestä */
    max-width: 140px;
    min-width: 70px;
    aspect-ratio: 2/3;
    position: relative;
    border-radius: 0.8vw;
}

/* Kortin erityisasetukset */
.card {
    position: absolute;
    background-color: #ffffff !important;
    border: 1px solid #999;
    box-shadow: 0.3vw 0.3vw 0.8vw rgba(0,0,0,0.4);
    z-index: 10;
}

/* Tekstien koko skaalautuu */
.card-value {
    font-size: 2.0vw; 
    font-weight: bold;
    margin: 0.4vw;
}

.card-suit {
    font-size: 3.5vw;
    text-align: center;
    margin-top: -1vw;
}

/* Sarakkeen pystysuuntainen pinoaminen */
.tableau-column {
    position: relative;
    width: 11vw;
    max-width: 150px;
    min-width: 80px;
}

/* Kortin selusta */
.card.down {
    background-color: #004488 !important;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,0.05) 10px, rgba(255,255,255,0.05) 20px),
        repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(255,255,255,0.05) 10px, rgba(255,255,255,0.05) 20px) !important;
    border: 2px solid #ffffff;
}

.card.down * { display: none; } /* Piilottaa sisällön jos kortti on nurin */

.red { color: #d00; }
.black { color: #333; }

/* Korttien limitys sarakkeessa (käytetään vh-yksikköä tai vw-yksikköä) */
.tableau-column .card:nth-child(n) { 
    top: calc((n - 1) * 3vw); /* Limitys skaalautuu ikkunan mukaan */
}

/* Automaattinen pinontajärjestys sarakkeessa */
.tableau-column .card:nth-child(1) { z-index: 1; top: 0px; }
.tableau-column .card:nth-child(2) { z-index: 2; top: 30px; }
.tableau-column .card:nth-child(3) { z-index: 3; top: 60px; }
.tableau-column .card:nth-child(4) { z-index: 4; top: 90px; }
.tableau-column .card:nth-child(5) { z-index: 5; top: 120px; }
.tableau-column .card:nth-child(6) { z-index: 6; top: 150px; }
.tableau-column .card:nth-child(7) { z-index: 7; top: 180px; }
.tableau-column .card:nth-child(8) { z-index: 8; top: 210px; }
.tableau-column .card:nth-child(9) { z-index: 9; top: 240px; }
.tableau-column .card:nth-child(10) { z-index: 10; top: 270px; }
/* ...jatka tarvittaessa sijoja 20 asti... */

.game-stats-bar {
            margin-left: auto;
            display: flex;
            gap: 25px;
            font-weight: bold;
}


/* ----- Nimimerkki-dialogi ----- */
#nm-dialog .nm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

#nm-dialog .nm-box {
    background: #1a3a1a;
    border: 2px solid #4a7c4a;
    border-radius: 12px;
    padding: 36px 40px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    color: #e8f5e8;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

#nm-dialog .nm-box h2 {
    font-size: 1.6rem;
    margin: 0 0 10px;
    color: #7dbe7d;
    font-family: Georgia, serif;
}

#nm-dialog .nm-box p {
    color: #a0c8a0;
    margin: 0 0 20px;
    font-size: .95rem;
}

#nm-dialog #nm-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1.5px solid #4a7c4a;
    background: #0f2a0f;
    color: #e8f5e8;
    font-size: 1rem;
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s;
}
#nm-dialog #nm-input:focus { border-color: #7dbe7d; }

#nm-dialog .nm-virhe {
    color: #e88080;
    font-size: .85rem;
    min-height: 20px;
    margin: 6px 0;
}

#nm-dialog #nm-ok {
    margin-top: 8px;
    padding: 10px 32px;
    background: #2d6a2d;
    color: #e8f5e8;
    border: 1.5px solid #4a7c4a;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background .2s;
}
#nm-dialog #nm-ok:hover { background: #3d8a3d; }

/* ----- Yleiset dialogit (tilastot + TOP30) ----- */
.ps-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    backdrop-filter: blur(2px);
}

.ps-dialog {
    background: #1a3a1a;
    border: 2px solid #4a7c4a;
    border-radius: 12px;
    width: min(680px, 95vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.7);
    overflow: hidden;
}

.ps-dialog-otsikko {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #0f2a0f;
    border-bottom: 1px solid #3a6a3a;
    font-family: Georgia, serif;
    font-size: 1.2rem;
    color: #7dbe7d;
}

.ps-sulje {
    background: transparent;
    border: none;
    color: #a0c8a0;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color .15s;
}
.ps-sulje:hover { color: #e88080; }

.ps-dialog-sisalto {
    overflow-y: auto;
    padding: 16px 20px 20px;
    color: #e8f5e8;
}

/* ----- Taulukot ----- */
.taulukko {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.taulukko th {
    background: #0f2a0f;
    color: #7dbe7d;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #3a6a3a;
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.taulukko td {
    padding: 8px 12px;
    border-bottom: 1px solid #2a4a2a;
    color: #d0e8d0;
}

.taulukko tr:last-child td { border-bottom: none; }
.taulukko tr:hover td { background: rgba(125,190,125,.07); }

/* TOP30 */
.top-taulukko td.sija {
    font-size: 1.1rem;
    text-align: center;
    width: 40px;
}

.oma-rivi td {
    background: rgba(125, 190, 125, .12) !important;
    color: #a8e8a8 !important;
    font-weight: 600;
}

/* ----- TOP 30 tabs ----- */
.top-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.top-tab {
    padding: 6px 16px;
    background: #0f2a0f;
    border: 1.5px solid #3a6a3a;
    color: #a0c8a0;
    border-radius: 20px;
    font-size: .85rem;
    cursor: pointer;
    transition: all .15s;
}

.top-tab:hover { border-color: #7dbe7d; color: #e8f5e8; }

.top-tab.aktiivinen {
    background: #2d6a2d;
    border-color: #7dbe7d;
    color: #e8f5e8;
    font-weight: 600;
}

/* ----- Scrollbar (Webkit) ----- */
.ps-dialog-sisalto::-webkit-scrollbar { width: 6px; }
.ps-dialog-sisalto::-webkit-scrollbar-track { background: #0f2a0f; }
.ps-dialog-sisalto::-webkit-scrollbar-thumb { background: #3a6a3a; border-radius: 3px; }

