/* ================= RESET ================= */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f2f2f2;
}

/* ================= HEADER ================= */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--dark);
    color: var(--header-text);
    padding: 0;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 20px;
}

header h1 {
    margin: 0;
    font-size: 22px;
}

.site-logo {
    color: var(--header-text);
}

.site-logo svg {
    display: block;
    width: 60px;
    height: 60px;
}

.logo-svg {
    display: block;
    max-width: 60px;
    height: auto;
}

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

nav {
    display: flex;
    gap: 18px;
    font-size: 18px;
}

nav a {
    color: var(--header-text);
    text-decoration: none;
    position: relative;
}

nav a::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.2s ease;
}

nav a:hover::after {
    width: 100%;
}

/* ================= FOOTER ================= */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: var(--dark);
    color: var(--header-text);
    display: flex;
    align-items: center;
    justify-content: right;
    font-size: 14px;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.4);
}
.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 20px;
}

/* ================= MOBILE MENU ================= */
#hamburger {
    display: none;
    font-size: 30px;
    cursor: pointer;
}

#mobileMenu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--dark-light);
    display: none;
    flex-direction: column;
    z-index: 1000;
}

#mobileMenu a {
    color: var(--header-text);
    padding: 14px 20px;
    text-decoration: none;
    border-bottom: 1px solid #444;
    font-size: 20px;
}

/* ================= CONTENT ================= */
main {
    padding: 30px 20px;
    margin-top: var(--header-height);
    margin-bottom: var(--footer-height);
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* ================= COMMON CONTAINERS ================= */
.add-game,
.edit-game,
.game-detail,
.home-container,
.settings-page {
    max-width: 1000px;
    margin: auto;
    background: var(--light);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ================= FLASH MESSAGES ================= */
.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.flash-error {
    color: var(--danger);
    margin-bottom: 15px;
}

/* ================= FORMS ================= */
.form-group label {
    font-weight: bold;
    margin-bottom: 5px;
    display: block;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* ================= BUTTONS ================= */
.submit-btn,
button {
    background: var(--dark);
    color: var(--header-text);
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.submit-btn:hover,
button:hover {
    background: #000;
}

/* ================= HOME ================= */
.platform-block {
    margin-bottom: 30px;
}

.platform-title {
    font-size: 1.4em;
    font-weight: bold;
    margin: 20px 0 10px;
}

.game-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #f1f1f1;
    padding: 12px 15px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-weight: bold;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
}

.game-item:hover {
    background: #e0e0e0;
}

.game-item .game-title {
    flex: 1;
}

.game-item .dlc-count {
    font-weight: bold;
    color: var(--accent);
    font-size: 14px;
    white-space: nowrap;
}

.view-switch {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
}

.view-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #f1f1f1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.view-btn.active {
    background: var(--accent);
    border-color: var(--accent);
}

.view-btn.active img {
    filter: brightness(0) invert(1);
}

.collection-grid {
    display: none;
}

.collection-list {
    display: block;
}

.collection-view-grid .collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.collection-view-grid .collection-list {
    display: none;
}

.game-card {
    position: relative;
}

.favorite-star {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.4);
    color: gold;
    font-size: 20px;
    padding: 4px 6px;
    border-radius: 30%;
    z-index: 2;
}

.dlc-orphan-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #c0392b;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 6px;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ================= ADD GAME ================= */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.result-card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.result-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.result-content {
    padding: 12px;
}

.result-title {
    font-size: 16px;
    font-weight: bold;
    line-height: 1.3;
}

.result-card:hover .result-title {
    color: var(--accent);
    text-decoration: underline;
}

.search-form {
    display: flex;
    gap: 10px;
}

.search-form input[type="text"] {
    flex: 1;
    padding: 10px;
    font-size: 16px;
}

.search-form button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
}

.manual-form {
    max-width: 500px;
}

.manual-form .form-group {
    margin-bottom: 15px;
}

.manual-form .form-actions {
    margin-top: 20px;
    text-align: right;
}

/* ================= EDIT GAME ================= */
.edit-section {
    margin-bottom: 30px;
}

.edit-section h3 {
    margin-bottom: 10px;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.section {
    margin-bottom: 30px;
}

.section h3 {
    margin-bottom: 15px;
    font-size: 20px;
}

.personal-flags {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.flag-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    background: #f1f1f1;
    cursor: pointer;
    font-weight: bold;
    user-select: none;
    transition: background 0.2s, color 0.2s;
}

.flag-checkbox input {
    display: none;
}

.flag-checkbox.favorite {
    color: var(--accent);
}

.flag-checkbox.completed {
    color: #2e7d32;
}

.flag-checkbox input:checked + span {
    text-decoration: underline;
}

.flag-checkbox input:checked ~ .checkmark {
    background: currentColor;
}

.flag-checkbox .checkmark {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid currentColor;
}

.personal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.rating-input {
    max-width: 120px;
}

.tips-textarea {
    min-height: 120px;
    resize: vertical;
}

#updateMenu {
    display: none;
    background: #f5f5f5;
    padding: 15px;
    border-radius: var(--radius);
    animation: fadeIn 0.3s ease-in-out;
}

.edit-footer-actions {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.edit-footer-actions .cancel-btn {
    padding: 10px 20px;
    border-radius: 4px;
    background: #ddd;
    color: #333;
    text-decoration: none;
    font-weight: bold;
}

.edit-footer-actions .cancel-btn:hover {
    background: #ccc;
}

/* ================= GAME DETAIL ================= */
.game-detail {
    max-width: 1000px;
    margin: auto;
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.game-banner {
    position: relative;
    height: 260px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 25px;
    background: #000;
}

.game-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.55);
}

.game-banner-overlay {
    position: absolute;
    inset: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: var(--header-text);
}

