body {
    color-scheme: light;
    --site-background: #f7f8fa;
    --site-foreground: #24262c;
    --site-muted: #555b66;
    --site-header-background: #ffffff;
    --site-border: #d9dce3;
    --site-control-hover: #e9edf4;
    --site-accent: #1d5bd6;
    --site-accent-hover: #1749b0;
    --site-accent-ink: #ffffff;
    --site-accent-tint: #eef3fe;
    --site-effect-ok: #107c10;
    --colorBrandBackground: #1d5bd6;
    --colorBrandBackgroundHover: #1749b0;
    --colorBrandBackgroundPressed: #123c94;
    --colorBrandBackgroundSelected: #1749b0;
    --colorBrandBackground2: #eef3fe;
    --colorBrandForeground1: #1d5bd6;
    --colorBrandForegroundLink: #1d5bd6;
    --colorBrandStroke1: #1d5bd6;
    --colorNeutralForegroundOnBrand: #ffffff;
    margin: 0;
    font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    line-height: 1.6;
    background: var(--site-background);
    color: var(--site-foreground);
}

body[data-theme="dark"] {
    color-scheme: dark;
    --site-background: #17191d;
    --site-foreground: #edf0f5;
    --site-muted: #a8b0bf;
    --site-header-background: #202328;
    --site-border: #3a3e47;
    --site-control-hover: #343a45;
    --site-accent: #7ea8ff;
    --site-accent-hover: #96b8ff;
    --site-accent-ink: #0f172a;
    --site-accent-tint: #1f2a40;
    --site-effect-ok: #facc15;
    --colorBrandBackground: #3b74e8;
    --colorBrandBackgroundHover: #4f84f0;
    --colorBrandBackgroundPressed: #2d62cf;
    --colorBrandBackgroundSelected: #4f84f0;
    --colorBrandBackground2: #1f2a40;
    --colorBrandForeground1: #7ea8ff;
    --colorBrandForegroundLink: #7ea8ff;
    --colorBrandStroke1: #7ea8ff;
    --colorNeutralForegroundOnBrand: #ffffff;
}

h1:focus {
    outline: none;
}

a:focus-visible,
button:focus-visible,
fluent-button:focus-visible {
    outline: 2px solid var(--site-accent);
    outline-offset: 2px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--site-border);
    background: var(--site-header-background);
    color: var(--site-foreground);
    cursor: pointer;
    transition: background-color 120ms ease;
}

.theme-toggle:hover {
    background: var(--site-control-hover);
}

.page-hero-logo {
    display: block;
    height: clamp(2.25rem, 4vw, 2.75rem);
    width: auto;
    max-width: 100%;
}

.ad-slot {
    display: block;
    min-height: 0;
}

.site-info {
    flex: none;
    width: min(100% - 2rem, 52rem);
    margin-inline: auto;
    padding-block: clamp(1.5rem, 4vw, 2.5rem);
}

.site-info h2 {
    margin-block: 1.5rem 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.3;
}

.status-page {
    width: min(100% - 2rem, 38rem);
    margin: clamp(2rem, 6vw, 4rem) auto;
    padding: 2rem;
    border-radius: 14px;
    background: var(--site-header-background);
    border: 1px solid var(--site-border);
}

.status-page h1 {
    margin: 0 0 0.65rem;
    font-size: 1.6rem;
    letter-spacing: -0.02em;
}

.status-page p {
    margin: 0;
    color: var(--site-muted);
}

.status-actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.status-link-primary,
.status-link-secondary {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.925rem;
    text-decoration: none;
}

.status-link-primary {
    background: var(--colorBrandBackground);
    color: var(--colorNeutralForegroundOnBrand);
}

.status-link-primary:hover {
    background: var(--colorBrandBackgroundHover);
}

.status-link-secondary {
    border: 1px solid var(--site-border);
    background: var(--site-header-background);
    color: var(--site-foreground);
}

