@import './css/color-tokens.css';

:root {
    --space-1: clamp(0.4rem, 0.35rem + 0.25vw, 0.55rem);
    --space-2: clamp(0.7rem, 0.6rem + 0.35vw, 0.9rem);
    --space-3: clamp(0.95rem, 0.8rem + 0.5vw, 1.2rem);
    --space-4: clamp(1.2rem, 1rem + 0.7vw, 1.6rem);
    --space-5: clamp(1.6rem, 1.35rem + 1vw, 2.2rem);
    --space-6: clamp(2.1rem, 1.75rem + 1.4vw, 3rem);
    --space-7: clamp(2.75rem, 2.15rem + 2vw, 4.1rem);

    --radius-sm: 14px;
    --radius-md: 20px;
    --radius-lg: 32px;

    --font-size-body: clamp(0.98rem, 0.94rem + 0.18vw, 1.06rem);
    --font-size-small: clamp(0.82rem, 0.79rem + 0.12vw, 0.9rem);
    --font-size-eyebrow: clamp(0.72rem, 0.69rem + 0.1vw, 0.8rem);
    --font-size-heading: clamp(1.35rem, 1.1rem + 1vw, 2rem);
    --font-size-display: clamp(2.1rem, 1.6rem + 2.8vw, 4rem);

    --surface-overlay: linear-gradient(180deg, rgba(10, 12, 16, 0.3) 0%, rgba(10, 12, 16, 0.68) 35%, rgba(10, 12, 16, 0.94) 100%);
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--color-obsidian);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--font-size-body);
}

body {
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top, rgba(212, 171, 106, 0.08), transparent 34%),
        radial-gradient(circle at 20% 20%, rgba(131, 123, 167, 0.1), transparent 26%),
        var(--surface-overlay);
    pointer-events: none;
    z-index: -1;
}

a {
    color: var(--text-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

.page-shell {
    min-height: 100vh;
    padding: var(--space-3) var(--space-3) calc(6.5rem + env(safe-area-inset-bottom, 0px));
    position: relative;
}

.topbar,
.surface-card,
.hero-card,
.hero-panel,
.dialog-card,
.toast,
.user-menu-panel,
#components-reconnect-modal[open] {
    border: 1px solid var(--panel-light-border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 35%),
        var(--panel-mid);
    backdrop-filter: blur(var(--blur-panel));
    -webkit-backdrop-filter: blur(var(--blur-panel));
    box-shadow: var(--shadow-panel);
}

.topbar {
    position: relative;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    max-width: 1100px;
    margin: 0 auto var(--space-3);
    padding: 0.8rem 0;
    border-radius: var(--radius-pill);
    border: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}

.brand-link {
    display: inline-flex;
    flex-direction: column;
    gap: 0.15rem;
    color: var(--text-primary);
    font-family: var(--font-display);
    text-decoration: none;
}

.brand-link:hover {
    text-decoration: none;
}

.brand-kicker,
.eyebrow,
.card-label {
    font-size: var(--font-size-eyebrow);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-fog);
}

.brand-link strong {
    font-size: clamp(1.15rem, 1rem + 0.9vw, 1.65rem);
    line-height: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.shell-main {
    display: block;
}

.shell-content {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    gap: var(--space-4);
}

.shell-footer {
    position: fixed;
    left: 50%;
    bottom: max(0.8rem, env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: min(calc(100% - 1.5rem), 1100px);
    z-index: 40;
}

.surface-card,
.hero-card {
    border-radius: var(--radius-card);
}

.surface-card {
    padding: var(--space-4);
}

.hero-card {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(212, 171, 106, 0.14), transparent 28%);
    pointer-events: none;
}

.compact-hero {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.95fr);
}

.hero-copy,
.stack,
.form-stack,
.card-list,
.search-results,
.meta-list {
    display: grid;
    gap: var(--space-3);
}

.tight-stack {
    gap: 0.25rem;
}

.hero-copy h1,
.surface-card h1,
.surface-card h2,
.surface-card h3,
.hero-card h2 {
    margin-bottom: 0;
    font-family: var(--font-display);
    line-height: 0.96;
    letter-spacing: -0.025em;
}

