:root {
    --trivit-font-family: Arial, sans-serif;
    --trivit-shell-gap: 12px;
    --trivit-shell-radius: 18px;
    --trivit-header-inline-spacing: 12px;
}

/* Page-wide defaults: removes browser spacing, sets the base font, and applies the gray background. */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--trivit-font-family);
    font-size: 16px;
    background-color: #cbcbcb;
    color: #494949;
    box-sizing: border-box;
    padding: var(--trivit-shell-gap);
}

button,
input,
textarea,
select {
    font: inherit;
}

header,
header *,
.auth-panel,
.auth-panel *,
.account-panel,
.account-panel *,
footer,
footer *,
.page-placeholder,
.page-placeholder * {
    font-family: var(--trivit-font-family);
}

/* Top navigation bar: arranges its children horizontally and keeps absolute-positioned effects anchored here. */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    background-color: #cbcbcb;
    padding: 5px var(--trivit-header-inline-spacing);
    position: relative;
    border: 1px solid #494949;
    border-radius: var(--trivit-shell-radius);
}

/* Left section of the header: keeps the logo and tabs aligned in one row. */
.left {
    display: flex;
    align-items: center;
    gap: var(--trivit-header-inline-spacing);
    min-width: 0;
}

/* Controls the logo size and spacing from the navigation tabs. */
.logo {
    display: flex;
    align-items: center;
}

.logo img {
    display: block;
    height: 50px;
    margin-right: 0;
}

.logo a {
    display: inline-flex;
    align-items: center;
}

/* Tab container: used as the positioning context for the tab highlight elements. */
.tabs {
    position: relative;
}

/* Removes default list styling and displays the tabs side by side. */
.tabs ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: var(--trivit-header-inline-spacing);
}

/* Base style for each tab: spacing, text color, click cursor, and stacking above the moving background. */
.tabs li {
    color: #494949;
    cursor: pointer;
    position: relative;
    background-color: transparent;
    border: 1px solid #494949;
    border-radius: 12px;
    transition: color 0.18s ease;
    z-index: 1; /* keep text above selector */
}

.tab-link {
    display: block;
    padding: 8px 16px;
    color: inherit;
    text-decoration: none;
}

.tab-link,
.search-bar input,
.auth-trigger,
.footer-tabs a,
.auth-submit,
.auth-mode-toggle,
.account-menu-item {
    font-family: inherit;
    font-size: 1rem;
}

.tab-link,
.search-bar input,
.auth-trigger,
.footer-tabs a {
    letter-spacing: 0.08em;
}

.tabs li,
.tab-link,
.auth-trigger,
.footer-tabs li,
.footer-tabs a {
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Hover feedback is handled by the separate `.tab-hover` element instead of a per-tab pseudo-element. */

/* Active tab text changes color so it stays visible on the dark selector background. */
.tabs li.active {
    color: #cbcbcb;
}

/* Animated dark background that slides behind the currently selected tab. */
.tab-selector {
    position: absolute;
    top: 0;
    left: 0;
    height: 0;
    background-color: #494949;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    z-index: 0; /* behind text but above .tab-hover */
}

.tab-selector.is-ready {
    transition: transform 0.28s cubic-bezier(.2,.9,.2,1), width 0.28s cubic-bezier(.2,.9,.2,1), top 0.28s cubic-bezier(.2,.9,.2,1), height 0.28s cubic-bezier(.2,.9,.2,1), opacity 0.18s ease;
}

.tab-selector.is-visible {
    opacity: 1;
}

/* Right section of the header: keeps the search aligned to the far edge. */
.right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--trivit-header-inline-spacing);
    flex-shrink: 0;
}

.search-bar {
    position: relative;
    z-index: 2;
}

.search-bar input {
    box-sizing: border-box;
    padding: 6px 12px;
    border: 0;
    background: transparent;
    width: 126px;
    margin: 0;
    border-radius: 12px;
    outline: 4px;
    box-shadow: none;
    color: inherit;
    font: inherit;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
    height: 35px;
    line-height: 24px;
    pointer-events: auto;
    transition: width 0.28s cubic-bezier(.2,.9,.2,1), color 0.18s ease;
    border: 1px solid #494949;
}

