/* Punkte-Challenge (/challenge). Eigene Datei, eigene Farbe (Fuchsia). */

.subpage-hero:has(.fa-trophy) { --sky-a: #c026d3; --sky-b: #3b0a45; }

.ch-page { max-width: 1000px; }

#ch {
    --pink: #f0abfc;
    --pink-strong: #e879f9;
    --pink-soft: rgba(232, 121, 249, 0.12);
    --pink-line: rgba(232, 121, 249, 0.38);
    --good: #4ade80;
    --bad: #f87171;
    --line: rgba(255, 255, 255, 0.08);
    --field: #17171d;
    font-variant-numeric: tabular-nums;
}

/* ===== Grundbausteine ===== */
.ch-card {
    padding: 22px;
    margin-bottom: 18px;
    border-radius: 18px;
    background: var(--bg-card);
    border: 1px solid var(--line);
}

.ch-h {
    margin: 0 0 14px;
    font: 600 1.1rem var(--font-fun);
    color: #fff;
}

.ch-hrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.ch-hrow .ch-h { margin: 0; }

.ch-muted { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.ch-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ch-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    min-width: 0;
}

#ch input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--field);
    color: #fff;
    font: inherit;
    font-size: 0.95rem;
}

#ch input:focus {
    outline: none;
    border-color: var(--pink-line);
    box-shadow: 0 0 0 3px var(--pink-soft);
}

.ch-addrow {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 10px;
}

.ch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--pink-strong);
    color: #2a0530;
    font: 600 0.9rem var(--font-fun);
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s, filter 0.15s, background 0.15s, border-color 0.15s;
}

.ch-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.ch-btn:active:not(:disabled) { transform: translateY(1px); }
.ch-btn:disabled { opacity: 0.4; cursor: default; }

.ch-btn.ghost {
    background: transparent;
    border-color: var(--line);
    color: #e5e7eb;
}

.ch-btn.ghost:hover:not(:disabled) { border-color: var(--pink-line); }
.ch-btn.armed { border-color: var(--bad); color: #fecaca; background: rgba(248, 113, 113, 0.12); }
.ch-btn.danger:hover:not(:disabled) { border-color: var(--bad); }

/* ===== Verbindung ===== */
.ch-sync {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin: 0 0 14px;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.ch-sync-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ch-sync-info > div { display: flex; flex-direction: column; min-width: 0; }
.ch-sync-info strong { font: 600 0.98rem var(--font-fun); }
.ch-sync-info span { font-size: 0.82rem; color: var(--text-muted); }

.ch-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #52525b;
}

.ch-sync[data-state="on"] { border-color: var(--pink-line); background: var(--pink-soft); }
.ch-sync[data-state="on"] .ch-dot { background: var(--good); box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.18); }
.ch-sync[data-state="loading"] .ch-dot { background: #fbbf24; }
.ch-sync[data-state="error"] .ch-dot { background: var(--bad); }
.ch-sync[data-state="error"] #sync-sub { color: #fca5a5; }

.ch-connect {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 0 12px;
}

.ch-connect .ch-field { margin: 0; }
.ch-msg { grid-column: 1 / -1; margin: 10px 0 0; font-size: 0.88rem; color: #fca5a5; }
.ch-msg:empty { display: none; }

/* ===== Punktetafel ===== */
.ch-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.ch-board[data-count="2"] { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.ch-empty {
    margin: 0 0 18px;
    padding: 34px 20px;
    border-radius: 18px;
    border: 1px dashed var(--line);
    text-align: center;
    color: var(--text-muted);
}

.ch-player {
    position: relative;
    padding: 20px 20px 14px;
    border-radius: 22px;
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(232, 121, 249, 0.10), transparent 70%),
        var(--bg-card);
    border: 1px solid var(--line);
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.ch-player.low { border-color: rgba(248, 113, 113, 0.35); }
.ch-player.out { border-color: rgba(248, 113, 113, 0.6); background: rgba(127, 29, 29, 0.25); }

.ch-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 28px;
}

.ch-name {
    margin: 0;
    font: 600 1.2rem var(--font-fun);
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-crown {
    flex: none;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.14);
    color: #fbbf24;
    font: 600 0.78rem var(--font-fun);
}

.ch-score {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 6px 0 10px;
}

.ch-points {
    font: 700 clamp(3.6rem, 9vw, 5rem) / 1 var(--font-fun);
    letter-spacing: -0.02em;
    color: #fff;
    display: inline-block;
}

.ch-of { color: var(--text-muted); font-size: 0.95rem; }

.ch-player.low .ch-points { color: #fca5a5; }

.bump-down .ch-points { animation: ch-down 0.45s ease; }
.bump-up .ch-points { animation: ch-up 0.45s ease; }

@keyframes ch-down {
    0% { transform: scale(1); color: #fff; }
    30% { transform: scale(0.86) translateY(4px); color: var(--bad); }
    100% { transform: scale(1); }
}

@keyframes ch-up {
    0% { transform: scale(1); }
    30% { transform: scale(1.12) translateY(-4px); color: var(--good); }
    100% { transform: scale(1); }
}

.ch-bar {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
    margin-bottom: 16px;
}

.ch-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #c026d3, var(--pink));
    transition: width 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.ch-player.low .ch-bar span { background: var(--bad); }

.ch-btns {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
}

.ch-btns button {
    padding: 16px 10px;
    border-radius: 16px;
    border: 1px solid transparent;
    font: 700 1.5rem var(--font-fun);
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    transition: transform 0.1s, filter 0.15s;
}

.ch-btns button:active { transform: scale(0.96); }
.ch-btns button:hover { filter: brightness(1.1); }

.ch-minus { background: #ef4444; color: #fff; }
.ch-plus { background: rgba(74, 222, 128, 0.12); color: var(--good); border-color: rgba(74, 222, 128, 0.35) !important; }

.ch-edit-toggle {
    display: block;
    margin: 12px auto 0;
    padding: 4px 10px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: 500 0.82rem var(--font-fun);
    cursor: pointer;
}

.ch-edit-toggle:hover { color: #fff; }

.ch-edit {
    margin-top: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.ch-edit .ch-addrow { grid-template-columns: 1fr 1fr; }

/* ===== Unterer Bereich ===== */
.ch-grid2 {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0 18px;
    align-items: start;
}

.ch-log {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 340px;
    overflow-y: auto;
}

.ch-log li {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}

.ch-log li:last-child { border-bottom: 0; }
.ch-log strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-delta { font: 700 0.95rem var(--font-fun); }
.ch-log .down .ch-delta { color: var(--bad); }
.ch-log .up .ch-delta { color: var(--good); }
.ch-after, .ch-log time { color: var(--text-muted); font-size: 0.82rem; }

@media (max-width: 760px) {
    .ch-grid2 { grid-template-columns: 1fr; }
    .ch-connect { grid-template-columns: 1fr; gap: 10px; }
    .ch-points { font-size: 3.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    .bump-down .ch-points, .bump-up .ch-points { animation: none; }
    .ch-bar span { transition: none; }
}
