:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-2: #1f2937;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #22c55e;
    --accent-hover: #53cc80;
    --accent-contrast: #062b12;
    --accent-2: #38bdf8;
    --danger: #f87171;
    --border: #334155;
    --warning: #f59e0b;
    --chip-text: #000000;
    --chip-bg: #b8b8b8;
    --chip-bg-hover: #d5d5d5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
}

.prefill-panel {
    margin-top: 24px;
}

.container {
    width: 100%;
    min-height: 100vh;
    padding: 24px;
}

.court-count {
    display: flex;
    gap: 20px;
    align-items: center;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 20px 18px;
    background: rgba(17, 24, 39, 0.92);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    position: relative;
}

.app-header, .grid {
    max-width: 800px;
    margin: 0 auto 20px;
}

.app-title {
    font-size: 24px;
    font-weight: bold;
}

.header-menu {
    position: relative;
}

.menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: backdropIn 0.15s ease;
}

@keyframes backdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.menu-backdrop.open {
    display: block;
}

.menu-toggle {
    min-width: 52px;
    font-size: 22px;
    line-height: 1;
    padding: 10px 14px;
}

.menu-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 240px;
    background: rgba(15, 23, 42, 0.97);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.55), 0 0 0 0.5px rgba(255,255,255,0.04);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: none;
    z-index: 100;
    transform-origin: top right;
    animation: menuOpen 0.15s ease;
}

@keyframes menuOpen {
    from { opacity: 0; transform: scale(0.95) translateY(-6px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.menu-dropdown.open {
    display: block;
}

.menu-dropdown button.menu-item {
    width: 100%;
    text-align: left;
    margin: 0;
    background: transparent;
    color: var(--text);
    border-radius: 10px;
    padding: 11px 14px;
    font-weight: 500;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.12s ease;
}

.menu-dropdown button.menu-item:hover {
    background: rgba(255,255,255,0.07);
    opacity: 1;
}

.menu-dropdown button.menu-item:active {
    background: rgba(255,255,255,0.12);
}

/* Danger item gets a separator on top and a subtle red tint on hover */
.menu-dropdown button.menu-item.danger {
    background: transparent;
    color: var(--danger);
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 14px;
    border-radius: 0 0 10px 10px;
}

.menu-dropdown button.menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.12);
}

.mini-table td.center,
.mini-table th.center {
    text-align: center;
}

.h-no-m {
    margin: 0;
}

h1, h2, h3 {
    margin: 0 0 16px;
}

.mb {
    margin-bottom: 16px;
}

.mt {
    margin-top: 16px;
}

.subtle {
    color: var(--muted);
    line-height: 1.5;
}

.small-text {
    font-size: 13px;
}



.panel {
    background: rgba(17, 24, 39, 0.92);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.panel + .panel {
    margin-top: 20px;
}

.hidden {
    display: none !important;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(245, 158, 11, 0.4);
    background: rgba(17, 24, 39, 0.98);
    color: #fde68a;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 640px) {
    .toast {
        top: 12px;
        right: 12px;
        left: 12px;
        min-width: 0;
        max-width: none;
    }
}

label {
    display: block;
    font-weight: bold;
    margin: 10px 0;
}

.settings-panel label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: normal;
}

.settings-panel input[type="checkbox"] {
    width: auto;
    transform: scale(1.2);
}

input,
button,
select,
textarea {
    font: inherit;
}

input[type="number"],
input[type="text"],
select,
textarea {
    width: 100%;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.match-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: end;
}

.settings-row {
    margin-top: 16px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.actions input[type="text"] {
    flex: 1 1 220px;
}

.actions.no-top-margin {
    margin-top: 0;
}

button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.05s ease, opacity 0.2s ease;
}

button:hover {
    opacity: 0.95;
}

button:active {
    transform: translateY(1px);
}

.primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.secondary {
    background: var(--accent-2);
    color: #062235;
}

.danger {
    background: var(--danger);
    color: #3b0a0a;
}

.ghost {
    background: #334155;
    color: var(--text);
}

.result-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    background: rgba(31, 41, 55, 0.7);
    margin-bottom: 14px;
}