.hero-copy h1 {
    font-size: var(--font-size-display);
    max-width: 12ch;
}

.surface-card h1 {
    font-size: clamp(2rem, 1.55rem + 2.2vw, 3rem);
}

.surface-card h2,
.hero-card h2 {
    font-size: var(--font-size-heading);
}

.surface-card h3 {
    font-size: clamp(1.05rem, 0.96rem + 0.45vw, 1.25rem);
}

.lede,
.muted-text,
.card-description,
.queue-description,
.art-description {
    color: var(--text-secondary);
}

.lede {
    font-size: clamp(1rem, 0.95rem + 0.45vw, 1.22rem);
    max-width: 52ch;
}

.hero-panel {
    display: grid;
    align-content: start;
    gap: var(--space-3);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
        rgba(15, 18, 23, 0.86);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: var(--space-3);
}

.page-header h1 {
    margin: 0.15rem 0 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 1.55rem + 2.2vw, 3.25rem);
    line-height: 0.96;
    letter-spacing: -0.03em;
    max-width: 15ch;
}

.panel-grid {
    display: grid;
    gap: var(--space-3);
}

.settings-grid,
.event-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-header-row,
.metric-row,
.inline-actions,
.search-row,
.form-grid,
.split-actions,
.auth-links {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    align-items: center;
}

.card-header-row {
    justify-content: space-between;
    align-items: start;
}

.metric-row {
    align-items: stretch;
}

.metric-pill {
    min-width: 96px;
    flex: 1 1 0;
    padding: 1rem 1.05rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-light-border);
    display: grid;
    gap: 0.3rem;
    justify-items: center;
}