/* Placeholder text styling (centered by text-align above). */
.search-bar input::placeholder {
    color: #494949;
    opacity: 1;
    transition: color 0.18s ease;
}

/* When the search bar is selected (the tab selector moves over it),
   make the input text and placeholder light for readability. */
.search-bar.active input {
    color: #cbcbcb;
    width: 286px;
    text-align: left;
}
.search-bar.active input::placeholder {
    color: #cbcbcb;
}

.auth-trigger {
    min-height: 35px;
    padding: 0 18px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: color 0.18s ease;
}

.auth-trigger.active {
    color: #cbcbcb;
}

.auth-trigger:disabled {
    opacity: 1;
    cursor: default;
}

/* Hover outline shown at header level: matches the selector shape, but only draws a border. */
.tab-hover {
    position: absolute;
    top: 10px;
    left: 0;
    height: calc(100% - 28px);
    border: 4px solid #494949;
    border-radius: 12px;
    z-index: 0; /* behind text but above .tab-selector */
}

/* Main page content gets inner spacing so it does not touch the viewport edges. */
main {
    flex: 1;
    padding: 20px;
}

.page-main {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(73, 73, 73, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.auth-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.auth-panel,
.account-panel {
    position: fixed;
    top: var(--auth-panel-top, 90px);
    right: 28px;
    width: min(420px, calc(100vw - 32px));
    padding: 18px 18px 18px;
    border: 1px solid #494949;
    border-radius: 18px;
    background: #cbcbcb;
    box-shadow: 0 20px 42px rgba(73, 73, 73, 0.16);
    opacity: 0;
    pointer-events: none;
    --panel-origin-x: calc(100% - 54px);
    --panel-origin-y: -18px;
    transform-origin: var(--panel-origin-x) var(--panel-origin-y);
    transform: scale(0.18);
    transition: opacity 0.16s ease-in, transform 0.2s cubic-bezier(.55,.06,.68,.19);
    will-change: opacity, transform;
    z-index: 11;
}

.auth-panel.is-open,
.account-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    transition: opacity 0.22s ease-out, transform 0.28s cubic-bezier(.16,.84,.28,1);
}

.auth-close,
.account-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 35px;
    height: 35px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
    cursor: pointer;
}

.auth-close,
.account-close {
    background-image: url("Trivit Close Icon Light.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 14px 14px;
}

.auth-close {
    top: 10px;
    right: 10px;
}

.auth-panel h2 {
    margin: 2px 56px 18px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
}

.account-panel h2,
.page-placeholder h1 {
    margin: 0 0 10px;
    font-family: inherit;
    font-size: clamp(1.8rem, 4vw, 2.3rem);
    letter-spacing: 0.02em;
    line-height: 1.05;
}

.account-copy {
    margin: 0 0 22px;
    line-height: 1.5;
    opacity: 0.82;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-field {
    position: relative;
    display: block;
    padding-top: 10px;
}

.auth-field + .auth-field {
    margin-top: 4px;
}

.auth-field-label {
    position: absolute;
    top: 0;
    left: 50%;
    min-height: 28px;
    padding: 0 14px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: #cbcbcb;
    color: #494949;
    font-size: 0.82rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    line-height: 26px;
    text-transform: uppercase;
    transform: translateX(-50%);
    z-index: 1;
}

.auth-field input {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    padding: 14px 14px 12px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
}

.auth-field input:focus {
    outline: 2px solid rgba(73, 73, 73, 0.22);
    outline-offset: 2px;
}

.auth-submit {
    min-height: 46px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: #494949;
    color: #cbcbcb;
    font: inherit;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.18s ease;
}

.auth-submit:hover,
.auth-submit:focus-visible {
    opacity: 0.88;
}

.auth-submit:disabled {
    cursor: wait;
    opacity: 0.7;
}

.auth-provider-separator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 0;
    color: rgba(73, 73, 73, 0.72);
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: lowercase;
}

.auth-provider-separator::before,
.auth-provider-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(73, 73, 73, 0.36);
}