.status-link-secondary:hover {
    background: var(--site-control-hover);
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Online features: nicknames, challenges, duels, announcement, consent, ad placeholders */
.ad-slot[hidden] {
    display: none;
}

.ad-slot-placeholder {
    display: grid;
    place-items: center;
    min-height: 4rem;
    border: 1px dashed var(--site-border);
    border-radius: 0.5rem;
    color: var(--site-muted);
    font-size: 0.85rem;
}

.announcement-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1rem;
    background: var(--site-accent-tint);
    border-bottom: 1px solid var(--site-border);
    color: var(--site-foreground);
    font-size: 0.95rem;
}

.consent-banner {
    position: fixed;
    inset: auto 1rem 1rem 1rem;
    z-index: 1000;
    max-width: 40rem;
    margin-inline: auto;
    padding: 1rem;
    background: var(--site-header-background);
    border: 1px solid var(--site-border);
    border-radius: 0.75rem;
    box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}

.consent-banner p {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.consent-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.consent-actions button {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--site-border);
    border-radius: 0.4rem;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.consent-actions button[data-consent="granted"] {
    background: var(--site-accent);
    border-color: var(--site-accent);
    color: var(--site-accent-ink);
}

.form-error {
    color: #b3261e;
    margin: 0.4rem 0;
    font-size: 0.9rem;
}

.form-ok {
    color: #1b7a3a;
    margin: 0.4rem 0;
    font-size: 0.9rem;
}

body[data-theme="dark"] .form-error {
    color: #ff8a80;
}

body[data-theme="dark"] .form-ok {
    color: #7bd88f;
}

.nickname-panel {
    width: 100%;
    box-sizing: border-box;
    margin: 0.25rem 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--site-border);
    border-radius: 10px;
    background: var(--site-header-background);
    text-align: left;
}

.game-modal-card .nickname-panel {
    background: var(--site-background);
}

.nickname-panel summary {
    cursor: pointer;
    font-size: 0.92rem;
}

.nickname-badge {
    margin-left: 0.5rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--site-accent-tint);
    font-size: 0.8rem;
}

.nickname-body {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.85rem;
}

.nickname-group {
    display: grid;
    gap: 0.35rem;
}

.nickname-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}

.nickname-field {
    flex: 1 1 14rem;
    min-width: 0;
    max-width: 24rem;
}

.nickname-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.nickname-field > *,
.duel-join-field > * {
    width: 100%;
    margin-block: 0 !important;
}

.nickname-field fluent-text-input,
.duel-join-field fluent-text-input {
    width: 100%;
}

.nickname-hint {
    margin: 0;
    color: var(--site-muted);
    font-size: 0.85rem;
}

.challenge-create,
.challenge-comparison,
.duel-status {
    width: 100%;
    margin: 0.75rem 0;
    display: grid;
    gap: 0.5rem;
    justify-items: center;
}

.challenge-hint {
    margin: 0;
    max-inline-size: 40ch;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--site-muted);
}

.challenge-link-label {
    font-size: 0.85rem;
    color: var(--site-muted);
}

.challenge-link-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--site-border);
    border-radius: 0.4rem;
    background: var(--site-background);
    color: inherit;
    font: inherit;
    font-size: 0.9rem;
    text-align: center;
}

.duel-section {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    width: min(100% - 2rem, 72rem);
    margin-inline: auto;
    padding-block: 1rem;
    gap: 0.75rem;
}

.duel-menu,
.duel-lobby {
    display: grid;
    gap: 0.75rem;
    justify-items: start;
}

.duel-join {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
}

.duel-join-field {
    flex: 0 1 14rem;
    min-width: 12rem;
}

.duel-code {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    font-variant-numeric: tabular-nums;
    padding: 0.2rem 0.7rem;
    border-radius: 8px;
    background: var(--site-background);
    border: 1px solid var(--site-border);
    line-height: 1.25;
}

.duel-lobby-card {
    display: grid;
    gap: 1.25rem;
    width: min(100%, 42rem);
    padding: 1.5rem;
    border: 1px solid var(--site-border);
    border-radius: 14px;
    background: var(--site-header-background);
}

.duel-lobby-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.duel-code-block {
    display: grid;
    gap: 0.35rem;
}

.duel-code-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--site-muted);
}

.duel-code-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}

.duel-rule-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--site-border);
    background: var(--site-background);
    color: var(--site-muted);
    font-size: 0.84rem;
}