.metric-pill--record {
    flex: 2 1 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.metric-sub {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 1rem 1.05rem;
}

.metric-record-divider {
    width: 1px;
    align-self: stretch;
    background: var(--panel-light-border);
    flex-shrink: 0;
}

.metric-value {
    font-family: var(--font-display);
    font-size: clamp(1.55rem, 1.3rem + 1.1vw, 2.25rem);
    color: var(--text-primary);
    line-height: 1;
}

.metric-label {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.72rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.82rem 1.1rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease;
    text-decoration: none;
    min-height: 46px;
    font-family: var(--font-body);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.button:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.button:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.primary-button {
    background: linear-gradient(180deg, rgba(240, 139, 88, 0.95) 0%, rgba(225, 110, 62, 0.92) 100%);
    color: #fffaf4;
    border-color: rgba(255, 214, 184, 0.14);
    box-shadow: 0 10px 22px rgba(225, 110, 62, 0.18);
}

.ghost-button {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.subtle-button {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: rgba(245, 236, 226, 0.92);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.subtle-button:hover,
.ghost-button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}

.button-inline {
    gap: 0.55rem;
}

.field-label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.field-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.95rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--panel-light-border);
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
    transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.field-input::placeholder {
    color: rgba(231, 236, 244, 0.56);
}

.field-input:focus {
    outline: none;
    border-color: rgba(240, 139, 88, 0.9);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(225, 110, 62, 0.18);
}

textarea.field-input {
    min-height: 120px;
    resize: vertical;
}

.validation-message,
.validation-message * {
    color: #ffb4a3;
    font-size: 0.84rem;
}

.auth-card,
.narrow-card {
    max-width: 680px;
}

.auth-card {
    margin-inline: auto;
}

.auth-shell {
    display: grid;
    gap: var(--space-4);
}

.auth-hero {
    min-height: clamp(180px, 30vw, 260px);
}

.auth-hero .hero-copy h1 {
    max-width: 11ch;
}

.auth-links {
    justify-content: space-between;
}

.notice {
    padding: 0.95rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
}

.notice-success {
    background: rgba(107, 140, 123, 0.16);
    border-color: rgba(107, 140, 123, 0.28);
}

.notice-warning {
    background: rgba(212, 171, 106, 0.14);
    border-color: rgba(212, 171, 106, 0.3);
}

.notice-error {
    background: rgba(225, 110, 62, 0.14);
    border-color: rgba(225, 110, 62, 0.28);
}

.pending-match-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.pending-match-alert p {
    margin: 0.2rem 0 0;
}

@media (max-width: 640px) {
    .pending-match-alert {
        align-items: stretch;
        flex-direction: column;
    }
}

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.42rem 0.8rem;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    border: 1px solid transparent;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chip-success {
    background: rgba(107, 140, 123, 0.18);
    color: #d4eadb;
    border-color: rgba(107, 140, 123, 0.35);
}

.chip-warning {
    background: rgba(212, 171, 106, 0.16);
    color: #f8deaf;
    border-color: rgba(212, 171, 106, 0.28);
}

.chip-error {
    background: rgba(225, 110, 62, 0.16);
    color: #ffc1a9;
    border-color: rgba(225, 110, 62, 0.32);
}

.chip-highlight {
    background: rgba(131, 123, 167, 0.18);
    color: #e0d9fb;
    border-color: rgba(131, 123, 167, 0.32);
}

.chip-muted {
    background: rgba(180, 188, 203, 0.1);
    color: var(--text-secondary);
    border-color: rgba(180, 188, 203, 0.2);
}

.event-card,
.match-card {
    padding: var(--space-4);
}

.match-card-priority {
    border-left: 3px solid rgba(131, 123, 167, 0.72);
    background: rgba(131, 123, 167, 0.08);
}

.event-card.event-card-stack {
    display: grid;
    gap: var(--space-3);
}

/* Collapsible event list (Events page) */
.event-list {
    display: grid;
    gap: var(--space-3);
}

.event-list-card {
    display: grid;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.event-list-trigger {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: var(--space-4);
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    text-align: left;
}

.event-list-trigger:hover {
    background: rgba(255, 255, 255, 0.03);
}

.event-list-summary {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    min-width: 0;
}

.event-list-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 1rem + 0.5vw, 1.4rem);
    line-height: 1.1;
}

.event-list-chevron {
    flex-shrink: 0;
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-top: -0.2rem;
    opacity: 0.6;
}

.event-list-card.is-expanded .event-list-chevron {
    transform: rotate(-135deg);
    margin-top: 0.15rem;
}

.event-list-detail {
    display: grid;
    gap: var(--space-3);
    padding: 0 var(--space-4) var(--space-3);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.event-list-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.events-archive-link {
    padding-top: var(--space-2);
    display: flex;
    justify-content: center;
}

.event-title-block {
    display: grid;
    gap: 0.55rem;
}

.event-title-block h2 {
    max-width: 16ch;
}

.event-summary {
    display: grid;
    gap: var(--space-2);
}

.detail-grid,
.match-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.detail-item,
.match-meta-item {
    display: grid;
    gap: 0.25rem;
    padding: 0.95rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-item span:first-child,
.match-meta-item span:first-child {
    font-size: var(--font-size-small);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.detail-item strong,
.match-meta-item strong {
    font-size: 0.98rem;
    line-height: 1.35;
}

.player-chip-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.player-chip {
    display: grid;
    gap: 0.1rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.player-chip small,
.result-row small,
.toast-message,
.user-menu-summary small {
    color: var(--text-secondary);
}

.player-chip-self {
    border-color: rgba(225, 110, 62, 0.35);
    background: rgba(225, 110, 62, 0.08);
}

.player-chip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.player-chip-challenge {
    flex-shrink: 0;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    color: rgba(231, 236, 244, 0.75);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.player-chip-challenge:hover:not(:disabled) {
    background: rgba(240, 139, 88, 0.15);
    border-color: rgba(240, 139, 88, 0.4);
    color: #fff7ed;
}

.player-chip-challenge:disabled {
    opacity: 0.4;
    cursor: default;
}

.result-row {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 1rem 1.05rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    color: var(--text-primary);
}

.result-row:hover {
    background: rgba(255, 255, 255, 0.1);
}

.result-row span {
    display: grid;
    gap: 0.18rem;
}

.result-row-action {
    align-self: center;
    color: var(--text-accent);
    font-family: var(--font-display);
}

.result-form {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    gap: var(--space-3);
}

.form-grid > div {
    flex: 1 1 180px;
}

.checkbox-row,
.checkbox-helper {
    display: flex;
    align-items: start;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.checkbox-row {
    padding: 1rem 1.05rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

.checkbox-row span {
    display: grid;
    gap: 0.2rem;
}

.checkbox-input {
    margin-top: 0.25rem;
    width: 1.1rem;
    height: 1.1rem;
}

.meta-list p,
.card-details p {
    margin-bottom: 0;
}

.wrap-actions {
    justify-content: flex-start;
}

.compact-card {
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
}

.status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 1rem 1.05rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
}

.status-banner-copy {
    display: grid;
    gap: 0.3rem;
}

.status-banner-copy h3 {
    margin: 0;
}

.token-panel {
    margin-top: var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.06);
    border: 1px dashed rgba(212, 171, 106, 0.35);
    display: grid;
    gap: var(--space-2);
}

.token-panel code {
    display: inline-block;
    padding: 0.65rem 0.8rem;
    border-radius: 12px;
    background: rgba(15, 18, 23, 0.92);
    color: #fff4e6;
    overflow-wrap: anywhere;
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-flex;
    flex: 0 0 auto;
    vertical-align: middle;
}

.spinner-inline {
    margin-right: 0.5rem;
}

.spinner-sm {
    width: 0.875rem;
    height: 0.875rem;
}

.spinner-muted {
    border-top-color: var(--text-secondary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: min(100% - 2rem, 24rem);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: grid;
    gap: 0.55rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: currentColor;
    opacity: 0.85;
}

.toast-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
}

.toast-actions {
    display: flex;
    justify-content: flex-end;
}

.toast-dismiss {
    min-height: 40px;
    padding: 0.55rem 0.9rem;
    font-size: 0.82rem;
}

.toast-success {
    color: #d4eadb;
}

.toast-error {
    color: #ffc1a9;
}

.toast-warning {
    color: #f8deaf;
}

.toast-info {
    color: #e0d9fb;
}

#blazor-error-ui {
    background: rgba(54, 38, 27, 0.94);
    color: #fff6e9;
    bottom: 1rem;
    box-shadow: var(--shadow-panel);
    display: none;
    left: 1rem;
    padding: 0.85rem 1rem;
    position: fixed;
    right: 1rem;
    z-index: 1000;
    border-radius: var(--radius-md);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    gap: 0.6rem;
    padding-inline: 0.7rem 1rem;
    min-width: 0;
}

.user-menu-text {
    display: grid;
    gap: 0.05rem;
    text-align: left;
}

.user-menu-text strong {
    max-width: 14ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-badge {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-ember) 100%);
    color: #fff8f2;
    font-family: var(--font-display);
    letter-spacing: 0.04em;
}

.user-menu-panel {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    min-width: 220px;
    padding: 0.7rem;
    border-radius: var(--radius-md);
    display: grid;
    gap: 0.3rem;
    z-index: 20;
}

.user-menu-summary {
    display: grid;
    gap: 0.15rem;
    padding: 0.4rem 0.5rem 0.55rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.25rem;
}

.user-menu-link {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    padding: 0.75rem 0.8rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-primary);
    text-decoration: none;
}

.user-menu-link:hover {
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
}

.user-menu-button {
    cursor: pointer;
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 14, 0.45);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 10000;
}

.dialog-card {
    width: min(100%, 30rem);
    display: grid;
    gap: 0.9rem;
}

.dialog-card h2,
.dialog-card p {
    margin-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 1.6s;
    }

    .button,
    .result-row,
    .field-input {
        transition: none;
    }
}

@media (max-width: 860px) {
    .compact-hero,
    .settings-grid,
    .event-grid,
    .detail-grid,
    .match-meta-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 0.75rem 0.75rem calc(8rem + env(safe-area-inset-bottom, 0px));
    }

    .topbar,
    .page-header,
    .card-header-row,
    .status-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar {
        padding: 0.25rem 0 0.5rem;
    }

    .topbar-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .hero-card {
        padding: var(--space-4);
    }

    .surface-card,
    .hero-panel {
        padding: var(--space-3);
    }

    .page-header h1,
    .hero-copy h1 {
        max-width: 100%;
    }

    .hero-panel .button,
    .inline-actions .button,
    .search-row .button,
    .page-header .button,
    .split-actions > * {
        width: 100%;
    }

    .search-row,
    .auth-links {
        flex-direction: column;
        align-items: stretch;
    }

    .result-row {
        flex-direction: column;
        align-items: start;
    }

    .toast-container {
        top: 0.75rem;
        right: 0.75rem;
        width: calc(100% - 1.5rem);
    }

    .user-menu-panel {
        left: 0;
        right: 0;
        min-width: 0;
    }
}

