/* Base layout */
body {
    font-family: sans-serif;
    margin: 0;
}

[hidden] {
    display: none !important;
}

.is-hidden {
    display: none !important;
}

.page-shell {
    width: min(1400px, 100%);
    margin: 0 auto;
}

/* Header */
.header {
    background: #f5f5f5;
    padding: 24px;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header h1 {
    margin: 0;
}

.header-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "title account"
        "search link";
    align-items: start;
    column-gap: 20px;
    row-gap: 10px;
}

.app-title {
    grid-area: title;
    margin: 0;
    font-size: 1.5rem;
    white-space: nowrap;
}

.title-block {
    grid-area: title;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.app-description {
    margin: 0;
    max-width: 62ch;
    color: #475467;
    font-size: 0.95rem;
    line-height: 1.4;
}

.public-home-cta {
    margin: 0;
    color: #475467;
    font-size: 0.92rem;
    line-height: 1.4;
}

.public-home-link {
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: none;
}

.public-home-link:hover {
    text-decoration: underline;
}

.session-controls {
    display: contents;
}

.session-account-row {
    grid-area: account;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.current-user {
    font-weight: 600;
    color: #243447;
    white-space: nowrap;
}

.session-btn {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    background: #243447;
    color: #fff;
    cursor: pointer;
}

.session-link {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    grid-area: link;
    justify-self: end;
    width: 100%;
    max-width: 560px;
    text-align: right;
    color: #243447;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background: #eef2f7;
    border: 1px solid #d2d9e3;
    border-radius: 6px;
    min-height: 42px;
    padding: 0 10px;
    line-height: 1;
}

.session-link::before {
    content: "\1F517";
    flex: 0 0 auto;
    line-height: 1;
}

.session-link:hover {
    text-decoration: underline;
}

.session-controls .search-container {
    grid-area: search;
    width: min(460px, 100%);
    max-width: 460px;
    justify-self: start;
}

@media (max-width: 900px) {
    .header-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "account"
            "search"
            "link";
        row-gap: 12px;
    }

    .session-controls .search-container {
        width: 100%;
        max-width: none;
    }

    .session-account-row {
        justify-self: start;
    }

    .session-link {
        justify-self: stretch;
        justify-content: flex-start;
        text-align: left;
    }
}

/* Auth */
.auth-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
    gap: 16px;
    margin: 24px;
}

.auth-card {
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
}

.auth-card h2 {
    margin: 0 0 16px 0;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #243447;
}

.auth-input {
    padding: 10px;
    border: 1px solid #c7d0db;
    border-radius: 6px;
    font-size: 1rem;
}

.auth-submit {
    margin-top: 8px;
    border: none;
    border-radius: 6px;
    padding: 10px 14px;
    background: #4a90e2;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.auth-status {
    margin: 0 24px 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
}

.auth-status[data-state="error"] {
    background: #fbe7e5;
    color: #8a1f11;
}

.auth-status[data-state="success"] {
    background: #e8f5ea;
    color: #17612a;
}

.public-list-banner {
    margin: 0 24px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #243447;
}

/* Search */
.search-container {
    position: relative;
    max-width: 400px;
}

.search-input {
    width: 100%;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.search-results[hidden] {
    display: none;
}

.search-result {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-result:hover {
    background: #f9f9f9;
}

.search-result-image {
    width: 80px;
    height: 30px;
    object-fit: contain;
    border-radius: 3px;
    flex-shrink: 0;
    background: #ddd;
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
}

/* Game list */
#game-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px;
}

.game-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.game-row.is-played {
    background: linear-gradient(180deg, #d4edda 0%, #c8e6c9 100%);
    border-color: #a8d5a8;
}

.game-row.is-played .game-name {
    color: #667085;
}

.game-row.is-played .game-rating,
.game-row.is-played .game-tags,
.game-row.is-played .game-played-toggle {
    opacity: 0.8;
}

/* Media and left column */
.game-image-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
}

.game-image-link {
    display: inline-block;
}

.game-row img {
    flex: 0 0 auto;
    border-radius: 4px;
}

.game-image {
    width: 144px;
    height: 216px;
    object-fit: cover;
}

.game-row.is-played .game-image,
.game-row.is-played .game-screenshot,
.game-row.is-played .game-video img {
    filter: grayscale(0.35) saturate(0.8);
    opacity: 0.9;
}

/* Row actions */
.game-remove-btn {
    background: rgba(192, 57, 43, 0.9);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.game-remove-btn:hover {
    background: rgba(192, 57, 43, 1);
}

.game-played-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 2px;
    font-size: 0.875rem;
    color: #344054;
    user-select: none;
    cursor: pointer;
}

.game-played-checkbox {
    margin: 0;
    width: 16px;
    height: 16px;
    accent-color: #4a90e2;
    cursor: pointer;
}

.game-played-checkbox:disabled {
    cursor: not-allowed;
}

/* Main content and ordering controls */
.game-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.game-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

.game-order-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
    align-self: center;
    align-items: center;
}