.court-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: bold;
}

.court-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.vs-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
}

.team {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.team h4 {
    margin: 0 0 8px 0;
    color: #cbd5e1;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.player-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.2);
}

.player-line:last-child {
    border-bottom: none;
}

.tag {
    display: inline-block;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.16);
    color: #bae6fd;
}

.bench-list, .history-list {
    margin: 0;
    padding-left: 18px;
    line-height: 1.6;
}

.warning {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 12px;
}

.player-manager-form {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-direction: row;
    align-items: center;
    margin-top: 24px;
}

.lowered {
    font-size: 10px;
    padding: 0;
    margin: 7px 0 0 -6px;
}

.player-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-contrast);
    background: var(--accent);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-weight: normal;
    padding: 7px 10px;
}

.player-chip:hover {
    background: var(--accent-hover);
    cursor: pointer;
}


.level {
    font-size: 12px;
}

.player-chip button {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.mini-table th,
.mini-table td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    padding: 8px 6px;
    text-align: left;
    vertical-align: top;
}

.mini-table th {
    color: var(--muted);
    font-weight: bold;
}

.table-subtle {
    color: var(--accent);
    font-size: 12px;
    display: inline;
}

.mt24 {
    margin-top: 24px;
}

#newPlayerLevel {
    width: 60px;
}
#newPlayerName {
    width: 100%;
}

.w100 {
    width: 100%;
}

.settings-panel,
.new-player-panel,
.import-export-panel {
    display: none;
}

.settings-panel.open,
.new-player-panel.open,
.import-export-panel.open {
    display: block;
}

textarea {
    resize: vertical;
}

.muted {
    color: var(--muted);
}

.flex-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.history-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.history-header h2 {
    margin-bottom: 0;
}

.player-manager-list {
    display: grid;
    gap: 12px;
}

.player-row-name-pref {
    display: flex;
    gap: 16px;
}

.player-row.is-inactive {
    opacity: 0.82;
}

.player-row-main {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    height: 40px;
}

.player-row button {
    font-weight: normal;
    height: 40px;
}


.icon-toggle-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
}

.player-row-main button {
    width: auto;
}

.player-row-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.player-level-badge {
    display: inline-block;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.12);
    color: #bae6fd;
}

.player-row-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
    flex-direction: row-reverse;
}


.player-row-settings {
    display: grid;
    gap: 12px;
    width: 100%;
}

.prefill-header {
    width: 100%;
    padding: 0;
}

.prefill-header h3 {
    font-size: 16px;
}

.collapse-indicator {
    margin-left: auto; /* ekstra sikkerhed */
}

.prefill-area {
    display: grid;
    gap: 24px;
}

.prefill-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    gap: 14px;
    background: rgba(31, 41, 55, 0.55);
    flex-direction: column;
}

prefill-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-direction: row;
    align-items: center;
}

.prefill-format {
    min-width: 140px;
}

.flex-center {
    display: flex;
    align-items: center;
}


.prefill-grid {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-direction: row;
}

.prefill-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.prefill-side {
    display: flex;
    gap: 10px;
    border-radius: 12px;
    width: 100%;
    justify-content: space-between;
    flex-direction: column;
}

.prefill-side label {
    margin: 0;
}

.prefill-side label span {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--muted);
}

.prefill-vs {
    font-weight: bold;
    color: #cbd5e1;
}

.compact-player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.player-row-inline-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.level-select {
    width: 72px;
    min-width: 72px;
}

.player-row-inline-controls select:not(.level-select) {
    width: 150px;
    min-width: 150px;
}

.player-row-name {
    width: auto;
    flex: 1 1 auto;
    justify-content: flex-start;
}


.collapsible-toggle {
    width: 100%;
    display: flex;
    height: 50px;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: transparent;
    color: var(--text);
    padding: 0;
    border: none;
    cursor: pointer;
}