@media (max-width: 420px) {
    .page-shell {
        padding-inline: 0.65rem;
    }

    .metric-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-pill:last-child:nth-child(odd),
    .metric-pill--record {
        grid-column: 1 / -1;
    }

    .topbar-actions > * {
        width: 100%;
    }

    .topbar-actions .chip,
    .topbar-actions .button,
    .topbar-actions .user-menu-trigger {
        justify-content: center;
    }
}

/* Dispute resolution section */
.dispute-details {
    margin-top: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: rgba(225, 110, 62, 0.07);
    border: 1px solid rgba(225, 110, 62, 0.22);
    display: grid;
    gap: var(--space-2);
}

.dispute-submissions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-2);
}

.dispute-submission {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    gap: 0.3rem;
}

/* Data tables (standings) */
.table-shell {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-small);
}

.data-table thead {
    background: rgba(255, 255, 255, 0.04);
}

.data-table th {
    padding: 0.9rem 1rem;
    text-align: left;
    font-size: var(--font-size-eyebrow);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.data-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.standings-table .rank-col {
    width: 2.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 700;
}

/* Standings accordion list */
.standings-card {
    padding: 0;
    overflow: hidden;
}

.standings-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.standings-col-label {
    font-size: var(--font-size-eyebrow);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    flex: 1;
    padding-left: 2.8rem;
}

.standings-col-pts {
    flex: 0 0 3.5rem;
    text-align: center;
    padding-left: 0;
}

.standings-col-record {
    flex: 0 0 4.5rem;
    text-align: center;
    padding-left: 0;
}

.standings-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.standings-entry {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.standings-entry:first-child {
    border-top: none;
}

.standings-entry--me {
    background: rgba(251, 146, 60, 0.05);
}

.standings-entry--me .standings-name {
    color: #fb923c;
}

.standings-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.85rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    text-align: left;
}

.standings-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.standings-rank {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    width: 1.8rem;
    flex-shrink: 0;
    text-align: right;
}

.standings-player {
    flex: 1;
    min-width: 0;
}

.standings-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.standings-you-badge {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.4);
    border-radius: 3px;
    padding: 1px 4px;
    flex-shrink: 0;
    font-family: var(--font-body);
}