.game-position {
    min-width: 32px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #444;
    line-height: 1;
}

.game-up-btn,
.game-down-btn {
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-up-btn:hover,
.game-down-btn:hover {
    background: #357abd;
}

.game-up-btn:disabled,
.game-down-btn:disabled {
    background: #b8c3d1;
    color: #eef3f8;
    cursor: not-allowed;
}

.game-up-btn:disabled:hover,
.game-down-btn:disabled:hover {
    background: #b8c3d1;
}

/* Textual details */
.game-name {
    font-size: 1rem;
    font-weight: 600;
    color: inherit;
    text-decoration: none;
    flex: 1 1 auto;
    min-width: 0;
}

.game-name:hover {
    text-decoration: underline;
}

.game-rating {
    font-size: 0.8rem;
    color: #444;
}

.game-rating-label {
    font-weight: 600;
}

.game-rating-label[data-sentiment="positive"] {
    color: #1a9e3f;
}

.game-rating-label[data-sentiment="mixed"] {
    color: #c07000;
}

.game-rating-label[data-sentiment="negative"] {
    color: #c0392b;
}

.game-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.game-tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #243447;
    font-size: 0.8rem;
}

/* Pricing */
.game-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    margin-left: auto;
    padding: 8px 12px;
    border: 1px solid #d7e2d2;
    border-radius: 10px;
    background: #f3fbf0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f5f2c;
    text-align: right;
}

.game-row.is-played .game-price {
    display: none;
}

.game-price-discount {
    color: #b42318;
}

.game-price-current {
    color: #1f5f2c;
    font-size: 1.05rem;
}

.game-price-original {
    color: #667085;
    font-weight: 500;
    text-decoration: line-through;
}

/* Screenshots and video thumbnails */
.game-screenshots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: calc(68px * 2.5 + 8px * 2);
    overflow-y: auto;
    overflow-x: hidden;
    align-content: flex-start;
    padding-right: 4px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.game-screenshots.is-dragging-scroll {
    cursor: grabbing;
}

.game-screenshots img,
.game-screenshots .game-video {
    -webkit-user-drag: none;
}

.game-screenshot {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 4px;
    flex: 0 0 auto;
    cursor: zoom-in;
}

.game-video {
    position: relative;
    width: 120px;
    height: 68px;
    border-radius: 4px;
    flex: 0 0 auto;
    cursor: zoom-in;
    background: #000;
    overflow: hidden;
}

.game-video img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.game-video::after {
    content: "\25B6";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 2px;
    pointer-events: none;
}

/* Overlay */
.screenshot-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.screenshot-overlay[hidden] {
    display: none;
}

.screenshot-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: min(1100px, 95vw);
}

.screenshot-overlay-image {
    max-width: min(1100px, 95vw);
    max-height: 80vh;
    border-radius: 8px;
}

.screenshot-overlay-video {
    width: min(1100px, 95vw);
    max-height: 80vh;
    border-radius: 8px;
    background: #000;
}

.screenshot-overlay-nav-row {
    display: flex;
    gap: 12px;
}

.screenshot-overlay-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1;
    border: 0;
    border-radius: 999px;
    padding: 8px 12px;
    background: #ffffff;
    color: #111111;
    font-weight: 600;
    cursor: pointer;
}

.screenshot-overlay-nav {
    border: 0;
    border-radius: 999px;
    padding: 10px 20px;
    background: #ffffff;
    color: #111111;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 900px) {
    #game-list {
        margin: 16px;
    }

    .game-row {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }

    .game-image {
        width: 96px;
        height: 144px;
    }

    .game-meta {
        min-width: 0;
        flex: 1 1 calc(100% - 120px);
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .game-price {
        margin-left: 0;
        justify-content: flex-start;
        text-align: left;
    }

    .game-order-btns {
        flex-direction: row;
        justify-content: flex-end;
        align-self: stretch;
        width: 100%;
        padding-top: 4px;
    }

    .game-position {
        min-width: 24px;
    }

    .game-up-btn,
    .game-down-btn {
        width: 30px;
        height: 30px;
    }

    .game-screenshot,
    .game-video {
        width: 108px;
        height: 61px;
    }
}

@media (max-width: 520px) {
    .game-image {
        width: 84px;
        height: 126px;
    }
}
