:root {
    color-scheme: dark;
    --bg: #14161f;
    --panel: #1e2130;
    --panel-2: #262a3d;
    --text: #eef0f6;
    --muted: #8b8fa3;
    --accent: #e8c974;
    --accent-2: #6c8ef5;
    --danger: #e0685f;
    --ok: #6fcf97;
    --border: #33374a;
    font-size: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding-bottom: 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.1rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
}

.topnav { display: flex; align-items: center; gap: 0.8rem; font-size: 0.9rem; color: var(--muted); }

.badge {
    background: var(--accent);
    color: #1a1d29;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.container { max-width: 720px; margin: 0 auto; padding: 1rem; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.header-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

h1 { font-size: 1.4rem; margin: 0 0 0.3rem 0; }
h2 { font-size: 1.05rem; margin: 0 0 0.7rem 0; color: var(--accent); }

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

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.3rem;
}

.center-card { max-width: 380px; margin: 2rem auto; }

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

.stack { display: flex; flex-direction: column; gap: 0.9rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }

input {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.65rem 0.7rem;
    border-radius: 8px;
    font-size: 1rem;
}

button, .btn, .link-btn {
    background: var(--accent);
    color: #1a1d29;
    border: none;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.link-btn { background: none; color: var(--accent-2); padding: 0; font-weight: 500; }

.tournament-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }

.tournament-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.4rem 0.4rem 0.4rem 1rem;
}

.tournament-link {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
    padding: 0.4rem 0;
    min-width: 0;
}

.t-name { font-weight: 600; }
.t-name-block { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }

.icon-btn {
    background: none;
    color: var(--muted);
    padding: 0.5rem 0.7rem;
    font-size: 1rem;
    line-height: 1;
}
.icon-btn:hover { color: var(--danger); }

.status { font-size: 0.8rem; padding: 0.2rem 0.55rem; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.status-in_progress { color: var(--accent-2); }
.status-finished { color: var(--ok); }

.player-list { padding-left: 1.2rem; margin: 0 0 1rem 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem; padding: 0.4rem; border-bottom: 1px solid var(--border); }
td { padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr.me { background: rgba(232, 201, 116, 0.08); }
td.me { font-weight: 700; color: var(--accent); }

.matches .vs { color: var(--muted); text-align: center; width: 1.5rem; }

.report-form { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.report-form button { font-size: 0.8rem; padding: 0.4rem 0.55rem; }

.pill { background: var(--panel-2); color: var(--muted); font-size: 0.78rem; padding: 0.25rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.pill-done { color: var(--ok); }
.pill-pending { color: var(--muted); }

.admin-actions { margin-top: 1rem; display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

.table-scroll { overflow-x: auto; margin-bottom: 0.8rem; }

.rr-round-title { font-size: 0.85rem; color: var(--muted); margin: 1rem 0 0.4rem 0; text-transform: uppercase; letter-spacing: 0.05em; }
.rr-round-title:first-of-type { margin-top: 0; }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 10rem; }

.share-code { font-family: ui-monospace, monospace; letter-spacing: 0.15em; margin-bottom: 0; }
#share-url { font-family: ui-monospace, monospace; font-size: 0.85rem; }

.radio-group { border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem 0.8rem; margin: 0; }
.radio-group legend { padding: 0 0.3rem; font-size: 0.85rem; color: var(--muted); }
.radio-option { flex-direction: row; align-items: flex-start; gap: 0.5rem; font-size: 0.95rem; color: var(--text); margin-top: 0.4rem; }
.radio-option:first-of-type { margin-top: 0; }
.radio-option input { width: auto; margin-top: 0.2rem; }

.small { font-size: 0.78rem; }

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tab {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}
.tab-active { background: var(--accent); color: #1a1d29; border-color: var(--accent); }

@media (max-width: 480px) {
    table.matches thead { display: none; }
    table.matches tr { display: flex; flex-wrap: wrap; align-items: center; padding: 0.5rem 0; gap: 0.3rem 0; }
    table.matches td { border-bottom: none; padding: 0.2rem 0.3rem; }
    table.matches td.result-cell { flex-basis: 100%; padding-top: 0.4rem; }
}