.standings-pts {
    font-family: var(--font-display);
    font-size: 1.05rem;
    white-space: nowrap;
    flex: 0 0 3.5rem;
    text-align: center;
}

.standings-pts-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.standings-record {
    font-family: var(--font-display);
    font-size: 0.92rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex: 0 0 4.5rem;
    text-align: center;
}

.standings-chevron {
    flex-shrink: 0;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-top: -0.15rem;
    opacity: 0.45;
}

.standings-entry.is-open .standings-chevron {
    transform: rotate(-135deg);
    margin-top: 0.1rem;
}

.standings-detail {
    padding: 0.75rem 1rem 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.02);
}

.standings-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1.5rem;
    margin: 0;
    padding: 0;
}

.standings-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.standings-stat dt {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.standings-stat dd {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--text-primary);
}

/* Admin table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm, 0.875rem);
}

.admin-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: var(--text-xs, 0.75rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted, #6b7280);
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.admin-table td {
    padding: 0.625rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

/* Match progress bar */
.match-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.match-progress-bar-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    overflow: hidden;
}

.match-progress-bar-fill {
    height: 100%;
    background: var(--color-accent, #f97316);
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 4px;
}

.match-progress-label {
    font-size: var(--font-size-small);
    color: var(--text-muted);
}
