*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f0;
    color: #1a1a1a;
    min-height: 100vh;
}

/* ── Header ── */
header {
    background: #2a5e24;
    color: #fff;
    padding: 1rem 2rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

header p {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

/* ── Layout ── */
.container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.card-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #2a5e24;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #e4f0e4;
}

/* ── Settings ── */
.settings-row {
    display: flex;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}

.field input[type="number"] {
    width: 80px;
    padding: 0.45rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.95rem;
    text-align: center;
    transition: border-color 0.15s;
}

.field input[type="number"]:focus {
    outline: none;
    border-color: #2a5e24;
}

/* ── Players table ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 0.4rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #777;
    border-bottom: 2px solid #e4f0e4;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #f2f2f2;
    transition: background 0.1s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: #fafdf9;
}

tbody td {
    padding: 0.3rem 0.75rem;
    vertical-align: middle;
}

/* ── Column widths ── */
.col-handle {
    width: 28px;
    padding-left: 0.25rem !important;
    padding-right: 0 !important;
}

.col-seed {
    width: 36px;
    padding-left: 0.25rem !important;
}

.col-name {
    min-width: 160px;
}

.col-rating {
    width: 100px;
}

.col-eff {
    width: 130px;
}

.col-bib {
    width: 46px;
}

.col-del {
    width: 36px;
}

/* ── Drag handle ── */
.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 28px;
    cursor: grab;
    color: #d4d4d4;
    border-radius: 3px;
    user-select: none;
    font-size: 1rem;
    transition: color 0.12s, background 0.12s;
}

.drag-handle:hover {
    color: #888;
    background: #f0f0f0;
}

.drag-handle:active {
    cursor: grabbing;
}

/* ── Auto seed display ── */
.seed-num {
    font-size: 0.78rem;
    font-weight: 700;
    color: #c8c8c8;
    text-align: center;
    user-select: none;
}

/* ── Inputs ── */
tbody td input[type="number"],
tbody td input[type="text"] {
    width: 100%;
    padding: 0.3rem 0.45rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.875rem;
    background: transparent;
    transition: border-color 0.15s, background 0.15s;
}

tbody td input:focus {
    outline: none;
    border-color: #2a5e24;
    background: #fff;
}

/* ── Effective rating + warning ── */
.eff-cell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.eff-value {
    font-size: 0.82rem;
    color: #999;
    font-style: italic;
}

.eff-value.is-explicit {
    color: #2a5e24;
    font-style: normal;
    font-weight: 600;
}

.eff-value.is-interpolated {
    color: #888;
}

.warn-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 15px;
    width: 15px;
    height: 15px;
    background: #f59e0b;
    color: #fff;
    border-radius: 50%;
    font-size: 0.62rem;
    font-weight: 900;
    line-height: 1;
    cursor: help;
    flex-shrink: 0;
}

.warn-badge.show {
    display: flex;
}

/* ── Delete button ── */
.btn-del {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #bbb;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.15s, background 0.15s;
}

.btn-del:hover {
    color: #d93535;
    background: #fdf0f0;
}

/* ── Drag-and-drop states ── */
tbody tr.is-dragging {
    opacity: 0.35;
}

tbody tr.drop-above {
    box-shadow: inset 0 2px 0 0 #2a5e24;
}

tbody tr.drop-below {
    box-shadow: inset 0 -2px 0 0 #2a5e24;
}

/* ── Table footer ── */
.table-footer {
    margin-top: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-add {
    padding: 0.4rem 1rem;
    background: #f0f8f0;
    color: #2a5e24;
    border: 1px dashed #8cbe8a;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-add:hover {
    background: #dceedd;
}

.player-count {
    font-size: 0.78rem;
    color: #aaa;
}

/* ── Legend ── */
.interp-note {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.6rem;
}

.interp-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 3px;
    vertical-align: middle;
}

/* ── Buttons ── */
.btn-primary {
    padding: 0.7rem 2.5rem;
    background: #2a5e24;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(42, 94, 36, 0.3);
}

.btn-primary:hover {
    background: #22501e;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(42, 94, 36, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 0.4rem 1rem;
    background: #fff;
    color: #2a5e24;
    border: 1.5px solid #2a5e24;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: #f0f8f0;
}

.generate-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* ── Error / notice ── */
.notice {
    font-size: 0.82rem;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    margin-top: 0.75rem;
}

.notice.error {
    color: #b91c1c;
    background: #fef2f2;
}

.notice.warning {
    color: #92400e;
    background: #fffbeb;
}

/* ── Schedule ── */
.schedule-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #e4f0e4;
}

.schedule-top .card-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.export-row {
    display: flex;
    gap: 0.5rem;
}

/* ── Schedule grid ── */
.schedule-grid {
    display: grid;
    gap: 0;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    overflow: hidden;
    background: #f9f9f9;
    width: 100%;
    margin-bottom: 1rem;
}

.grid-cell {
    border-right: 1px solid #e8e8e8;
    border-bottom: 1px solid #e8e8e8;
    padding: 0.4rem 0.5rem;
    font-size: 0.72rem;
    line-height: 1.3;
    background: #fff;
}

.grid-header {
    background: #e4f0e4;
    color: #2a5e24;
    font-weight: 700;
    text-align: center;
    padding: 0.4rem 0.5rem;
    border-right: 1px solid #d0d0d0;
    border-bottom: 2px solid #d0d0d0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.grid-label {
    background: #f0f8f0;
    color: #2a5e24;
    font-weight: 600;
    padding: 0.4rem 0.5rem;
    border-right: 2px solid #d0d0d0;
    border-bottom: 1px solid #e8e8e8;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.grid-cell:last-child {
    border-right: none;
}

/* ── Print ── */
@media print {
    body {
        background: #fff;
    }

    header {
        box-shadow: none;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .settings-section,
    .players-section,
    .generate-row,
    .export-row {
        display: none !important;
    }

    .container {
        margin: 0;
        padding: 0;
        gap: 1rem;
    }

    .card {
        box-shadow: none;
        padding: 0.75rem;
    }

    .round-block {
        break-inside: avoid;
    }
}