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

:root {
    --bg-primary: #033b47;
    --bg-secondary: #022d36;
    --bg-card: #2a475e;
    --bg-card-hover: #3e5a6d;
    --text-primary: #c7d5e0;
    --text-secondary: #8f98a0;
    --accent-blue: #1a9fff;
    --border-color: #3d4f5c;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
}

#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
}

#bgOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    background: rgba(23, 26, 33, 0);
}

@media (prefers-reduced-motion: reduce) {
    #bgCanvas {
        display: none;
    }

    #bgOverlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(23, 26, 33, 0.7);
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 0;
}

header {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Page Navigation */
.page-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

.nav-link {
    padding: 8px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95em;
    border-radius: 5px 5px 0 0;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(26, 159, 255, 0.1);
}

.nav-link.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: rgba(26, 159, 255, 0.1);
}

.nav-link.highlight:not(.active) {
    border: 2px solid rgba(255, 80, 80, 0.6);
    animation: nav-glow 2s ease-in-out infinite;
}

@keyframes nav-glow {

    0%,
    100% {
        border-color: rgba(255, 80, 80, 0.35);
        box-shadow: 0 0 6px rgba(255, 80, 80, 0.2);
    }

    50% {
        border-color: rgba(255, 80, 80, 0.85);
        box-shadow: 0 0 14px rgba(255, 80, 80, 0.45);
    }
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

h1 {
    color: var(--accent-blue);
    margin: 0;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    flex-shrink: 1;
    min-width: 0;
}

.last-update {
    color: var(--text-secondary);
    font-size: 0.85em;
}

.discord-links {
    display: flex;
    gap: 10px;
}

.discord-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #5865F2;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(88, 101, 242, 0.3);
}

.discord-button:hover {
    background: #4752C4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.5);
}

.discord-button.after-dark {
    background: #9333EA;
    box-shadow: 0 2px 8px rgba(147, 51, 234, 0.3);
    transition: all 0.3s ease;
}

.discord-button.after-dark:hover {
    background: #7E22CE;
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.5);
}

.discord-button.after-dark.hidden {
    display: none;
}

.discord-button.github-button {
    background: #24292e;
    box-shadow: 0 2px 8px rgba(36, 41, 46, 0.3);
}

.discord-button.github-button:hover {
    background: #1a1e22;
    box-shadow: 0 4px 12px rgba(36, 41, 46, 0.5);
}

.discord-button.spreadsheet-button {
    background: #0f9d58;
    box-shadow: 0 2px 8px rgba(15, 157, 88, 0.3);
}

.discord-button.spreadsheet-button:hover {
    background: #0b8043;
    box-shadow: 0 4px 12px rgba(15, 157, 88, 0.5);
}

.bg-toggle {
    position: fixed;
    bottom: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(42, 71, 94, 0.6);
    border: 1px solid rgba(61, 79, 92, 0.6);
    color: rgba(143, 152, 160, 0.6);
    font-size: 0.6em;
    font-weight: 700;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s ease;
    user-select: none;
}

.bg-toggle.active {
    box-shadow: 0 0 8px 3px rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

.bg-toggle:hover {
    background: rgba(42, 71, 94, 0.9);
    color: rgba(199, 213, 224, 0.8);
    border-color: rgba(61, 79, 92, 0.9);
}

.bg-toggle.off {
    opacity: 0.4;
    box-shadow: none;
}

.secret-container {
    text-align: center;
    padding: 30px 0 10px;
}

.secret-button {
    font-size: 0.55em;
    color: rgba(143, 152, 160, 0.15);
    text-decoration: none;
    transition: color 0.3s ease;
    cursor: default;
}

.secret-button:hover {
    color: rgba(143, 152, 160, 0.4);
    cursor: pointer;
}

.egg-spawn-btn {
    margin-left: 20px;
    font-size: 0.7em !important;
    color: rgba(143, 152, 160, 0.5) !important;
}

.discord-icon {
    width: 20px;
    height: 20px;
}

.adult-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(147, 51, 234, 0.1);
    border: 1px solid rgba(147, 51, 234, 0.3);
    border-radius: 5px;
}

.toggle-label {
    color: var(--text-primary);
    font-size: 0.9em;
    font-weight: 500;
    user-select: none;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2a475e;
    transition: 0.3s;
    border-radius: 26px;
    border: 2px solid #3d4f5c;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: #9333EA;
    border-color: #7E22CE;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(24px);
    background-color: white;
}

.toggle-switch input:focus+.toggle-slider {
    box-shadow: 0 0 1px #9333EA;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

#csvFileInput {
    display: none;
}

.file-label {
    padding: 10px 20px;
    background: var(--accent-blue);
    color: white;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
}

.file-label:hover {
    background: #1589e8;
}

#searchInput,
#dateFilter,
#sortSelect {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-primary);
    font-size: 14px;
}

#dateFilter,
#sortSelect {
    max-width: 200px;
    cursor: pointer;
}

#searchInput::placeholder {
    color: var(--text-secondary);
}

#searchInput:focus,
#dateFilter:focus,
#sortSelect:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.stats {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    background: var(--bg-card);
    border-radius: 3px;
    font-weight: 600;
}

/* Online Counter */
.online-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 20px;
    font-weight: 500;
}

.online-dot {
    width: 10px;
    height: 10px;
    background: #4caf50;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

#onlineCount {
    color: #4caf50;
    font-weight: 600;
    font-size: 1.1em;
    min-width: 20px;
    text-align: center;
}

