/* TubZi app chrome: sidebar + overlapping top bar (browse / categories / all games). */

:root {
    --brand: #ff6a00;
    --brand-hover: #e55f00;
    --bg: #1a1c2c;
    --header-bg: #16182a;
    --header-border: #2a2d42;
    --text: #e8e8ef;
    --text-muted: #8b8fa3;
    --btn-bg: #2a2d42;
    --btn-bg-hover: #35384f;
    --btn-border: #3d4158;
    --search-bg: #252838;
    --search-border: #3d4158;
    --search-placeholder: #6c7088;
    --accent-green: #22c55e;
    --accent-green-hover: #16a34a;
    --card-radius: 16px;
    --rail-width: 276px;
    --site-header-height: 88px;
}

body.light {
    --bg: #eef1f8;
    --header-bg: #ffffff;
    --header-border: #dde1ed;
    --text: #1a1c2c;
    --text-muted: #5c6070;
    --btn-bg: #eef0f4;
    --btn-bg-hover: #e2e6ee;
    --btn-border: #c8cedd;
    --search-bg: #f1f3f9;
    --search-border: #c8cedd;
    --search-placeholder: #8b909f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    flex-direction: column;
}

/* Main column only (rail hidden); header absolutely spans full width on top */
.app-shell {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    min-width: 0;
    position: relative;
}

.site-header {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    z-index: 400;
    flex-shrink: 0;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    padding: 16px 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

body.light .site-header {
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.game-rail {
    display: none !important;
    grid-column: 1 / 2;
    grid-row: 1 / -1;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: var(--rail-width);
    padding-top: var(--site-header-height);
    box-sizing: border-box;
    background: var(--header-bg);
    border-right: 1px solid var(--header-border);
    border-radius: 0;
    box-shadow: none;
    z-index: 200;
    overflow: hidden;
}

body.light .game-rail {
    box-shadow: none;
}

.game-rail-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
    padding: 12px 0 14px;
}

.game-rail-top {
    flex-shrink: 0;
    padding: 4px 14px 12px;
    margin: 0 10px 8px;
    border-bottom: 1px solid var(--header-border);
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--brand);
}

.game-rail-scroll {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 0 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--btn-border) transparent;
}

.game-rail-scroll::-webkit-scrollbar {
    width: 5px;
}

.game-rail-scroll::-webkit-scrollbar-thumb {
    background: var(--btn-border);
    border-radius: 4px;
}

.rail-section-label {
    padding: 14px 12px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.85;
}

.rail-section-label:first-child {
    padding-top: 2px;
}

.rail-section-label--compact {
    padding: 6px 12px 2px;
    font-size: 9px;
    letter-spacing: 0.1em;
    opacity: 0.75;
}

.rail-nav-item--compact {
    margin: 1px 2px;
    padding: 5px 10px;
    gap: 8px;
    font-size: 12px;
    border-radius: 10px;
}

.rail-nav-item--compact .rail-icon {
    width: 17px;
    height: 17px;
}

.rail-game-loop-item--thumb {
    height: 44px;
    padding: 0;
    margin: 2px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.rail-game-loop-item--thumb .rail-label {
    display: none;
}

.rail-spacer {
    flex: 1 1 24px;
    min-height: 16px;
    pointer-events: none;
}

.rail-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 4px);
    margin: 3px 2px;
    padding: 8px 12px;
    border: none;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: left;
    color: var(--text-muted);
    transition:
        background 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.rail-nav-item:hover {
    background: var(--btn-bg-hover);
    color: var(--text);
}

.rail-nav-item.is-active {
    background: var(--btn-bg-hover);
    color: var(--text);
    box-shadow: 0 0 0 2px rgba(255, 106, 0, 0.35);
}

body.light .rail-nav-item.is-active {
    box-shadow: 0 0 0 2px rgba(255, 106, 0, 0.28);
}

.rail-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: var(--brand);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.18s ease;
}

.rail-nav-item:hover .rail-icon,
.rail-nav-item.is-active .rail-icon {
    stroke: var(--brand-hover);
}