.auth-google-button {
    min-height: 46px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.auth-google-button:hover,
.auth-google-button:focus-visible {
    background: #494949;
    color: #cbcbcb;
    opacity: 1;
}

.auth-google-button:disabled {
    opacity: 0.55;
    cursor: wait;
}

.auth-mode-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.auth-mode-label {
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    line-height: 1.3;
    text-transform: uppercase;
    opacity: 0.75;
}

.auth-mode-toggle {
    min-height: 35px;
    padding: 0 18px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.auth-mode-toggle:hover,
.auth-mode-toggle:focus-visible {
    background: #494949;
    color: #cbcbcb;
    opacity: 1;
}

.auth-mode-toggle:disabled {
    opacity: 0.55;
    cursor: wait;
}

.auth-feedback,
.account-feedback {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
}

.auth-feedback:empty,
.account-feedback:empty {
    display: none;
}

.auth-feedback:not(:empty),
.account-feedback:not(:empty) {
    margin-top: 2px;
}

.auth-feedback[data-state="error"],
.account-feedback[data-state="error"] {
    color: #9b2c2c;
}

.auth-feedback[data-state="success"],
.account-feedback[data-state="success"] {
    color: #21613f;
}

.auth-feedback[data-state="pending"],
.account-feedback[data-state="pending"] {
    opacity: 0.75;
}

.account-menu-list {
    display: grid;
    gap: 12px;
}

.account-menu-item {
    min-height: 46px;
    padding: 12px 16px;
    border: 1px solid #494949;
    border-radius: 14px;
    background: #f1f1f1;
    color: inherit;
    font: inherit;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
    background: #494949;
    color: #cbcbcb;
}

.account-menu-item:disabled {
    opacity: 0.72;
    cursor: wait;
    transform: none;
}

.account-menu-logout {
    background: #494949;
    color: #cbcbcb;
}

.account-menu-logout:hover,
.account-menu-logout:focus-visible {
    opacity: 0.86;
}

body.auth-open {
    overflow: hidden;
}

.page-placeholder {
    text-align: center;
    max-width: 680px;
    padding: 48px 24px;
}

.page-kicker {
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.8rem;
    opacity: 0.65;
}

.page-placeholder h1 {
    margin: 0;
    font-size: clamp(2.2rem, 6vw, 4.5rem);
    font-weight: 600;
}

.page-path {
    margin: 14px 0 0;
    font-size: 1rem;
    letter-spacing: 0.12em;
    opacity: 0.75;
}

.game-download-hero {
    display: grid;
    justify-items: center;
    gap: 34px;
}

.game-download-copy {
    display: grid;
    justify-items: center;
    gap: 16px;
}

.game-download-logo {
    display: block;
    width: min(180px, 42vw);
    height: auto;
}

.game-download-label {
    margin: 0;
    font-size: clamp(3rem, 9vw, 5.75rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 0.98;
}

.game-download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid #494949;
    border-radius: 12px;
    background: #494949;
    color: #cbcbcb;
    text-decoration: none;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: opacity 0.18s ease;
}

.game-download-button:hover,
.game-download-button:focus-visible {
    opacity: 0.86;
}

footer {
    border: 1px solid #494949;
    border-radius: var(--trivit-shell-radius);
    padding: 18px 28px 22px;
}

.footer-tabs ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 28px;
}

.footer-tabs li {
    cursor: pointer;
}

.footer-tabs a {
    display: block;
    padding: 8px 12px;
    color: #494949;
    text-decoration: none;
    transition: opacity 0.18s ease;
}

.footer-tabs a.active {
    text-decoration: underline;
    text-underline-offset: 0.3em;
}

.footer-tabs a:hover,
.footer-tabs a:focus-visible {
    opacity: 0.65;
}

@media (max-width: 820px) {
    header {
        flex-wrap: wrap;
    }

    .left {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .right {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .search-bar input,
    .search-bar.active input {
        width: min(286px, 70vw);
    }

    .auth-trigger {
        width: min(220px, 70vw);
    }

    .auth-panel,
    .account-panel {
        left: 16px;
        right: 16px;
        width: auto;
        padding: 18px 16px 18px;
    }

    .footer-tabs ul {
        flex-wrap: wrap;
        gap: 18px;
    }
}
