:root {
    --bg: #0f1115;
    --panel: #141821;
    --muted: #9aa3b2;
    --text: #e8ecf1;
    --primary: #ff7a18;
    --primary-600: #ff9329;
    --danger: #ff4d4f;
    --ok: #19c37d;
    --border: #232a36;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--text);
    background: radial-gradient(1200px 800px at -10% -10%, #1a2230 0%, transparent 60%),
        radial-gradient(1000px 700px at 110% -20%, #1b1f2a 0%, transparent 60%),
        linear-gradient(180deg, #0b0d12, #0f1115);
    background-attachment: fixed, fixed, fixed;
    background-repeat: no-repeat, no-repeat, no-repeat;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(15, 17, 21, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 800;
    letter-spacing: 0.2px;
}

.muted {
    color: var(--muted);
    font-weight: 500;
}

.brand::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--primary), var(--primary-600));
    margin-right: 8px;
    box-shadow: 0 0 18px rgba(255, 122, 24, 0.6);
}

.tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
}

.tab.active {
    background: var(--panel);
    border-color: #2e3747;
}

.actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.grid.two {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (min-width: 700px) {
    .grid.two {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 900px) {
    .grid.two {
        grid-template-columns: 1fr 1fr;
    }
}

.grid.four {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

@media (min-width: 900px) {
    .grid.four {
        grid-template-columns: repeat(4, 1fr);
    }
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.insight {
    display: grid;
    gap: 6px;
    align-content: start;
}

.insight .title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.6px;
}

.insight .value {
    font-size: 20px;
    font-weight: 800;
}

.insight .sub {
    color: var(--muted);
    font-size: 12px;
}

.charts canvas {
    width: 100%;
    display: block;
}

.mt {
    margin-top: 10px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 1rem;
}

.section-header h3 {
    margin: 0;
    font-size: 16px;
}

.view h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

button {
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text);
    background: #1a2230;
    border: 1px solid var(--border);
}

button.primary {
    background: linear-gradient(180deg, var(--primary), var(--primary-600));
    color: #111;
    border: none;
}

button.primary:hover {
    filter: brightness(1.05);
}

button.secondary {
    background: #1a2230;
}

button.danger {
    background: #36191b;
    border-color: #5e2226;
    color: #ffd6d6;
}

button.small {
    padding: 4px 8px;
    font-size: 12px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    background: #0f131b;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
}

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.field {
    margin-bottom: 12px;
}

.row-right {
    display: flex;
    justify-content: flex-end;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--muted);
    font-weight: 600;
}

.table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.stat {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    background: #121722;
    align-items: center;
    justify-content: center;
}

.badge {
    background: #0b1019;
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
}

.win {
    color: var(--ok);
    font-weight: 700;
}

.loss {
    color: #ef6b73;
    font-weight: 700;
}

.match {
    display: grid;
    grid-template-columns: 120px 1fr 150px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #121722;
    transition: transform .12s ease, background .12s ease;
}

.match:hover {
    transform: translateY(-1px);
    background: #131a28;
}

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #0b1019;
    border: 1px solid var(--border);
    margin-right: 6px;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog {
    border: none;
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    width: 640px;
    max-width: calc(100% - 24px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dialog-form {
    padding: 12px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.participant-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 6px;
}

.placement-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--panel);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.participant-info {
    font-size: 14px;
    color: var(--text);
}

.placement-input {
    width: 60px;
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    text-align: center;
    font-size: 14px;
}

.placement-input:focus {
    outline: none;
    border-color: var(--primary);
}

.inline-muted {
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    color: var(--muted);
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

/* Consistent list spacing */
#matchesList,
#playersList,
#decksList {
    display: grid;
    gap: 8px;
}

.h2h {
    overflow: auto;
}

.h2h table {
    width: 100%;
    border-collapse: collapse;
}

.h2h th,
.h2h td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.h2h th {
    font-weight: 600;
    color: var(--muted);
    position: sticky;
    top: 0;
    background: var(--panel);
}

.cell-win {
    background: rgba(25, 195, 125, 0.08);
}

.cell-lose {
    background: rgba(255, 77, 79, 0.08);
}

/* Password Dialog Styles */
.password-dialog {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    max-width: 400px;
    width: 90vw;
}

.password-dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.password-description {
    color: var(--muted);
    font-size: 14px;
    margin: 8px 0 0 0;
    line-height: 1.4;
}

.error-message {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.error-message::before {
    content: "⚠";
    font-size: 14px;
}

#passwordInput {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    transition: border-color 0.2s ease;
}

#passwordInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(255, 122, 24, 0.1);
}

#passwordInput::placeholder {
    color: var(--muted);
}