* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212;
    color: #f0f0f0;
    padding: 40px 20px;
}

h1 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 40px;
    letter-spacing: 2px;
    font-weight: 700;
    text-transform: uppercase;
    color: #ff4444;
}

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.search-container {
    max-width: 600px;
    margin: 0 auto 30px auto;
    padding: 0 20px;
    position: relative;
}

#game-search {
    width: 100%;
    padding: 18px 25px;
    font-size: 18px;
    border: 3px solid #ff4444;
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(40, 40, 40, 0.9));
    color: #ffffff;
    outline: none;
    transition: all 0.4s ease;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(255, 68, 68, 0.2);
}

#game-search::placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
}

#game-search:focus {
    border-color: #ff6666;
    background: linear-gradient(135deg, rgba(40, 40, 40, 0.95), rgba(50, 50, 50, 0.95));
    box-shadow: 0 0 25px rgba(255, 102, 102, 0.5), 0 0 50px rgba(255, 68, 68, 0.2);
    transform: translateY(-2px);
}

#game-search:hover {
    border-color: #ff5555;
    box-shadow: 0 6px 25px rgba(255, 68, 68, 0.3);
}

#game-count {
    text-align: center;
    color: #ff6666;
    margin-top: 15px;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.game-card {
    background-color: #1e1e1e;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(255, 68, 68, 0.6);
}

.game-card.hidden {
    display: none;
}

.favorite-star {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    cursor: pointer;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: rgba(255, 255, 255, 0.6);
    border: 2px solid transparent;
}

.favorite-star:hover {
    background: rgba(255, 68, 68, 0.8);
    color: white;
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.favorite-star.favorited {
    background: linear-gradient(135deg, #ffd700, #ffb347);
    color: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.favorite-star.favorited:hover {
    background: linear-gradient(135deg, #ffed4e, #ffd700);
    transform: scale(1.1);
}

.favorite-star svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.game-image {
    width: 100%;
    height: 140px;
    object-fit: fill;
    transition: opacity 0.3s ease;
}

.game-card:hover .game-image {
    opacity: 0.9;
}

.game-content {
    padding: 15px;
    text-align: center;
}

.game-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
    font-weight: 600;
    color: #ff6666;
    line-height: 1.3;
    cursor: help;
    transition: color 0.3s ease;
}

.game-title:hover {
    color: #ff8888;
}

.play-button {
    background-color: #ff4444;
    color: white;
    padding: 8px 20px;
    font-size: 0.9rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
}

.play-button:hover,
.play-button:focus {
    background-color: #cc0000;
    outline: none;
    transform: scale(1.05);
}

.scroll-buttons {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 15px;
    z-index: 1000;
}

.scroll-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff4444, #cc0000);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(255, 68, 68, 0.4);
    transition: all 0.3s ease;
    opacity: 1;
    pointer-events: auto;
    font-weight: bold;
}

.scroll-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(255, 68, 68, 0.6);
    background: linear-gradient(135deg, #ff6666, #ee0000);
}

.scroll-btn:active {
    transform: scale(0.95);
}

.scroll-btn svg {
    width: 28px;
    height: 28px;
}

.no-results {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    margin: 50px 0;
    grid-column: 1 / -1;
    padding: 40px;
    background: rgba(255, 68, 68, 0.1);
    border-radius: 12px;
    border: 2px dashed rgba(255, 68, 68, 0.3);
}

.settings-overlay--scoped {
    background-color: #292929;
    border-radius: 12px;
    padding: 25px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    color: #ddd;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    gap: 15px;
    grid-column: 1 / -1;
    margin-top: 20px;
    border: 2px solid #333;
    transition: border-color 0.3s ease;
}

.settings-overlay--scoped:hover {
    border-color: #ff4444;
}

.settings-overlay--scoped label {
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
    color: #ff6666;
}

.settings-overlay--scoped small {
    font-weight: 400;
    font-size: 0.85rem;
    color: #999;
}

#panic-key {
    background-color: #1e1e1e;
    border: 2px solid #ff4444;
    border-radius: 6px;
    padding: 10px 12px;
    width: 100%;
    color: #f0f0f0;
    font-weight: 600;
    font-size: 1rem;
    cursor: not-allowed;
    user-select: text;
    transition: all 0.3s ease;
}

#panic-key:focus {
    outline: none;
    border-color: #cc0000;
    background-color: #2a2a2a;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
}

