/* ==========================================================================
   WP Highscore — Kiosk View
   Optimized for 4K TV (75") full-screen display
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    background: #080810;
    color: #e0e0e0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* Base: tiled dot matrix pattern — rendered as HTML element from PHP */
.kiosk-bg-pattern {
    position: fixed;
    inset: 0;
    background-repeat: repeat;
    background-position: center center;
    background-size: 600px auto;
    opacity: 0.28;
    z-index: 0;
    pointer-events: none;
}

/* Overlay: colored gradient on top of pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 15% 100%, rgba(120, 40, 200, 0.2) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 85% 0%, rgba(200, 60, 20, 0.15) 0%, transparent 70%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(243, 156, 18, 0.06) 0%, transparent 60%);
    z-index: 1;
    animation: bg-drift 20s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes bg-drift {
    0% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.05); }
}

.kiosk-container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1vh 1.2vw;
    gap: 1vh;
}

/* ── Header ── */

.kiosk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1vh 2vw;
    background: linear-gradient(135deg, rgba(20, 15, 40, 0.9) 0%, rgba(15, 20, 45, 0.9) 100%);
    border-radius: 0.8vh;
    border: 1px solid rgba(200, 40, 40, 0.15);
    border-bottom: 2px solid rgba(200, 40, 40, 0.3);
    flex-shrink: 0;
}

.kiosk-logo {
    height: 4vh;
    width: auto;
    max-width: 12vw;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(243, 156, 18, 0.2));
}

.kiosk-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 2.2vh;
    letter-spacing: 0.5vw;
    background: linear-gradient(90deg, #e74c3c, #f39c12, #e74c3c);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: title-shimmer 6s ease-in-out infinite;
    text-shadow: none;
}

@keyframes title-shimmer {
    0%, 100% { background-position: 0% center; }
    50% { background-position: 200% center; }
}

.kiosk-clock {
    font-size: 2.5vh;
    font-weight: 600;
    color: #fff;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.15vw;
}

/* ── Section cards ── */

.kiosk-section {
    background: rgba(14, 12, 24, 0.69);
    border: 1px solid rgba(200, 40, 40, 0.1);
    border-radius: 0.8vh;
    padding: 1.2vh 1.5vw;
}

.kiosk-section h2 {
    font-size: 1.3vh;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3vw;
    color: #e74c3c;
    margin-bottom: 1vh;
    padding-bottom: 0.6vh;
    border-bottom: 1px solid rgba(231, 76, 60, 0.2);
}

.kiosk-empty {
    color: #444;
    font-style: italic;
    font-size: 1.6vh;
}

/* ── Main layout ── */

.kiosk-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1vw;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.kiosk-col {
    display: flex;
    flex-direction: column;
    gap: 1vh;
    min-height: 0;
}

.kiosk-col-left .kiosk-recent {
    flex: 1;
}

.kiosk-col-left .kiosk-gotm {
    flex: 1;
}

.kiosk-col-right {
    overflow-y: auto;
    scrollbar-width: none;
}
.kiosk-col-right::-webkit-scrollbar { display: none; }

/* ── Tables ── */

.kiosk-table {
    width: 100%;
    border-collapse: collapse;
}

.kiosk-table tr {
    border-bottom: 1px solid rgba(200, 40, 40, 0.06);
}
.kiosk-table tr:last-child { border-bottom: none; }

/* ── New score entry animation ── */

.kiosk-recent tr:first-child {
    animation: new-score-in 1.5s ease-out;
}

@keyframes new-score-in {
    0% {
        background: rgba(231, 76, 60, 0.4);
        transform: translateX(-1vw);
        opacity: 0;
    }
    10% {
        transform: translateX(0.3vw);
        opacity: 1;
    }
    15% {
        background: rgba(243, 156, 18, 0.3);
        transform: translateX(-0.15vw);
    }
    20% {
        transform: translateX(0.08vw);
    }
    25% {
        transform: translateX(0);
        background: rgba(243, 156, 18, 0.15);
    }
    100% {
        background: transparent;
        transform: translateX(0);
    }
}

/* Screen flash on reload */
.kiosk-flash {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(231, 76, 60, 0.2), transparent 70%);
    z-index: 50;
    pointer-events: none;
    animation: screen-flash 1s ease-out forwards;
}

