/* ============================================================
   Solvoo — stylesheet pubblico
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@500;700&family=Nunito+Sans:wght@400;600;700;800&family=Press+Start+2P&display=swap');

:root {
    --ink: #1F2A38;
    --brand: #E6007A;
    --brand-light: #FF3D9A;
    --indigo: #2A2A72;
    --indigo-light: #4B3FA0;
    --orange: #FF8A3D;
    --orange-light: #FFB067;
    --purple: #7C5CFF;
    --pink: #FF5C8A;
    --yellow: #FFC400;
    --bg: #8AD5F2;
    --card-bg: #FFFFFF;
    --border: #B9DEF5;
    --shadow: 0 10px 25px rgba(14, 92, 168, 0.20);
    color-scheme: light only;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Nunito Sans', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .logo-text {
    font-family: 'Comfortaa', 'Nunito Sans', sans-serif;
    font-weight: 700;
    line-height: 1.25;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Header ---------- */

.site-header {
    background: var(--bg);
    box-shadow: 0 2px 10px rgba(9, 60, 90, 0.15);
    position: sticky;
    top: 0;
    z-index: 50;
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    max-width: 1100px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand img {
    height: 48px;
    width: auto;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 26px;
}

.main-nav a {
    color: #0B5A8A;
    font-weight: 700;
    font-family: 'Comfortaa', sans-serif;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.main-nav a:hover {
    color: var(--brand);
    text-decoration: none;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 3px;
    background: #0B5A8A;
    margin: 5px 0;
    border-radius: 3px;
}

/* ---------- Breadcrumbs ---------- */

.breadcrumbs {
    font-size: 13px;
    color: #8A8577;
    padding: 14px 0 0;
}

.breadcrumbs a {
    color: #0B5A8A;
}

.breadcrumbs a:hover {
    color: var(--brand);
}

.breadcrumbs .sep {
    margin: 0 6px;
    color: #0B5A8A;
}

.breadcrumbs .current {
    color: #0B5A8A;
    font-weight: 700;
}

/* ---------- Hero ---------- */

.hero {
    text-align: center;
    padding: 64px 20px 48px;
    background:
        radial-gradient(circle at 15% 20%, rgba(255, 196, 0, 0.25), transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(42, 42, 114, 0.16), transparent 40%),
        radial-gradient(circle at 50% 90%, rgba(230, 0, 122, 0.14), transparent 45%);
}

.hero h1 {
    font-size: 42px;
    margin: 0 0 14px;
    color: var(--brand);
}

.hero p {
    font-size: 18px;
    color: #3D4C5C;
    max-width: 560px;
    margin: 0 auto;
}

/* ---------- Category pills ---------- */

.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin: 28px 0 0;
}

.category-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 700;
    font-family: 'Comfortaa', sans-serif;
    font-size: 14px;
    color: #fff;
    box-shadow: var(--shadow);
}

.category-pill.cat-arcade { background: linear-gradient(135deg, var(--orange), var(--pink)); }
.category-pill.cat-puzzle { background: linear-gradient(135deg, var(--purple), #5B7FFF); }
.category-pill.cat-cards  { background: linear-gradient(135deg, var(--indigo), var(--indigo-light)); }
.category-pill.active { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- Section titles ---------- */

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 48px 0 20px;
}

.section-title h2 {
    font-size: 24px;
    margin: 0;
    color: var(--ink);
}

.section-title a {
    font-weight: 700;
    font-size: 14px;
}

/* ---------- Game grid & cards ---------- */

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 22px;
    padding-bottom: 40px;
}

.game-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px rgba(31, 109, 69, 0.14);
    text-decoration: none;
}

.game-card-thumb {
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, var(--yellow), var(--orange-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    color: #fff;
    position: relative;
}

.game-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.game-card-body {
    padding: 16px 16px 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.game-card-body h3 {
    margin: 0 0 6px;
    font-size: 17px;
    color: var(--ink);
}

.game-card-body p {
    margin: 0;
    font-size: 14px;
    color: #6B6659;
    flex: 1;
}

.game-card-play {
    margin-top: 12px;
    font-family: 'Comfortaa', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--brand);
}

/* ---------- Game play page ---------- */

.play-wrap {
    padding: 30px 0 60px;
}

.play-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.play-header h1 {
    margin: 0;
    font-size: 30px;
    color: var(--ink);
}

.play-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.1s ease;
}

.btn-icon:hover {
    transform: scale(1.06);
}

.btn-icon[hidden] {
    display: none;
}

.play-stage {
    background: linear-gradient(160deg, #223257, #0F1730);
    border-radius: 22px;
    padding: 24px;
    display: flex;
    justify-content: center;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
    position: relative;
}

.play-stage canvas {
    max-width: min(100%, 560px);
    border-radius: 12px;
    background: #0B1622;
    touch-action: none;
}

/* ---------- Fullscreen play stage ---------- */

.play-stage:fullscreen,
.play-stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    align-items: center;
}

.play-stage.is-fullscreen {
    background: #0B1622;
}

.play-stage:fullscreen canvas,
.play-stage:-webkit-full-screen canvas {
    max-width: 96vw;
    max-height: 92vh;
    width: auto;
    height: auto;
}

.play-stage:fullscreen .start-panel,
.play-stage:fullscreen .game-over-panel,
.play-stage:-webkit-full-screen .start-panel,
.play-stage:-webkit-full-screen .game-over-panel {
    inset: 0;
    border-radius: 0;
}

