/* Compact UI overrides for Pico CSS */
:root {
    --pico-block-spacing-vertical: 0.75rem;
    --pico-block-spacing-horizontal: 0.75rem;
    --pico-typography-spacing-vertical: 0.75rem;
}

nav.container {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

main.container {
    padding-top: 0.5rem;
    padding-bottom: 1rem;
}

h1 { margin-bottom: 0.5rem; font-size: 1.6rem; }
h2 { margin-bottom: 0.4rem; font-size: 1.3rem; }
h3 { margin-bottom: 0.3rem; font-size: 1.1rem; }

hgroup {
    margin-bottom: 0.75rem;
}
hgroup > p {
    margin-top: 0.1rem;
}

article {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}
article > header {
    padding: 0.5rem 0.75rem;
    margin: -0.75rem -0.75rem 0.5rem;
}

table th, table td {
    padding: 0.35rem 0.5rem;
}

table.compact-table th, table.compact-table td {
    padding: 0.1rem 0.4rem;
    font-size: 0.78rem;
}

fieldset {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
}

label {
    margin-bottom: 0.25rem;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    margin-bottom: 0.25rem;
    padding: 0.4rem 0.5rem;
}

button, [role="button"] {
    padding: 0.4rem 0.75rem;
}

.grid {
    gap: 0.75rem;
}

footer {
    margin-top: 1rem;
    text-align: center;
    opacity: 0.6;
}

/* Compact action buttons in tables */
table form {
    margin-bottom: 0;
}

table button {
    margin-bottom: 0;
}

.action-btns {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    white-space: nowrap;
}

.action-btns a[role="button"],
.action-btns button {
    padding: 0.2rem 0.5rem;
    margin: 0;
    font-size: 0.78rem;
    white-space: nowrap;
}

.action-btns form {
    margin: 0;
}

/* Bracket display */
.bracket-section {
    margin-bottom: 2rem;
}

/* Winner highlight */
tr.winner td {
    font-weight: bold;
}

[role="alert"] {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

/* Match form — team grid */
.team-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.35rem;
}
.team-grid fieldset {
    margin-bottom: 0;
}
.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    opacity: 0.5;
}

fieldset > legend {
    width: 100%;
}

/* Match form — set score rows */
.set-row {
    --pico-line-height: 1.1;
    --pico-form-element-spacing-vertical: 0.25rem;
    --pico-form-element-spacing-horizontal: 0.25rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.25rem;
}
.set-row input {
    justify-self: center;
}
.set-score-input {
    width: 3rem !important;
    text-align: center;
    padding: 0.1rem 0.15rem !important;
    margin-bottom: 0 !important;
    font-size: 0.9rem;
}
.set-score-input.set-winner {
    background-color: #e8f5e9;
    border-color: #a5d6a7;
}
.set-dash {
    font-weight: bold;
    opacity: 0.5;
    text-align: center;
}
.match-status {
    font-weight: 600;
    margin-top: 0.25rem;
    text-align: center;
}

/* Match form — forfeit row */
.forfeit-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.forfeit-check {
    margin-bottom: 0 !important;
}
.forfeit-select {
    width: auto !important;
    margin-bottom: 0 !important;
}

/* Responsive: stack teams on small screens */
@media (max-width: 600px) {
    .team-grid {
        grid-template-columns: 1fr;
    }
    .vs-divider {
        padding-top: 0;
    }
}