@keyframes screen-flash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.kiosk-table td {
    padding: 1vh 0.4vw;
}

.k-rank {
    width: 2vw;
    font-weight: 700;
    font-size: 2vh;
    color: #666;
}

.k-nick {
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.15vw;
    font-size: 2.2vh;
}

.k-score {
    text-align: right;
    font-weight: 700;
    color: #f39c12;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 1.8vh;
    white-space: nowrap;
}

.k-game {
    color: #777;
    font-size: 1.6vh;
    padding-left: 0.8vw;
}

.k-date {
    color: #555;
    font-size: 1.4vh;
    text-align: right;
    white-space: nowrap;
}

/* ── Game of the Month ── */

.gotm-game-name {
    font-size: 2.8vh;
    font-weight: 800;
    color: #fff;
    margin-bottom: 1.2vh;
    text-align: center;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.08);
}

.kiosk-table-gotm tr.rank-1 .k-nick { font-size: 3vh; color: #f1c40f; }
.kiosk-table-gotm tr.rank-1 .k-score { font-size: 2.4vh; color: #f1c40f; text-shadow: 0 0 10px rgba(241, 196, 15, 0.3); }
.kiosk-table-gotm tr.rank-1 .k-rank { color: #f1c40f; font-size: 3vh; }

.kiosk-table-gotm tr.rank-2 .k-nick,
.kiosk-table-gotm tr.rank-2 .k-score { font-size: 2.4vh; color: #bdc3c7; }
.kiosk-table-gotm tr.rank-2 .k-rank { color: #bdc3c7; }

.kiosk-table-gotm tr.rank-3 .k-nick,
.kiosk-table-gotm tr.rank-3 .k-score { font-size: 2.2vh; color: #cd7f32; }
.kiosk-table-gotm tr.rank-3 .k-rank { color: #cd7f32; }

/* ── Player of the Month (horizontal sliding carousel) ── */

.kiosk-potm {
    flex-shrink: 0;
}

.potm-carousel {
    overflow: hidden;
}

.potm-track {
    display: flex;
    gap: 0.8vw;
    transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.potm-card {
    flex: 0 0 calc(20% - 0.64vw);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.6vh;
    padding: 1.2vh 1vw;
    text-align: center;
}

.potm-nickname {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 2.8vh;
    color: #f1c40f;
    text-shadow: 0 0 14px rgba(241, 196, 15, 0.3);
    margin-bottom: 0.4vh;
}

.potm-score {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 1.8vh;
    color: #f39c12;
    margin-bottom: 0.4vh;
}

.potm-month-label {
    font-size: 1.5vh;
    font-weight: 600;
    color: #bbb;
    margin-bottom: 0.2vh;
}

.potm-game {
    font-size: 1.2vh;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Attract mode: kuukauden pelaajat placeholder ── */

.potm-attract {
    text-align: center;
    padding: 1.5vh 0;
}

.potm-attract-text {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 1.6vh;
    line-height: 1.8;
    color: #f39c12;
    text-shadow: 0 0 12px rgba(243, 156, 18, 0.3);
    margin-bottom: 0.8vh;
    animation: attract-pulse 3s ease-in-out infinite;
}

.potm-attract-sub {
    font-size: 1.3vh;
    color: #666;
}

@keyframes attract-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* ── Attract mode: kuukauden peli empty ── */

.gotm-start-date {
    text-align: center;
    font-size: 1.2vh;
    color: #666;
    margin-bottom: 1vh;
}

.gotm-attract {
    text-align: center;
    padding: 2vh 0;
}

.gotm-attract-text {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 2.2vh;
    color: #f1c40f;
    text-shadow: 0 0 16px rgba(241, 196, 15, 0.4);
    margin-bottom: 1vh;
    animation: attract-pulse 3s ease-in-out infinite;
}

.gotm-attract-sub {
    font-size: 1.4vh;
    color: #999;
    max-width: 80%;
    margin: 0 auto;
    line-height: 1.5;
}

/* ── Ennätykset (right column, compact rows) ── */

.kiosk-all-machines {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.kiosk-machine-grid {
    display: flex;
    flex-direction: column;
    gap: 0.4vh;
    flex: 1;
}

.machine-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(200, 40, 40, 0.08);
    border-radius: 0.4vh;
    padding: 0.8vh 0.8vw;
    display: grid;
    grid-template-columns: 1fr 3.5vw 12vw;
    align-items: center;
    gap: 0.5vw;
}

.mc-game {
    font-size: 1.5vh;
    font-weight: 600;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mc-nick {
    font-size: 1.7vh;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.12vw;
    text-align: center;
}

.mc-score {
    font-size: 1.4vh;
    font-weight: 700;
    color: #f39c12;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    text-align: right;
    white-space: nowrap;
}

/* ── Debug panel ── */

.kiosk-debug {
    position: fixed;
    bottom: 1vh;
    left: 1vw;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.6vh;
    font-size: 1.1vh;
    color: #666;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.8vh 1vw;
    border-radius: 0.5vh;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s;
}

.kiosk-debug.visible {
    opacity: 1;
}

.kiosk-debug-row {
    display: flex;
    gap: 0.4vw;
    align-items: center;
}

.kiosk-debug label {
    min-width: 3vw;
    color: #888;
}

.kiosk-debug a {
    color: #888;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.08);
    padding: 0.2vh 0.5vw;
    border-radius: 0.3vh;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1vh;
}

.kiosk-debug a.active {
    color: #f39c12;
    border-color: #f39c12;
}

.kiosk-debug input[type="range"] {
    width: 8vw;
    accent-color: #f39c12;
    height: 1.2vh;
}

.kiosk-debug .val {
    min-width: 2vw;
    text-align: right;
    color: #f39c12;
    font-size: 1vh;
}

/* ==========================================================================
   Mobile: stack everything vertically, allow scrolling
   ========================================================================== */

@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }

    .kiosk-container {
        height: auto;
        min-height: 100vh;
        padding: 8px;
        gap: 8px;
    }

    /* Header */
    .kiosk-header {
        padding: 8px 12px;
    }
    .kiosk-logo {
        height: 24px;
    }
    .kiosk-title {
        font-size: 12px;
        letter-spacing: 2px;
    }
    .kiosk-clock {
        font-size: 14px;
    }

    /* Stack columns */
    .kiosk-main {
        grid-template-columns: 1fr;
        flex: none;
        overflow: visible;
    }

    .kiosk-col {
        min-height: auto;
    }
    .kiosk-col-right {
        overflow-y: visible;
    }

    /* Sections */
    .kiosk-section {
        padding: 10px 12px;
    }
    .kiosk-section h2 {
        font-size: 10px;
        letter-spacing: 2px;
        margin-bottom: 8px;
    }

    /* Tables */
    .kiosk-table td {
        padding: 6px 4px;
        font-size: 13px;
    }
    .k-nick {
        font-size: 14px;
    }
    .k-score {
        font-size: 10px;
    }
    .k-game {
        font-size: 11px;
        padding-left: 6px;
    }
    .k-date {
        font-size: 10px;
    }

    /* Game of the month */
    .gotm-game-name {
        font-size: 16px;
    }
    .kiosk-table-gotm tr.rank-1 .k-nick { font-size: 18px; }
    .kiosk-table-gotm tr.rank-1 .k-score { font-size: 14px; }
    .kiosk-table-gotm tr.rank-1 .k-rank { font-size: 18px; }

    /* Ennätykset */
    .machine-card {
        grid-template-columns: 1fr auto auto;
        gap: 6px;
        padding: 6px 8px;
    }
    .mc-game { font-size: 11px; }
    .mc-nick { font-size: 12px; }
    .mc-score { font-size: 9px; }

    /* Player of the month carousel */
    .potm-track {
        gap: 6px;
    }
    .potm-card {
        flex: 0 0 calc(50% - 3px);
        padding: 10px;
    }
    .potm-nickname {
        font-size: 16px;
    }
    .potm-score {
        font-size: 11px;
    }
    .potm-month-label {
        font-size: 11px;
    }
    .potm-game {
        font-size: 9px;
    }

    /* Attract mode */
    .potm-attract-text {
        font-size: 12px;
    }
    .gotm-attract-text {
        font-size: 14px;
    }
    .gotm-attract-sub {
        font-size: 12px;
    }

    /* Hide debug panel on mobile */
    .kiosk-debug {
        display: none;
    }

    /* Background */
    .kiosk-bg-pattern {
        background-size: 300px auto;
    }
}