.game-banner-overlay h1 {
    margin: 0 0 10px;
    font-size: 28px;
}

.banner-actions {
    display: flex;
    gap: 15px;
}

.banner-actions a {
    color: var(--header-text);
    text-decoration: none;
    font-weight: bold;
    opacity: 0.9;
}

.banner-actions a:hover {
    opacity: 1;
    text-decoration: underline;
}

.game-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.game-meta p {
    margin: 0;
    background: #f4f4f4;
    padding: 10px;
    border-radius: 4px;
}

.game-description {
    margin-bottom: 25px;
}

.game-description h3 {
    margin-bottom: 5px;
}

.game-tags {
    margin-bottom: 25px;
    color: #ADADAD;
    font-style: italic;
}

.game-tags h3 {
    margin-bottom: 5px;
}

.image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
}

.image-grid img {
    max-width: 280px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.main-image img {
    max-width: 300px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.screenshots {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.screenshots img {
    max-width: 200px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ================= SETTINGS ================= */
.settings-page {
    max-width: 1000px;
    margin: auto;
}

.settings-page h2 {
    font-size: 28px;
    margin-bottom: 10px;
}

.settings-intro {
    margin-bottom: 25px;
    color: #555;
}

.settings-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.settings-card h3 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 20px;
}

.settings-card .subtitle {
    font-size: 14px;
    color: #777;
    margin-bottom: 15px;
}

.settings-card label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.settings-card input,
.settings-card select {
    width: 100%;
    max-width: 400px;
    padding: 8px 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.settings-card button {
    padding: 8px 16px;
    background: #222;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.settings-card button:hover {
    background: #000;
}

.page-actions {
    margin-bottom: 20px;
}

.action-link {
    text-decoration: none;
    font-weight: bold;
    color: #0066cc;
    transition: color 0.2s ease;
    margin-right: 10px;
}

.action-link:hover {
    color: #003f7f;
}

.danger-zone {
    border: 1px solid #c00;
    background: rgba(200,0,0,0.05);
}

.danger-btn {
    background: #c00;
    color: #fff;
    border: none;
}

.danger-btn:hover {
    background: #900;
}

/* ================= RANDOM GAME ================= */
.random-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.random-card {
    background: var(--light);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.3s ease-in-out;
}

.random-title {
    font-size: 22px;
    font-weight: bold;
    margin: 15px 0 5px;
}

.random-platform {
    color: #555;
    margin-bottom: 20px;
}

.random-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.random-actions button {
    min-width: 140px;
}

.random-btn {
    color: var(--header-text);
}

/* ================= MODALS ================= */
.import-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.import-card {
    background: var(--light);
    padding: 25px 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 420px;
    width: 90%;
    text-align: center;
    animation: fadeIn 0.25s ease-in-out;
}

.import-card h3 {
    margin-top: 0;
}

.import-warning {
    background: rgba(200,0,0,0.1);
    border: 1px solid #c00;
    color: #900;
    padding: 10px;
    border-radius: 6px;
    margin: 15px 0;
    font-weight: bold;
}

.import-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.import-actions button {
    min-width: 140px;
}

.import-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.rawg-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.rawg-card {
    background: var(--light);
    padding: 25px 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 420px;
    width: 90%;
    animation: fadeIn 0.25s ease-in-out;
}

.rawg-card h3 {
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
}

.rawg-checkbox {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    cursor: pointer;
}

.rawg-checkbox input {
    margin-right: 8px;
}

.rawg-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.cancel-btn {
    background: #ccc;
    color: #000;
}

.cancel-btn:hover {
    background: #bbb;
}

/* ================= LIGHTBOX ================= */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.lightbox.hidden {
    display: none;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 50px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    user-select: none;
}

.lightbox-nav.prev {
    left: 10px;
}

.lightbox-nav.next {
    right: 10px;
}

/* ================= ANIMATIONS ================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ================= RESPONSIVE ================= */
@media (max-width: 820px) {
    .header-container {
        padding: 0 15px;
    }

    header {
        padding: 0 15px;
    }

    header h1 {
        font-size: 18px;
    }

    nav {
        display: none;
    }

    #hamburger {
        display: block;
    }

    #mobileMenu {
        display: none;
        flex-direction: column;
    }

    #mobileMenu.active {
        display: flex;
    }

    .add-game,
    .edit-game,
    .game-detail,
    .home-container,
    .settings-page {
        padding: 15px;
        border-radius: 0;
        box-shadow: none;
    }

    main {
        padding: 15px 10px;
    }

    body {
        font-size: 16px;
    }

    h2 {
        font-size: 22px;
    }

    h3 {
        font-size: 18px;
    }

    .game-item {
        font-size: 16px;
        padding: 14px;
    }

    .main-image img,
    .screenshots img,
    .images-preview img {
        max-width: 100%;
        height: auto;
    }

    .random-actions {
        flex-direction: column;
    }

    .edit-header,
    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .edit-actions,
    .game-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    button,
    .submit-btn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .game-banner {
        height: 200px;
    }

    .game-banner-overlay h1 {
        font-size: 22px;
    }

    .image-grid img,
    .screenshots img {
        max-width: 100%;
    }

    .lightbox-nav {
        display: none;
        pointer-events: none;
    }

    .lightbox-close {
        top: 12px;
        right: 12px;
        font-size: 28px;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .result-thumb {
        height: 120px;
    }

    .result-title {
        font-size: 14px;
    }

    .collection-view-grid .result-thumb {
        height: 100px;
    }

    .collection-view-grid .result-title {
        font-size: 14px;
    }
}

/* Touch actions */
.lightbox * {
    -webkit-tap-highlight-color: transparent;
}

.lightbox-nav,
.lightbox-close {
    touch-action: manipulation;
}