.collapsible-toggle:hover {
    opacity: 1;
}

.collapsible-content {
    margin-top: 14px;
}

.collapsed .collapsible-content {
    display: none;
}

.collapse-indicator {
    font-size: 18px;
    line-height: 1;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.collapsible-panel:not(.collapsed) .collapse-indicator {
    transform: rotate(180deg);
}

.panel-toggle {
    font-size: 24px;
    font-weight: bold;
    margin: 0;
}

.player-row button.player-row-name {
    background-color: var(--muted);
}

.player-row.is-active button.player-row-name {
    background-color: var(--accent);
}

.prefill-actions {
    display: flex;
    margin-bottom: 24px;
}


.settings-row {
    margin: 30px 0;
}

/* Label for settings sections that aren't checkboxes */
.settings-label {
    font-size: 14px;
    margin-bottom: 10px;
    opacity: 0.85;
}

/* Inline grid of format-size checkboxes */
.format-sizes-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.format-size-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.settings-sub-row {
    margin-left: 24px;
}

.settings-sub-row--hidden {
    display: none;
}

/* Dims the level-balance settings when skill levels are turned off */
.settings-group-disabled {
    opacity: 0.38;
    pointer-events: none;
    user-select: none;
}

/* Reveal-level button in the player manager list */
.level-reveal-btn {
    font-size: 13px;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.15s;
}

.level-reveal-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

/* The level select area that appears after reveal */
.level-reveal-area {
    display: none;
}

.level-reveal-area--open {
    display: block;
}

@media (max-width: 980px) {
    .grid,
    .vs-grid,
    .match-row,
    .player-row-main {
        flex-direction: column;
        align-items: stretch;
    }



    .app-header {
        align-items: stretch;
    }

    /* Bottom sheet on mobile */
    .menu-dropdown {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 20px;
        top: auto;
        min-width: 0;
        border-radius: 20px;
        padding: 10px;
        transform-origin: bottom center;
        animation: menuOpenMobile 0.18s ease;
    }

    @keyframes menuOpenMobile {
        from { opacity: 0; transform: scale(0.97) translateY(12px); }
        to   { opacity: 1; transform: scale(1)   translateY(0); }
    }

    .menu-dropdown button.menu-item {
        padding: 15px 18px;
        font-size: 16px;
        border-radius: 12px;
    }

    .menu-dropdown button.menu-item.danger {
        border-radius: 0 0 12px 12px;
    }

    .panel {
        border: none;
        border-radius: 0;
    }

    .container {
        padding: 0;
    }

    .app-header {
        border: none;
        border-radius: 0;
    }

    .menu-toggle {
        position: absolute;
        right: 12px;
        top: 12px;
    }

    .header-menu {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
    }

    /* --- ændret del --- */
    .player-row-main.compact-player-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .player-row-name {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .player-row-inline-controls {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 0 0 auto;
        width: auto;
    }

    .level-select {
        width: 52px !important;
        min-width: 52px !important;
        padding-left: 8px;
        padding-right: 8px;
    }

    .player-row-inline-controls select:not(.level-select) {
        width: 96px !important;
        min-width: 96px !important;
    }


    .app-header, .grid {
        max-width: 100%;
    }
    .app-header {
        margin: 0 auto 20px;
    }

    .prefill-card {
        border: none;
        border-radius: 0;
        padding: 18px;
        display: flex;
        gap: 14px;
        background: rgba(31, 41, 55, 0.55);
        flex-direction: column;
        margin: 0 -18px;
    }

}


.retry-row {
    padding-top: 18px;
}


@keyframes spin {
    to { transform: rotate(360deg); }
}

.generate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.generate-overlay--visible {
    display: flex;
}

.generate-overlay__spinner {
    width: 52px;
    height: 52px;
    border: 5px solid rgba(255,255,255,0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.generate-overlay__text {
    color: var(--text);
    font-size: 16px;
    opacity: 0.85;
    letter-spacing: 0.02em;
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    