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

:root {
    --red: #8c2020;
    --red-dark: #5c1414;
    --red-light: #b03030;
    --bg: #0d0d0d;
    --surface: #181818;
    --surface2: #222222;
    --text: #ede8e8;
    --text-muted: #a08888;
    --border: #2e1a1a;
    --accent: #c8a04a;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ── Header ── */
header {
    background: var(--red-dark);
    border-bottom: 3px solid var(--accent);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}
.logo-icon {
    font-size: 2.2rem;
    line-height: 1;
}
.logo-text h1 {
    font-size: 1.5rem;
    letter-spacing: 1px;
    color: var(--accent);
}
.logo-text span {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

nav {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 0;
}
nav a {
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.15s;
}
nav a:hover, nav a.active {
    background: var(--red-light);
    color: #fff;
    text-decoration: none;
}
nav a.nav-signin {
    margin-left: 0.5rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-weight: 400;
    font-size: 0.85rem;
}
nav a.nav-signin:hover {
    background: var(--surface2);
    color: var(--text);
}

/* ── Layout ── */
main {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

footer {
    background: var(--red-dark);
    border-top: 2px solid var(--border);
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Page title ── */
.page-title {
    font-size: 1.8rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.card-image {
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: block;
    cursor: zoom-in;
}
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,.7);
    cursor: default;
}
.card-thumb {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    display: block;
}
.read-more {
    font-size: 0.85rem;
    font-weight: 700;
}
.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
}
.card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.card-body {
    line-height: 1.6;
    color: var(--text);
}
.card-body p                  { margin-bottom: 0.6rem; }
.card-body p:last-child       { margin-bottom: 0; }
.card-body h2                 { font-size: 1.15rem; color: var(--accent); margin: 0.9rem 0 0.4rem; }
.card-body h3                 { font-size: 1rem;    color: var(--accent); margin: 0.75rem 0 0.35rem; }
.card-body ul, .card-body ol  { padding-left: 1.4rem; margin-bottom: 0.6rem; }
.card-body li                 { margin-bottom: 0.2rem; }
.card-body a                  { color: var(--accent); }
.card-body strong             { font-weight: 700; }
.card-body em                 { font-style: italic; }

/* ── Quill editor dark theme ── */
.ql-toolbar.ql-snow {
    background: var(--surface2);
    border-color: var(--border);
    border-radius: 5px 5px 0 0;
}
.ql-container.ql-snow {
    background: var(--bg);
    border-color: var(--border);
    border-radius: 0 0 5px 5px;
    font-size: 0.95rem;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: var(--text);
}
.ql-editor { min-height: 140px; color: var(--text); line-height: 1.6; }
.ql-editor.ql-blank::before  { color: var(--text-muted); font-style: normal; }
.ql-snow .ql-stroke           { stroke: var(--text-muted); }
.ql-snow .ql-fill             { fill:   var(--text-muted); }
.ql-snow .ql-stroke.ql-fill   { fill:   var(--text-muted); }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar  button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-toolbar  button.ql-active .ql-stroke { stroke: var(--accent); }
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow .ql-toolbar  button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill,
.ql-snow .ql-toolbar  button.ql-active .ql-fill   { fill: var(--accent); }
.ql-snow .ql-picker             { color: var(--text-muted); }
.ql-snow .ql-picker-options     { background: var(--surface2); border-color: var(--border); }
.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker.ql-expanded .ql-picker-label { color: var(--accent); }
.ql-snow .ql-picker-item:hover  { color: var(--accent); }

/* ── Table ── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
th {
    background: var(--red-dark);
    color: var(--accent);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
td {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.95rem;
}
tr:hover td { background: var(--surface2); }

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}
.badge-win  { background: #1a5c2a; color: #6effa0; }
.badge-loss { background: #5c1a1a; color: #ffaaaa; }
.badge-draw { background: #3a3a0f; color: #ffe066; }
.badge-upcoming { background: var(--surface2); color: var(--text-muted); }

/* ── Time picker ── */
.tp-wrap {
    position: relative;
}
.tp-segments {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
input.tp-seg-input[type=text] {
    width: 3.5rem;
    padding: 0.6rem 0.4rem;
    text-align: center;
    cursor: pointer;
}
.tp-colon { color: var(--text-muted); }
.tp-popup {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    z-index: 200;
    box-shadow: 0 6px 20px rgba(0,0,0,.55);
}
.tp-popup.open { display: block; }
.tp-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3rem; }
.tp-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
.tp-opt {
    padding: 0.5rem 0.55rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: background 0.12s, border-color 0.12s;
    min-width: 2.4rem;
}
.tp-opt:hover  { border-color: var(--red-light); background: var(--surface); }
.tp-opt.active { background: var(--red); border-color: var(--red); color: #fff; }

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}
.tab-btn {
    padding: 0.4rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: var(--surface); color: var(--text); }
.tab-btn.active { background: var(--red); border-color: var(--red); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Empty state ── */
.empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1rem;
}

/* ── Admin styles ── */
.admin-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    max-width: 560px;
}
.form-group {
    margin-bottom: 1.25rem;
}
label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 600;
}
input[type=text], input[type=date], input[type=time],
input[type=password], input[type=number], input[type=file], textarea, select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--red-light);
}
textarea { resize: vertical; min-height: 100px; }