/* Bracket tabs */
.bracket-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.33rem;
    flex-wrap: wrap;
}
.bracket-tab {
    padding: 0.35rem 0.75rem;
    border: 1px solid #1a1a2e;
    background: transparent;
    color: #1a1a2e;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}
.bracket-tab.active {
    background: #1a1a2e;
    color: white;
}
.bracket-tab:hover {
    opacity: 0.8;
}

/* Bracket tree layout */
.bracket-tree {
    display: flex;
    gap: 2rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    align-items: stretch;
    min-height: 200px;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 220px;
    gap: 0.5rem;
}

.round-header {
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid #ccc;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
}

/* Match cards */
.match-card {
    border: 1px solid #ddd;
    border-left: 4px solid #1a1a2e;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    background: #fff;
    position: relative;
}

.match-number {
    font-size: 0.7rem;
    opacity: 0.4;
    margin-bottom: 0.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-team {
    padding: 0.1rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-team:last-of-type {
    border-bottom: none;
}

.match-team.match-winner {
    font-weight: 700;
}

.winner-check {
    color: #2a8f2a;
    font-size: 0.9rem;
}

.match-score {
    font-size: 0.7rem;
    opacity: 1;
}

a.match-score-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
a.match-score-link:hover {
    color: #1a1a2e;
    text-decoration: underline;
}

.match-enter-link {
    font-size: 0.75rem;
    display: block;
    text-align: center;
    margin-top: 0.25rem;
    padding-top: 0.2rem;
    border-top: 1px solid #eee;
}

.loser-route-link {
    font-size: 0.65rem;
    opacity: 0.5;
    margin-left: auto;
    white-space: nowrap;
}

.match-team-name {
    font-size: 0.78rem;
    word-break: break-word;
}

.match-bye {
    font-style: italic;
    opacity: 0.5;
}

.match-tbd {
    font-style: italic;
    opacity: 0.4;
}

/* Home page — season cards */
.season-active-badge {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-left: 0.5rem;
}

.season-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.season-half-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.season-half-header a {
    text-decoration: none;
}

.season-action-link {
    font-size: 0.8rem;
    font-weight: 400;
}

table.mini-results {
    width: 100%;
    font-size: 0.78rem;
    border-collapse: collapse;
    margin: 0;
}

table.mini-results tr {
    border-bottom: 1px solid #eee;
}

table.mini-results tr:last-child {
    border-bottom: none;
}

table.mini-results td {
    padding: 0.2rem 0.3rem;
    border: none;
    white-space: nowrap;
}

.mini-team {
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-team-right {
    text-align: right;
}

.mini-score {
    text-align: center;
    font-size: 0.72rem;
}

.mini-score a {
    color: #5b7fb5;
    text-decoration: none;
    opacity: 0.75;
}

.mini-score a:hover {
    opacity: 1;
    text-decoration: underline;
}

.mini-winner {
    font-weight: 700;
}

.mini-results-footer {
    font-size: 0.7rem;
    color: #999;
    text-align: center;
    margin-top: 0.3rem;
}

.inner-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    background: #fafafa;
}

ul.upcoming-list {
    list-style: square;
    padding: 0 0 0 1rem;
    margin: 0;
    font-size: 0.85rem;
}

ul.upcoming-list li {
    padding: 0.1rem 0;
}

.tourney-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.tourney-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.45;
    margin-bottom: 0.15rem;
}

.muted {
    opacity: 0.5;
}

.season-inactive {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.season-inactive a {
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .season-split {
        grid-template-columns: 1fr;
    }
}

/* Tournament filter tabs (admin dashboard) */
.tourney-filter-tabs {
    display: flex;
    gap: 0.25rem;
}

.tourney-filter {
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    border: 1px solid #ccc;
    background: transparent;
    color: #555;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 0;
}

.tourney-filter.active {
    background: #1a1a2e;
    color: white;
    border-color: #1a1a2e;
}

.tourney-filter:hover {
    opacity: 0.8;
}

/* Pending matches tab */
.pending-matches-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}
.pending-matches-table th,
.pending-matches-table td {
    padding: 0.2rem 0.4rem;
    font-size: 0.78rem;
    border: none;
    border-bottom: 1px solid #eee;
}
.pending-matches-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.5;
    font-weight: 600;
}
.pending-matches-table .matchup-cell {
    word-break: break-word;
}
.pending-matches-table .vs-text {
    opacity: 0.4;
    font-size: 0.7rem;
}
.bracket-badge {
    display: inline-block;
    background: #1a1a2e;
    color: white;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    min-width: 1.2rem;
    text-align: center;
}
.round-label {
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
}
.match-actions-cell {
    text-align: right;
    white-space: nowrap;
}
.match-action-btn {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.72rem;
    border-radius: 3px;
    text-decoration: none;
    cursor: pointer;
    background: #1a1a2e;
    color: white;
}
.match-action-btn:hover {
    opacity: 0.8;
}
.match-action-btn.outline {
    background: transparent;
    border: 1px solid #1a1a2e;
    color: #1a1a2e;
}

/* Placeholder match cards in bracket */
.match-card.match-placeholder {
    opacity: 0.35;
    border-left-color: #ccc;
}

/* Drag-and-drop seed table */
.seed-table tbody tr {
    cursor: grab;
}
.seed-table tbody tr:active {
    cursor: grabbing;
}
.seed-table tbody tr.drag-over {
    border-top: 2px solid #1a1a2e;
}
.seed-table .seed-num {
    font-weight: 700;
    text-align: center;
}
.seed-table tbody tr.excess {
    opacity: 0.4;
}

/* Compact match form inputs (password, date, player names) */
#match-form .grid,
#match-form .team-grid {
    gap: 0.25rem;
}
#match-form .grid label,
#match-form .team-grid label {
    margin-bottom: 0;
    font-size: 0.85rem;
}
#match-form .grid input,
#match-form .team-grid input:not([type="hidden"]),
#match-form > label input,
#match-form > input {
    padding: 0.15rem 0.25rem;
    margin-bottom: 0.1rem;
    height: 1.8rem;
    font-size: 0.6rem;
}
#match-form .team-grid fieldset {
    padding: 0.25rem 0.35rem;
    margin-bottom: 0;
}
#match-form .team-grid legend {
    margin-bottom: 0.1rem;
    text-align: center;
}

/* Matches list table */
.matches-table .match-winner-cell {
    font-weight: 700;
}
.matches-table .match-score-cell {
    text-align: center;
    font-size: 0.8rem;
}
.matches-table .match-score-cell a {
    color: #888;
    text-decoration: none;
}
.matches-table .match-score-cell a:hover {
    text-decoration: underline;
}
.matches-table .match-team-right {
    text-align: right;
}

/* Score entry modal */
dialog#score-modal,
dialog#match-modal {
    border: none;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    --pico-modal-overlay-background-color: rgba(0, 0, 0, 0.1);
    --pico-modal-overlay-backdrop-filter: none;
}