.duel-share-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}

.duel-share-field {
    flex: 1 1 18rem;
    min-width: 0;
}

.duel-share-field > * {
    width: 100%;
    margin-block: 0 !important;
}

.duel-share-field fluent-text-input {
    width: 100%;
}

.duel-players-section {
    display: grid;
    gap: 0.65rem;
}

.duel-players-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.duel-players-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--site-muted);
}

.duel-players-count {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--site-background);
    border: 1px solid var(--site-border);
    color: var(--site-muted);
    font-variant-numeric: tabular-nums;
}

.duel-players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.75rem;
}

.duel-player-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--site-border);
    background: var(--site-background);
    transition: border-color 150ms ease;
}

.duel-player-card.is-you {
    border-color: color-mix(in srgb, var(--site-accent) 45%, var(--site-border));
}

.duel-player-card.is-ready {
    border-color: #1f9d55;
}

.duel-player-empty {
    border-style: dashed;
    background: transparent;
}

.duel-player-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: var(--site-accent-tint);
    color: var(--site-accent);
}

.duel-player-avatar-empty {
    background: var(--site-control-hover);
    color: var(--site-muted);
}

.duel-player-info {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    flex: 1 1 auto;
}

.duel-player-name-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.duel-player-name {
    font-weight: 600;
    font-size: 0.96rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duel-you-badge {
    flex: 0 0 auto;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: var(--site-accent-tint);
    color: var(--site-accent);
    font-size: 0.74rem;
    font-weight: 600;
}

.duel-player-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    color: var(--site-muted);
}

.duel-player-status.ready {
    color: #1f9d55;
    font-weight: 600;
}

body[data-theme="dark"] .duel-player-status.ready {
    color: #5ee39a;
}

.duel-player-status.disconnected {
    color: #d64545;
    font-weight: 600;
}

body[data-theme="dark"] .duel-player-status.disconnected {
    color: #ff8a80;
}

.duel-player-empty-text {
    font-size: 0.9rem;
    color: var(--site-muted);
}

.duel-lobby-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--site-border);
}

.duel-lobby-waiting-hint {
    font-size: 0.88rem;
    color: var(--site-muted);
}

.duel-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--site-border);
    border-radius: 0.5rem;
    background: var(--site-header-background);
    font-variant-numeric: tabular-nums;
}

.duel-countdown {
    font-size: clamp(2rem, 8vw, 4rem);
}

/* Duel: while a game is running the arena fills the view like the solo game; only the status bar sits above it. */
.duel-section-playing {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    gap: 0;
}

.duel-section-playing .duel-bar {
    flex: 0 0 auto;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1rem;
    border-width: 0 0 1px;
    border-radius: 0;
}

