:root {
    --bg: #12111a;
    --panel: #1c1b27;
    --panel-2: #24222f;
    --line: #322f42;
    --ink: #f2f0f7;
    --muted: #9b96ad;
    --accent: #ffcb47;
    --accent-ink: #2a2200;
    --good: #5bd6a0;
    --warn: #ffa657;
    --bad: #ff7b7b;
    --radius: 12px;

    /* Tells the browser the page is dark, so the parts of form controls it draws itself —
       the password reveal button, number spinners, dropdown lists, autofill — come out dark
       too, instead of light-theme defaults sitting on a dark page. */
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

.site-header {
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
}

.brand {
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.2px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Title on the left, account links on the right, always on one line. */
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.account-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
    min-width: 0;
    font-size: 14px;
    white-space: nowrap;
}

/* The signed-in username. inline-block, not inline: max-width and the ellipsis only take effect
   on a box, and a long name would otherwise push the links off the line. */
.account-name {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

@media (max-width: 380px) {
    .brand {
        font-size: 15px;
    }

    .account-nav {
        gap: 10px;
        font-size: 13px;
    }
}

.inline-form {
    display: inline;
    margin: 0;
}

.auth-card {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.auth-card + .card.tight {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Auto-close timing --- */

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: var(--ink);
    margin: 4px 0 12px;
    cursor: pointer;
}

.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.duration-row {
    display: flex;
    gap: 10px;
    max-width: 320px;
}

.duration-row input[type="number"] {
    flex: 0 0 110px;
}

.duration-row select {
    flex: 1;
}

.countdown {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.card .countdown {
    background: var(--panel-2);
}

.countdown-label {
    color: var(--muted);
    font-size: 14px;
}

.countdown-time {
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.countdown.urgent {
    border-left-color: var(--bad);
}

.countdown.urgent .countdown-time {
    color: var(--bad);
}

.field-error {
    color: var(--bad);
    font-size: 13px;
    margin-top: 4px;
}

.hint {
    font-size: 13px;
    margin-top: 4px;
}

@media (max-width: 560px) {
    .account-name {
        display: none;
    }
}

.site-footer {
    border-top: 1px solid var(--line);
    padding: 14px 16px;
    text-align: center;
    font-size: 13px;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 4px;
}

h2 {
    font-size: 1.15rem;
    margin: 0 0 8px;
}

h3 {
    font-size: 1rem;
    margin: 0 0 6px;
}

a {
    color: var(--accent);
}

.muted {
    color: var(--muted);
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card.tight {
    padding: 14px 16px;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.row.between {
    justify-content: space-between;
}

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

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font-size: 15px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

input[type="text"]:disabled {
    opacity: 0.6;
}

/* Autofill. When the browser fills a saved email or password, it paints the field with its own
   light background and dark text, and ignores background-color to do it — so the sign-in boxes,
   the only ones on the site that get autofilled, stood out from every other text box. A large
   inset shadow covers that background in the site's own colour, and the text fill puts the ink
   back. Firefox's :autofill is a separate rule: a browser that doesn't recognise one selector in
   a list throws the whole rule away. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--ink);
    -webkit-box-shadow: 0 0 0 1000px var(--panel-2) inset;
    box-shadow: 0 0 0 1000px var(--panel-2) inset;
    caret-color: var(--ink);
    border-color: var(--line);
}

input:autofill {
    box-shadow: 0 0 0 1000px var(--panel-2) inset;
    color: var(--ink);
    filter: none;
}

button {
    font: inherit;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--ink);
    cursor: pointer;
}

button:hover:not(:disabled) {
    border-color: var(--accent);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button.primary {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
    font-weight: 600;
}

button.danger {
    border-color: var(--bad);
    color: var(--bad);
}

button.link {
    background: none;
    border: none;
    color: var(--muted);
    text-decoration: underline;
    padding: 4px 2px;
}

.pill {
    display: inline-block;
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--muted);
    white-space: nowrap;
}

.pill.good {
    color: var(--good);
    border-color: var(--good);
}

.pill.warn {
    color: var(--warn);
    border-color: var(--warn);
}

.pill.accent {
    color: var(--accent);
    border-color: var(--accent);
}

.alert {
    border-radius: 8px;
    padding: 10px 12px;
    margin: 10px 0;
    font-size: 14px;
    border: 1px solid var(--line);
    background: var(--panel-2);
}

.alert.bad {
    border-color: var(--bad);
    color: var(--bad);
}

.alert.good {
    border-color: var(--good);
    color: var(--good);
}

/* --- Movie search picker --- */

.picker {
    position: relative;
}

.results {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: 340px;
    overflow-y: auto;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.result {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
}

.result:last-child {
    border-bottom: none;
}

.result:hover:not(:disabled) {
    background: rgba(255, 203, 71, 0.12);
}

.result .thumb {
    width: 34px;
    height: 51px;
    flex: 0 0 34px;
    border-radius: 4px;
    background: var(--panel);
    object-fit: cover;
}

.result .taken {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
}

/* --- Suggestion slots --- */

.slot {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
    background: var(--panel);
}

.slot.filled {
    border-color: var(--good);
}

.slot-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.chosen {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chosen img {
    width: 46px;
    height: 69px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--panel-2);
}

/* --- Bracket --- */

/* Wide: details | film | VS | film | details — each film's details on its own outer side. */
.versus {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(140px, 180px) auto minmax(140px, 180px) minmax(0, 1fr);
    grid-template-areas: "details-a film-a vs film-b details-b";
    gap: 14px;
    align-items: start;
    margin-top: 14px;
}

.details-a {
    grid-area: details-a;
}

.details-b {
    grid-area: details-b;
}

.contender-a {
    grid-area: film-a;
}

.contender-b {
    grid-area: film-b;
}

.vs {
    grid-area: vs;
    align-self: center;
}

.movie-details {
    min-width: 0;
    font-size: 14px;
}

.movie-details-title {
    font-size: 1.05rem;
    margin: 0 0 6px;
    overflow-wrap: anywhere;
}

.movie-details-year {
    color: var(--muted);
    font-weight: 400;
    margin-left: 4px;
}

.movie-details-overview {
    margin: 0 0 6px;
    line-height: 1.5;
    color: var(--ink);
    /* Long summaries are clamped; "Read more" lifts it. */
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.movie-details-overview.expanded {
    display: block;
    -webkit-line-clamp: unset;
}

.movie-details-overview.muted {
    color: var(--muted);
}

.movie-details .link {
    display: block;
    padding: 0;
    margin-bottom: 8px;
    font-size: 13px;
}

.movie-details-link {
    font-size: 13px;
}

/* Narrower: five columns won't fit, so each film becomes a row — poster, then its details. */
@media (max-width: 820px) {
    .versus {
        grid-template-columns: minmax(96px, 140px) minmax(0, 1fr);
        grid-template-areas:
            "film-a details-a"
            "vs vs"
            "film-b details-b";
        gap: 12px 14px;
    }

    .vs {
        padding: 2px 0;
    }
}

.contender {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 12px;
    background: var(--panel-2);
    border: 2px solid var(--line);
    border-radius: var(--radius);
    text-align: center;
    min-height: 100%;
}

.contender:hover:not(:disabled) {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.contender img {
    width: 100%;
    max-width: 160px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 8px;
    background: var(--panel);
}

.contender .no-poster {
    width: 100%;
    max-width: 160px;
    aspect-ratio: 2 / 3;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-size: 28px;
}

.pick-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.contender:hover:not(:disabled) .pick-label {
    color: var(--accent);
}

.vs {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 1px;
}

.progress {
    height: 6px;
    background: var(--panel-2);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}

.progress > div {
    height: 100%;
    background: var(--accent);
}

/* --- Tables --- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    text-align: left;
    padding: 9px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.link-cell {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
}

.link-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.link-row .link-cell {
    flex: 1;
    min-width: 0;
}

button.copy {
    flex: 0 0 auto;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
}

button.copy.copied {
    border-color: var(--good);
    color: var(--good);
}

.winner-row td {
    color: var(--accent);
    font-weight: 600;
}

/* --- Error UI --- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bad);
    color: #2a0000;
    padding: 10px 16px;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #2a0000;
}