.rail-label {
    display: block;
    font-family: "Fredoka", system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.app-content {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    min-width: 0;
    min-height: 0;
    padding-top: var(--site-header-height);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.app-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.site-main {
    flex: 1 0 auto;
    min-width: 0;
    margin-left: 0;
}

.header-inner {
    max-width: 1180px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
    min-height: 54px;
}

.logo-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    color: var(--brand);
}

a.logo-brand {
    text-decoration: none;
    color: var(--brand);
    cursor: pointer;
    border-radius: 10px;
}

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

a.logo-brand:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

.logo-icon {
    flex-shrink: 0;
    display: block;
    width: 48px;
    height: 34px;
}

.logo-text {
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: clamp(1.8rem, 4.5vw, 2.4rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    color: var(--brand);
}

.header-search-slot {
    flex: 1;
    min-width: 120px;
    display: flex;
    justify-content: stretch;
}

.header-search-form {
    flex: 1;
    min-width: 120px;
    display: flex;
    justify-content: stretch;
    margin: 0;
}

.search-wrap {
    position: relative;
    width: 100%;
    max-width: none;
}

.search-wrap svg {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

#search {
    width: 100%;
    padding: 13px 18px 13px 52px;
    border-radius: 999px;
    border: 1px solid var(--search-border);
    background: var(--search-bg);
    color: var(--text);
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#search::placeholder {
    color: var(--search-placeholder);
}

#search:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.22);
}

.theme-icon-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: #fbbf24;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
}

.theme-icon-btn:hover {
    background: var(--btn-bg-hover);
}

.theme-icon-btn:active {
    transform: scale(0.96);
}

.theme-icon-btn svg {
    width: 24px;
    height: 24px;
}

.theme-icon-btn .icon-moon {
    display: none;
    color: var(--text-muted);
}

body.light .theme-icon-btn .icon-sun {
    display: none;
}

body.light .theme-icon-btn .icon-moon {
    display: block;
}

.hdr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 11px 17px;
    border-radius: 10px;
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.hdr-btn:hover {
    background: var(--btn-bg-hover);
}

.hdr-btn-random {
    flex-shrink: 0;
    background: var(--accent-green);
    border-color: var(--accent-green-hover);
    color: #fff;
}

.hdr-btn-random:hover {
    background: var(--accent-green-hover);
    border-color: var(--accent-green-hover);
}

.hdr-btn-random svg {
    width: 18px;
    height: 18px;
}

a.rail-nav-item {
    text-decoration: none;
    box-sizing: border-box;
}

body[data-tubzi-page="category"] .hdr-btn-random {
    display: none;
}

@media (max-width: 900px) {
    :root {
        --rail-width: 220px;
    }
}

@media (max-width: 720px) {
    .app-shell {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .site-header {
        position: relative;
        left: auto;
        top: auto;
        right: auto;
        z-index: 300;
        order: 1;
    }

    .game-rail {
        order: 2;
        grid-column: auto;
        grid-row: auto;
        width: 100%;
        max-width: none;
        padding-top: 0;
        border-right: none;
        border-bottom: 1px solid var(--header-border);
        max-height: min(42vh, 320px);
    }

    .game-rail-inner {
        max-height: min(42vh, 320px);
    }

    .app-content {
        order: 3;
        grid-column: auto;
        grid-row: auto;
        flex: 1;
        min-height: 0;
        padding-top: 0;
    }

    .rail-spacer {
        display: none;
    }
}

@media (max-width: 640px) {
    .site-header {
        padding: 12px 16px;
    }

    .header-inner {
        gap: 10px;
        min-height: 48px;
    }

    .hdr-btn {
        padding: 9px 12px;
        font-size: 13px;
    }

    #search {
        font-size: 15px;
        padding: 11px 15px 11px 46px;
    }

    .theme-icon-btn {
        width: 44px;
        height: 44px;
    }

    .rail-icon {
        width: 18px;
        height: 18px;
    }

    .rail-nav-item {
        font-size: 13px;
        padding: 7px 10px;
    }
}