.online-label {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.loading-message,
.error-message {
    text-align: center;
    padding: 40px;
    font-size: 1.2em;
    color: var(--text-secondary);
}

.error-message {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid #ff6b6b;
    border-radius: 5px;
    margin-bottom: 20px;
}

.legend {
    background: var(--bg-card);
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.legend-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 0.95em;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-box {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    border: 3px solid;
    background: var(--bg-secondary);
}

.legend-item span {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 40px;
    background: var(--bg-card);
    border-radius: 5px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), #1589e8);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 10px;
}

.game-card {
    background: var(--bg-card);
    border-radius: 5px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    border: 3px solid transparent;
}

.new-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 3px 12px rgba(255, 107, 107, 0.6);
    }
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    background: var(--bg-card-hover);
}

/* Status border colors */
.game-card.border-black {
    border-color: #333333;
}

.game-card.border-green {
    border-color: #4caf50;
}

.game-card.border-yellow {
    border-color: #ffc107;
}

.game-card.border-red {
    border-color: #f44336;
}

.game-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: linear-gradient(135deg, #2a475e 0%, #1b2838 100%);
    display: block;
}

.game-cover.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.game-cover.error {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
    text-align: center;
}

.game-cover.error::before {
    content: "🎮";
    font-size: 3em;
    margin-bottom: 10px;
    opacity: 0.5;
}

.game-info {
    padding: 15px;
}

.game-title {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-meta {
    font-size: 0.85em;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.game-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 500;
}

/* Status badge colors - default green */
.game-status {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Status badge colors based on status text */
.game-status[data-status*="unstable"] {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.game-status[data-status*="broken"] {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.game-status[data-status*="apworld only"] {
    background: rgba(51, 51, 51, 0.2);
    color: #999;
    border: 1px solid rgba(51, 51, 51, 0.3);
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Game Detail Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    overflow-y: auto;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 10px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Age Verification Modal */
.age-modal {
    max-width: 500px;
    padding: 30px;
    text-align: center;
}

.age-modal-title {
    color: var(--accent-blue);
    font-size: 1.8em;
    margin-bottom: 20px;
}

.age-modal-text {
    color: var(--text-primary);
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 30px;
}

.age-modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.age-button {
    padding: 12px 30px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.age-yes {
    background: #4caf50;
    color: white;
}

.age-yes:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.age-no {
    background: #f44336;
    color: white;
}

.age-no:hover {
    background: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.modal-banner {
    width: 100%;
    height: 300px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.modal-banner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, transparent, var(--bg-secondary));
}

.modal-banner.no-banner {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    color: var(--text-secondary);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(90vh - 300px);
}

.modal-title {
    font-size: 2.5em;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.modal-status-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.modal-status {
    display: inline-block;
    padding: 6px 15px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 600;
}

.modal-pr-status {
    display: inline-block;
    padding: 6px 15px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 600;
}

.modal-section {
    margin-bottom: 30px;
}

.modal-section-title {
    font-size: 1.3em;
    color: var(--accent-blue);
    margin-bottom: 15px;
    font-weight: 600;
}

.modal-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-link {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-blue), #2196f3);
    padding: 14px 24px;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1em;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    text-align: center;
}

.modal-link:hover {
    background: linear-gradient(135deg, #2196f3, var(--accent-blue));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.5);
}

/* Button icons */
.button-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
    display: inline-block;
}

.modal-notes {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 5px;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Links inside notes */
.modal-notes .note-link {
    color: var(--accent-blue);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s;
}

.modal-notes .note-link:hover {
    color: #2196f3;
    text-decoration: none;
    line-height: 1.6;
    white-space: pre-wrap;
    border-left: 3px solid var(--accent-blue);
}

.modal-notes:empty::before {
    content: 'Nessuna nota disponibile';
    color: var(--text-secondary);
    font-style: italic;
}

/* PR Status badge in game cards */
.game-pr-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: 500;
}

.game-pr-status[data-pr-status="merged"] {
    background: rgba(26, 159, 255, 0.2);
    color: #1a9fff;
    border: 1px solid rgba(26, 159, 255, 0.3);
}


/* Tool type badges */
.tool-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 500;
}

.tool-type-badge[data-type="tool"] {
    background: rgba(26, 159, 255, 0.2);
    color: #1a9fff;
    border: 1px solid rgba(26, 159, 255, 0.3);
}

.tool-type-badge[data-type="meta game"] {
    background: rgba(147, 51, 234, 0.2);
    color: #a855f7;
    border: 1px solid rgba(147, 51, 234, 0.3);
}

.tool-type-badge[data-type="hint game"] {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Tool card placeholder (no cover) */
.tool-cover-placeholder {
    width: 100%;
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(135deg, #2a475e 0%, #1b2838 100%);
    color: var(--text-secondary);
    font-size: 0.9em;
    text-align: center;
    padding: 20px;
}

.tool-cover-placeholder .tool-icon {
    font-size: 3em;
    opacity: 0.5;
}

/* Tool type border colors */
.game-card.border-blue {
    border-color: #1a9fff;
}

.game-card.border-purple {
    border-color: #a855f7;
}

/* Type filter for tools page */
#typeFilter {
    max-width: 200px;
    cursor: pointer;
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-primary);
    font-size: 14px;
}

#typeFilter:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Responsive design */
@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
    }

    h1 {
        font-size: 1.8em;
    }

    .discord-links {
        width: 100%;
        flex-wrap: wrap;
    }

    .discord-button {
        flex: 1;
        justify-content: center;
        min-width: 140px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    #searchInput {
        min-width: 100%;
    }
}