#panic-url {
    background-color: #1e1e1e;
    border: 2px solid #ff4444;
    border-radius: 6px;
    padding: 10px 12px;
    width: 100%;
    color: #f0f0f0;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: text;
}

#panic-url:focus {
    outline: none;
    border-color: #cc0000;
    background-color: #2a2a2a;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
}

#panic-url::placeholder {
    color: #999;
    font-weight: 400;
}

select[data-cloak-select] {
    background-color: #1e1e1e;
    border: 2px solid #ff4444;
    border-radius: 6px;
    color: #f0f0f0;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

select[data-cloak-select]:focus {
    outline: none;
    border-color: #cc0000;
    background-color: #2a2a2a;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
}

select[data-cloak-select]:hover {
    border-color: #ff6666;
}

#loading-message {
    text-align: center;
    color: #ff6666;
    font-size: 18px;
    margin: 50px 0;
    grid-column: 1 / -1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@media (min-width: 1400px) {
    .dashboard {
        max-width: 1600px;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 18px;
    }
    
    .scroll-buttons {
        bottom: 30px;
    }
}

@media (min-width: 1024px) and (max-width: 1399px) {
    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 18px;
    }
    
    body {
        padding: 30px 15px;
    }
    
    .scroll-buttons {
        bottom: 15px;
    }
    
    .scroll-btn {
        width: 55px;
        height: 55px;
    }
    
    .scroll-btn svg {
        width: 24px;
        height: 24px;
    }
}

@media (min-width: 600px) and (max-width: 767px) {
    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 15px;
    }
    
    .game-image {
        height: 120px;
    }
    
    body {
        padding: 25px 12px;
    }
    
    .scroll-buttons {
        bottom: 12px;
    }
    
    .scroll-btn {
        width: 50px;
        height: 50px;
    }
    
    .scroll-btn svg {
        width: 22px;
        height: 22px;
    }
    
    .favorite-star {
        width: 28px;
        height: 28px;
        top: 8px;
        right: 8px;
    }
}

@media (max-width: 599px) {
    body {
        padding: 20px 10px;
    }

    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }

    .game-image {
        height: 100px;
    }
    
    .game-content {
        padding: 10px;
    }
    
    .game-title {
        font-size: 0.95rem;
        margin-bottom: 8px;
    }
    
    .play-button {
        padding: 6px 15px;
        font-size: 0.85rem;
    }

    h1 {
        font-size: 2rem;
        margin-bottom: 30px;
    }
    
    .search-container {
        padding: 0 10px;
    }
    
    #game-search {
        padding: 15px 20px;
        font-size: 16px;
        border-width: 2px;
    }
    
    .scroll-buttons {
        bottom: 10px;
        gap: 10px;
    }
    
    .scroll-btn {
        width: 45px;
        height: 45px;
    }
    
    .scroll-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .settings-overlay--scoped {
        padding: 20px 15px;
        gap: 12px;
    }
    
    .favorite-star {
        width: 26px;
        height: 26px;
        top: 6px;
        right: 6px;
    }
    
    .favorite-star svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 400px) {
    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }
    
    .game-image {
        height: 85px;
    }
    
    .game-title {
        font-size: 0.85rem;
    }
    
    .play-button {
        padding: 5px 12px;
        font-size: 0.8rem;
    }
    
    h1 {
        font-size: 1.8rem;
        letter-spacing: 1px;
    }
    
    .scroll-btn {
        width: 40px;
        height: 40px;
    }
    
    .scroll-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .favorite-star {
        width: 24px;
        height: 24px;
        top: 5px;
        right: 5px;
    }
    
    .favorite-star svg {
        width: 14px;
        height: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .game-card,
    .play-button,
    .scroll-btn,
    #game-search,
    .favorite-star {
        transition: none;
    }
    
    #loading-message {
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .game-card {
        border: 2px solid #fff;
    }
    
    .play-button {
        border: 2px solid #fff;
    }
    
    .scroll-btn {
        border: 2px solid #fff;
    }
    
    .favorite-star {
        border: 2px solid #fff;
    }
}