.duel-bar-room {
    color: var(--site-muted);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

.duel-section-playing .game-shell {
    flex: 1 1 auto;
    min-height: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Shared by /pelaa, /haaste/{code} and /kaksinpeli: the arena section fills the space under the header. */
.play-arena-section {
    flex: 1 1 100%;
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Live versus panel in the top-right corner of the arena. */
.duel-versus {
    position: absolute;
    top: 6.5rem;
    right: 0.75rem;
    z-index: 5;
    min-width: 12rem;
    padding: 0.55rem 0.75rem;
    display: grid;
    gap: 0.3rem;
    border: 1px solid var(--site-border);
    border-radius: 0.6rem;
    background: color-mix(in srgb, var(--site-header-background) 88%, transparent);
    backdrop-filter: blur(4px);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.duel-versus-lead {
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.4rem;
    background: var(--site-control-hover);
}

.duel-versus.leading { border-color: #1f9d55; }
.duel-versus.leading .duel-versus-lead { background: rgba(31, 157, 85, 0.22); color: #2ecc71; }
.duel-versus.trailing { border-color: #d64545; }
.duel-versus.trailing .duel-versus-lead { background: rgba(214, 69, 69, 0.22); color: #ff6b6b; }

.duel-versus-row {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 0.75rem;
    align-items: baseline;
}

.duel-versus-name {
    font-size: 0.8rem;
    color: var(--site-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 9rem;
}

.duel-versus-score {
    font-size: 1.35rem;
    font-weight: 700;
    text-align: right;
}

.duel-versus-meta {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    color: var(--site-muted);
}

.duel-versus-me .duel-versus-name { color: var(--site-foreground); font-weight: 600; }

.duel-result-banner {
    display: grid;
    gap: 0.1rem;
    justify-items: center;
    padding: 0.6rem 1rem;
    border-radius: 0.6rem;
    margin-bottom: 0.75rem;
    background: var(--site-control-hover);
}

.duel-result-banner strong { font-size: 1.3rem; }
.duel-result-banner.win { background: rgba(31, 157, 85, 0.2); color: #2ecc71; }
.duel-result-banner.lose { background: rgba(214, 69, 69, 0.2); color: #ff6b6b; }

.duel-result-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.duel-result-table th,
.duel-result-table td {
    padding: 0.35rem 0.6rem;
    text-align: center;
    border-bottom: 1px solid var(--site-border);
}

.duel-result-table tbody th { text-align: left; font-weight: 500; color: var(--site-muted); }
.duel-result-table td.better { font-weight: 700; color: #2ecc71; }

.duel-bar-hint { color: var(--site-muted); font-size: 0.85rem; }
.duel-bar-hint-hot { color: #2ecc71; font-weight: 600; }

/* Duel result effects: fireworks + celebrating character for the winner, a sad little character for the loser. */

.duel-fx { pointer-events: none; }

.duel-fireworks {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    width: 100%;
    height: 9.25rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
}

.duel-winner-svg {
    position: relative;
    z-index: 1;
}

.win-person { animation: win-bounce 1.4s ease-in-out infinite; transform-origin: 60px 144px; }
.win-trophy { animation: win-trophy-lift 1.4s ease-in-out infinite; transform-origin: 60px 24px; }
.win-sparkle { animation: win-twinkle 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.win-sparkle.s2 { animation-delay: 0.8s; }

@keyframes win-bounce {
    0%, 100% { transform: translateY(0) scaleY(1); }
    45% { transform: translateY(-6px) scaleY(1.02); }
    65% { transform: translateY(-5px) scaleY(1.01); }
}

@keyframes win-trophy-lift {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

@keyframes win-twinkle {
    0%, 100% { opacity: 0.25; transform: scale(0.7); }
    50% { opacity: 1; transform: scale(1.15); }
}

.fw-burst {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 0;
    height: 0;
    z-index: 0;
}

.fw-burst i {
    position: absolute;
    left: 0;
    top: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 8px var(--c);
    opacity: 0;
    animation: fw-fly 1.8s ease-out 4 both;
    animation-delay: var(--delay);
}

@keyframes fw-fly {
    0% { opacity: 1; transform: rotate(var(--a)) translateX(0) scale(1); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: rotate(var(--a)) translateX(70px) translateY(18px) scale(0.3); }
}

.duel-sad {
    display: flex;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.sad-person { animation: sad-sway 4s ease-in-out infinite; transform-origin: 60px 140px; }
.sad-head { transform-origin: 60px 54px; animation: sad-nod 3.2s ease-in-out infinite; }
.sad-upper { transform-origin: 60px 100px; animation: sad-slump 3.2s ease-in-out infinite; }
.tear { animation: sad-tear 1.6s ease-in infinite; }
.tear.t2 { animation-delay: 0.5s; }

@keyframes sad-nod {
    0%, 100% { transform: rotate(14deg) translateY(2px); }
    50% { transform: rotate(20deg) translateY(4px); }
}

@keyframes sad-slump {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.98) translateY(1px); }
}

@keyframes sad-sway {
    0%, 100% { transform: rotate(-1.5deg); }
    50% { transform: rotate(1.5deg); }
}

@keyframes sad-tear {
    0% { opacity: 0; transform: translateY(0); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateY(22px); }
}

@media (prefers-reduced-motion: reduce) {
    .fw-burst i, .win-person, .win-trophy, .win-sparkle, .sad-person, .sad-head, .sad-upper, .tear { animation: none; }
    .fw-burst i { opacity: 0.8; transform: rotate(var(--a)) translateX(40px); }
}