.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: 5px;
    border: none;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-primary { background: var(--red-light); color: #fff; }
.btn-danger  { background: #8b1a1a; color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-success { background: #1a3a1a; border: 1px solid #2d6a3a; color: #a0ffb8; }
.alert-error   { background: #4a1a1a; border: 1px solid #8b2a2a; color: #ffaaaa; }

.admin-nav {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}
.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.nav-group-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    padding-left: 0.1rem;
}
.nav-group-links {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.admin-nav a {
    padding: 0.5rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-size: 0.9rem;
}
.admin-nav a:hover {
    background: var(--red);
    text-decoration: none;
    color: #fff;
}
.admin-nav a.active {
    background: var(--red);
    color: #fff;
}

.delete-btn {
    background: none;
    border: none;
    color: #cc4444;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem 0.5rem;
}
.delete-btn:hover { color: #ff6666; }

/* ── Post type selector ── */
.type-selector {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.type-option { flex: 1; min-width: 120px; }
.type-option input[type=radio] { display: none; }
.type-option span {
    display: flex;
    justify-content: center;
    padding: .55rem 1rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface2);
    cursor: pointer;
    font-size: .95rem;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.type-option span:hover { border-color: var(--red-light); }
.type-option input:checked + span {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

/* ── Polls ── */
.poll-create {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    max-width: 560px;
}
.poll-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.poll-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: .3rem;
}
.poll-question {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
}
.poll-meta {
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: .9rem;
}
.poll-options {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.poll-option-label {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    transition: border-color .15s;
    font-size: .95rem;
}
.poll-option-label:hover { border-color: var(--red-light); }
.poll-result { margin-bottom: .55rem; }
.poll-result-label {
    display: flex;
    justify-content: space-between;
    font-size: .88rem;
    margin-bottom: .25rem;
}
.poll-bar-track {
    height: 8px;
    background: var(--surface2);
    border-radius: 4px;
    overflow: hidden;
}
.poll-bar-fill {
    height: 100%;
    background: var(--red);
    border-radius: 4px;
}
.poll-result-chosen .poll-bar-fill { background: var(--accent); }
.poll-result-chosen .poll-result-label span:first-child {
    color: var(--accent);
    font-weight: 600;
}

/* ── Comments ── */
.comments {
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}
.comments-title {
    font-size: .8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .75rem;
}
.comment {
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}
.comment:last-of-type { border-bottom: none; }
.comment-header {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    margin-bottom: .25rem;
    flex-wrap: wrap;
}
.comment-author {
    font-weight: 600;
    font-size: .88rem;
    color: var(--accent);
}
.comment-date {
    font-size: .75rem;
    color: var(--text-muted);
}
.comment-body {
    font-size: .9rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.comment-form {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.comment-form textarea {
    min-height: 60px;
    font-size: .9rem;
}
.comments-login-hint {
    margin-top: .75rem;
    font-size: .85rem;
    color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    /* Make all tables horizontally scrollable instead of overflowing */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    header {
        padding: 0 1rem;
    }
    main {
        padding: 0 1rem;
    }
}

@media (max-width: 600px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
    }
    /* Logo shrinks so "Risvollan Dartklubb" fits on small screens */
    .logo {
        gap: 0.6rem;
        padding: 0.75rem 0;
    }
    .logo-icon {
        font-size: 1.7rem;
    }
    .logo-text h1 {
        font-size: 1.1rem;
    }
    .logo-text span {
        font-size: 0.7rem;
    }
    nav {
        flex-wrap: wrap;
        padding: 0 0 0.6rem;
        gap: 0.2rem;
    }
    nav a {
        padding: 0.35rem 0.6rem;
        font-size: 0.82rem;
    }
    main {
        margin: 1rem auto;
        padding: 0 0.85rem;
    }
    .page-title {
        font-size: 1.35rem;
    }
    .admin-form {
        padding: 1.1rem;
    }
    .card {
        padding: 1rem;
    }
    /* Tighten admin nav groups on small screens */
    .admin-nav {
        gap: 1rem;
    }
    .admin-nav a {
        font-size: 0.82rem;
        padding: 0.4rem 0.7rem;
    }
}