.fullscreen-exit-btn {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 5;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: rgba(11, 22, 34, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: #E7EEF5;
    cursor: pointer;
}

.play-stage.is-fullscreen .fullscreen-exit-btn:not([hidden]) {
    display: flex;
}

/* ---------- Game-over overlay ---------- */

.game-over-panel {
    position: absolute;
    inset: 24px;
    border-radius: 12px;
    background: rgba(11, 22, 34, 0.82);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.game-over-panel:not([hidden]) {
    display: flex;
}

.game-over-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 26px 28px;
    width: 260px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.game-over-card h3 {
    margin: 0 0 6px;
    font-family: 'Comfortaa', sans-serif;
    color: var(--brand);
    font-size: 20px;
}

.game-over-card p {
    margin: 0 0 14px;
    color: var(--ink);
}

.game-over-card form label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #6B6659;
    text-align: left;
    margin-bottom: 6px;
}

.game-over-card input[type="text"] {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    font-family: inherit;
}

.game-over-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-secondary-inline {
    background: #EFEBDE;
    color: var(--ink);
    border: none;
    padding: 10px 18px;
    border-radius: 999px;
    font-family: 'Comfortaa', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

.game-over-hint {
    min-height: 16px;
    font-size: 12px;
    color: #6B6659;
    margin: 10px 0 0;
}

/* ---------- Start overlay (retro arcade "HIT TO START") ---------- */

.start-panel {
    position: absolute;
    inset: 24px;
    border-radius: 12px;
    background: rgba(6, 12, 20, 0.86);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 500;
}

.start-panel:not([hidden]) {
    display: flex;
}

.start-card {
    text-align: center;
    padding: 20px;
    background: none;
    box-shadow: none;
}

.start-card h3 {
    margin: 0 0 22px;
    font-family: 'Press Start 2P', 'Comfortaa', monospace;
    color: #fff;
    font-size: 15px;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
}

.start-card p {
    margin: 0;
    display: inline-block;
}

.btn-play {
    font-family: 'Press Start 2P', 'Comfortaa', monospace;
    background: none;
    border: none;
    color: var(--yellow);
    font-size: 18px;
    letter-spacing: 3px;
    padding: 10px 14px;
    cursor: pointer;
    text-shadow: 0 0 6px rgba(255, 196, 0, 0.7), 0 0 16px rgba(255, 196, 0, 0.35);
    animation: retro-blink 1s steps(1, end) infinite;
}

@keyframes retro-blink {
    0%, 55% { opacity: 1; }
    56%, 100% { opacity: 0; }
}

.play-score {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: -14px;
    margin-bottom: 28px;
    font-family: 'Comfortaa', sans-serif;
    color: var(--ink);
}

.play-score span {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: var(--shadow);
}

/* A pill-shaped action button that sits next to the Score/Best pills
   (e.g. "Finish game now" / "End run & save score") — matches their
   shape but reads as clickable, not a stat. Shared across any game that
   lets the player end their own session early. */
.play-finish-pill {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-family: 'Comfortaa', sans-serif;
    cursor: pointer;
    opacity: 0.75;
}

.play-finish-pill:hover:not(:disabled) {
    opacity: 1;
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.play-info {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.play-info-3col {
    grid-template-columns: 1.3fr 1fr 1fr;
}

.leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: lb;
}

.leaderboard-list li {
    counter-increment: lb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.leaderboard-list li:last-child {
    border-bottom: none;
}

.leaderboard-list li::before {
    content: counter(lb) '.';
    color: #6B6659;
    font-weight: 700;
    margin-right: 8px;
    width: 18px;
    flex-shrink: 0;
}

.lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    font-weight: 700;
    color: var(--brand);
    font-family: 'Comfortaa', sans-serif;
}

.leaderboard-empty {
    color: #6B6659;
    font-size: 13px;
}
.leaderboard-empty::before {
    content: '' !important;
    margin: 0 !important;
}

.play-info-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
}

.play-info-card h2 {
    margin-top: 0;
    font-size: 18px;
}

.play-info-card p {
    color: #565149;
    line-height: 1.6;
}

.btn-restart {
    font-family: 'Comfortaa', sans-serif;
    font-weight: 700;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
}

.btn-restart:hover {
    background: var(--brand-light);
}

/* ---------- Footer ---------- */

.site-footer {
    background: var(--brand);
    color: #C9CFC9;
    margin-top: 60px;
    padding: 36px 0;
    text-align: center;
    font-size: 13px;
}

.site-footer a {
    color: #EAF3EC;
}

/* ---------- Responsive ---------- */

@media (max-width: 899px) {
    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 20px 20px;
        gap: 16px;
    }

    .main-nav a {
        color: var(--ink);
        text-shadow: none;
    }

    .main-nav a:hover {
        color: var(--brand);
    }

    .main-nav.open {
        display: flex;
    }

    .hamburger {
        display: block;
    }

    .play-info {
        grid-template-columns: 1fr;
    }

    .game-over-panel,
    .start-panel {
        inset: 10px;
    }
}

@media (max-width: 560px) {
    .hero h1 {
        font-size: 30px;
    }

    .hero p {
        font-size: 15px;
    }

    .play-stage {
        padding: 14px;
    }
}
