@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Work+Sans:wght@400;500;600;700&display=swap');

:root {
    --bg-deep: #1c1712;
    --bg-panel: #262019;
    --bg-panel-raised: #2f271e;
    --line: #443a2c;
    --parchment: #efe6d3;
    --ink: #f3ecdd;
    --ink-dim: #c9bea7;
    --gold: #c9a13b;
    --gold-bright: #e2bc5c;
    --green: #5c7a5c;
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --danger: #b4503a;
    --success: #6f8f5c;
    --radius: 10px;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    background:
        radial-gradient(circle at 15% 0%, #2a2115 0%, transparent 45%),
        radial-gradient(circle at 85% 100%, #241e17 0%, transparent 50%),
        var(--bg-deep);
    background-attachment: fixed;
    color: var(--ink);
    font-family: 'Work Sans', sans-serif;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    color: var(--parchment);
    margin: 0 0 .5rem;
    letter-spacing: .2px;
}

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* ---------- Navbar ---------- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(0,0,0,.15), transparent);
}

.navbar .brand {
    font-family: 'Fraunces', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold-bright);
    display: flex;
    align-items: center;
    gap: 10px;
}
.navbar .brand .glyph { font-size: 1.6rem; }

.navbar nav { display: flex; gap: 22px; align-items: center; }
.navbar nav a {
    color: var(--ink-dim);
    font-weight: 500;
    font-size: .95rem;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}
.navbar nav a.active, .navbar nav a:hover {
    color: var(--gold-bright);
    border-bottom-color: var(--gold);
    text-decoration: none;
}
.navbar nav a.nav-my-turn {
    position: relative;
    color: var(--gold-bright);
    animation: navMyTurnGlow 1.6s ease-in-out infinite;
}
.navbar nav a.nav-my-turn::after {
    content: '';
    position: absolute; top: 2px; right: -10px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--gold-bright);
    animation: navMyTurnDot 1.6s ease-in-out infinite;
}
@keyframes navMyTurnGlow {
    0%, 100% { text-shadow: 0 0 0 rgba(226,188,92,0); }
    50% { text-shadow: 0 0 10px rgba(226,188,92,.85); }
}
@keyframes navMyTurnDot {
    0%, 100% { opacity: .4; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.15); }
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid var(--gold);
    background: transparent;
    color: var(--gold-bright);
    font-weight: 600;
    font-family: 'Work Sans', sans-serif;
    cursor: pointer;
    font-size: .92rem;
    transition: background .15s, color .15s, transform .1s;
}
.btn:hover { background: var(--gold); color: #201a10; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--gold); color: #201a10; }
.btn-primary:hover { background: var(--gold-bright); }
.btn-danger { border-color: var(--danger); color: #f3c3b6; }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-logout {
    background: #7a2418; border: 1px solid #7a2418; color: #f5e2dd;
    padding: 12px 28px; font-weight: 700;
}
.btn-logout:hover { background: #93301f; border-color: #93301f; color: white; }

/* ---------- Einstellungen: Benachrichtigungs-Optionen ---------- */
.notify-option {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 16px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.notify-option:last-of-type { border-bottom: none; }
.notify-option input[type="checkbox"] {
    width: 20px; height: 20px; margin-top: 3px; accent-color: var(--gold); flex-shrink: 0; cursor: pointer;
}
.notify-option b { color: var(--parchment); }
.notify-option p { margin: 4px 0 0; color: var(--ink-dim); font-size: .85rem; }
.notify-option p.battery-hint {
    margin-top: 8px; padding: 8px 10px; border-radius: 6px;
    background: rgba(201,161,59,.08); border: 1px solid rgba(201,161,59,.25);
    font-size: .78rem;
}
.notify-option.disabled { opacity: .55; cursor: not-allowed; }
.notify-option.disabled input { cursor: not-allowed; }
@media (max-width: 700px) {
    .notify-option { padding: 14px 0; }
}
.btn-small { padding: 6px 14px; font-size: .82rem; }
.btn-block { width: 100%; }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}
.auth-card .glyph-row { text-align: center; font-size: 2.4rem; margin-bottom: 6px; }
.auth-card h1 { text-align: center; font-size: 1.6rem; }
.auth-card p.sub { text-align: center; color: var(--ink-dim); margin-bottom: 24px; font-size: .9rem; }

.tabs { display: flex; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.tabs button {
    flex: 1; background: none; border: none; color: var(--ink-dim);
    padding: 10px 0; font-family: 'Fraunces', serif; font-size: 1.05rem; cursor: pointer;
    border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--gold-bright); border-bottom-color: var(--gold); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: .82rem; color: var(--ink-dim); margin-bottom: 6px; }
.field input {
    width: 100%; padding: 11px 13px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--bg-deep); color: var(--ink); font-size: .95rem; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--gold); }
.field small.hint { display: block; margin-top: 5px; color: var(--ink-dim); font-size: .75rem; }

.msg { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: .88rem; display: none; }
.msg.error { background: rgba(180,80,58,.15); border: 1px solid var(--danger); color: #f3c3b6; }
.msg.success { background: rgba(111,143,92,.15); border: 1px solid var(--success); color: #cfe3c0; }

/* ---------- Cards / Layout ---------- */
.page-header { padding: 40px 0 24px; }
.page-header p { color: var(--ink-dim); }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 800px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
}
.card h3 { font-size: 1.05rem; margin-bottom: 14px; }

.stat-card { text-align: center; padding: 28px 20px; }
.stat-card .num { font-family: 'Fraunces', serif; font-size: 2.6rem; font-weight: 700; }
.stat-card .label { color: var(--ink-dim); font-size: .85rem; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.stat-card.win .num { color: var(--success); }
.stat-card.loss .num { color: var(--danger); }
.stat-card.resign .num { color: var(--gold); }

.list-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .72rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.badge.active { background: rgba(201,161,59,.18); color: var(--gold-bright); }
.badge.turn { background: rgba(111,143,92,.25); color: #cfe3c0; }
.badge.done { background: rgba(120,120,120,.2); color: var(--ink-dim); }

/* ---------- Friends page ---------- */
.search-box input {
    width: 100%; padding: 13px 16px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--bg-deep); color: var(--ink); font-size: 1rem;
}
.search-results { margin-top: 10px; }
.result-row, .friend-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
    background: var(--bg-panel-raised);
}
.friend-row { cursor: pointer; }
.friend-row:hover { border-color: var(--gold); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--gold);
    color: #201a10; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-family: 'Fraunces', serif; margin-right: 12px;
}
.result-left, .friend-left { display: flex; align-items: center; }

.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
    align-items: center; justify-content: center; z-index: 50;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 28px; width: 100%; max-width: 480px; max-height: 80vh; overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal .close-x { float: right; cursor: pointer; color: var(--ink-dim); font-size: 1.3rem; }

/* ---------- Play page ---------- */
.friend-pick {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px;
}
.color-choice { display: flex; gap: 8px; }
.color-choice button {
    background: var(--bg-deep); border: 1px solid var(--line); color: var(--ink);
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: .82rem;
}
.color-choice button.selected { border-color: var(--gold); color: var(--gold-bright); }

/* ---------- Game page ---------- */
.game-layout { display: grid; grid-template-columns: auto 320px; gap: 30px; align-items: start; }
@media (max-width: 900px) { .game-layout { grid-template-columns: 1fr; } }

.board-wrap { display: flex; flex-direction: column; align-items: center; }
.player-tag {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    max-width: 560px; padding: 8px 4px; color: var(--ink-dim); font-size: .9rem;
}
.player-tag.active-turn { color: var(--gold-bright); font-weight: 600; }

.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; }
.sq.light { background: var(--board-light); }
.sq.dark { background: var(--board-dark); }
.sq.selected { box-shadow: inset 0 0 0 4px var(--gold); }
.sq.legal::after {
    content: ''; position: absolute; width: 36%; height: 36%; border-radius: 50%;
    background: rgba(201,161,59,.9);
    box-shadow: 0 0 0 3px rgba(28,23,18,.25), 0 2px 5px rgba(0,0,0,.4);
    pointer-events: none;
}
.sq.legal-capture {
    box-shadow: inset 0 0 0 4px var(--danger);
}
.sq.legal-capture::after {
    content: ''; position: absolute; inset: 4%; border-radius: 50%;
    border: 4px solid var(--danger);
    box-shadow: 0 0 8px rgba(180,80,58,.6);
    pointer-events: none;
}
.sq.last-move {
    box-shadow: inset 0 0 0 999px rgba(201,161,59,.38), inset 0 0 0 3px rgba(201,161,59,.85);
}
.sq.selected.last-move { box-shadow: inset 0 0 0 4px var(--gold), inset 0 0 0 999px rgba(201,161,59,.2); }
.sq.last-move-flash {
    animation: lastMoveFlash 0.7s ease-in-out 2;
}
@keyframes lastMoveFlash {
    0%, 100% { box-shadow: inset 0 0 0 999px rgba(201,161,59,.38), inset 0 0 0 3px rgba(201,161,59,.85); }
    50% { box-shadow: inset 0 0 0 999px rgba(226,188,92,.75), inset 0 0 0 4px rgba(226,188,92,1); }
}
.sq.in-check { box-shadow: inset 0 0 0 999px rgba(180,60,40,.55); }

.coord-file, .coord-rank { position: absolute; font-size: .6rem; color: rgba(0,0,0,.35); }
.coord-file { bottom: 2px; right: 3px; }
.coord-rank { top: 2px; left: 3px; }

.side-panel .card { margin-bottom: 16px; }
.status-line { font-family: 'Fraunces', serif; font-size: 1.15rem; margin-bottom: 6px; }
.move-list { max-height: 240px; overflow-y: auto; font-size: .85rem; }
.move-list div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }

.invite-row { display: flex; gap: 8px; margin-top: 10px; }
.invite-row input {
    flex: 1; padding: 9px 10px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--bg-deep); color: var(--ink-dim); font-size: .78rem;
}

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-dim); }
.empty-state .glyph { font-size: 2.4rem; display: block; margin-bottom: 10px; }

footer.note { text-align: center; color: var(--ink-dim); font-size: .78rem; padding: 30px 0 10px; }

/* ---------- Mobile-Optimierung ---------- */
@media (max-width: 720px) {
    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 16px;
    }
    .navbar .brand { justify-content: center; font-size: 1.2rem; }
    .navbar nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 14px 18px;
        row-gap: 10px;
    }
    .navbar nav span { display: none; }
    .navbar nav a { font-size: .88rem; }
    .navbar .btn-small { padding: 8px 16px; }

    .container { padding: 0 14px 40px; }
    .page-header { padding: 26px 0 16px; }
    .page-header h1 { font-size: 1.4rem; }
    .page-header p { font-size: .88rem; }

    .card { padding: 18px; }
    .stat-card { padding: 20px 12px; }
    .stat-card .num { font-size: 2rem; }

    .auth-wrap { padding: 12px; }
    .auth-card { padding: 28px 22px; }

    .tabs button { font-size: .95rem; }

    .friend-pick, .friend-row, .result-row, .list-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .list-row > div:last-child { flex-wrap: wrap; }
    .friend-pick > div:last-child, .friend-row > div:last-child { width: 100%; }
    .color-choice { flex-wrap: wrap; }
    .friend-row .btn, .result-row .btn { width: 100%; text-align: center; }

    .modal { padding: 20px; width: 92vw; }
    .invite-row { flex-direction: column; }
    .invite-row input { font-size: .75rem; word-break: break-all; }

    .game-layout { gap: 20px; }
    .side-panel .card { padding: 16px; }
    .board-stack { width: 96vw; height: 96vw; }
    .sq .piece { font-size: min(9vw, 40px); }

    table, .move-list { font-size: .8rem; }
}

@media (max-width: 420px) {
    .navbar nav { gap: 10px 14px; }
    .navbar nav a { font-size: .82rem; }
    .stat-card .num { font-size: 1.7rem; }
    .avatar { width: 30px; height: 30px; font-size: .85rem; margin-right: 8px; }
}

/* ---------- Achievement Toasts (schwebend, alle Seiten) ---------- */
#achievement-toast-container {
    position: fixed; top: 16px; right: 16px; z-index: 999;
    display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
@media (max-width: 700px) {
    #achievement-toast-container { left: 12px; right: 12px; top: 10px; max-width: none; }
}
.ach-toast {
    display: flex; gap: 12px; align-items: flex-start;
    background: linear-gradient(135deg, var(--bg-panel-raised), var(--bg-panel));
    border: 1px solid var(--gold);
    box-shadow: 0 12px 30px rgba(0,0,0,.5);
    border-radius: 10px; padding: 14px 16px;
    transform: translateY(-16px); opacity: 0;
    transition: transform .35s ease, opacity .35s ease;
}
.ach-toast.show { transform: translateY(0); opacity: 1; }
.ach-toast-icon { font-size: 1.8rem; line-height: 1; }
.ach-toast-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .8px; color: var(--gold-bright); font-weight: 700; }
.ach-toast-title { font-family: 'Fraunces', serif; font-size: 1.02rem; color: var(--parchment); margin: 2px 0; }
.ach-toast-desc { font-size: .78rem; color: var(--ink-dim); }

/* ---------- Achievement Banner (Dashboard) ---------- */
.ach-banner {
    display: flex; align-items: center; gap: 14px;
    background: linear-gradient(90deg, rgba(201,161,59,.18), rgba(201,161,59,.05));
    border: 1px solid var(--gold);
    border-radius: 10px; padding: 14px 18px; margin-bottom: 12px;
}
.ach-banner-icon { font-size: 2rem; }
.ach-banner-body { flex: 1; }
.ach-banner-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--gold-bright); font-weight: 700; }
.ach-banner-title { font-family: 'Fraunces', serif; font-size: 1.05rem; color: var(--parchment); }
.ach-banner-close { background: none; border: none; color: var(--ink-dim); font-size: 1.4rem; cursor: pointer; line-height: 1; }
@media (max-width: 700px) {
    .ach-banner { flex-wrap: wrap; padding: 12px 14px; }
    .ach-banner-title { font-size: .92rem; }
}

/* ---------- Board: Sliding-Piece-Layer ---------- */
.board-stack { position: relative; width: min(560px, 92vw); height: min(560px, 92vw); }
.board-stack #board {
    position: absolute; inset: 0; z-index: 1;
    display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
    border: 6px solid var(--bg-panel-raised); border-radius: 4px; box-shadow: var(--shadow);
}
#pieces-layer { position: absolute; inset: 6px; z-index: 2; pointer-events: none; }
.piece-el {
    position: absolute; width: 12.5%; height: 12.5%;
    display: flex; align-items: center; justify-content: center;
    font-size: min(7vw, 42px); line-height: 1;
    transition: left .35s ease, top .35s ease, opacity .25s ease, transform .25s ease;
    will-change: left, top;
}
.piece-el svg { display: block; width: 82%; height: 82%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.piece-el.captured-fade { opacity: 0; transform: scale(.4); }

@keyframes knightHop {
    0% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-34%) scale(1.08); }
    100% { transform: translateY(0) scale(1); }
}
.piece-el.piece-hop {
    animation: knightHop 0.46s ease-out;
}

@keyframes pawnWalk {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8%) rotate(-4deg); }
    50% { transform: translateY(0) rotate(0deg); }
    75% { transform: translateY(-8%) rotate(4deg); }
}
.piece-el.piece-walk {
    animation: pawnWalk 0.25s ease-in-out 2;
    transform-origin: 50% 90%;
}

@keyframes bishopGlide {
    0% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(-10%) rotate(-3deg); }
    60% { transform: translateY(-4%) rotate(3deg); }
    100% { transform: translateY(0) rotate(0deg); }
}
.piece-el.piece-glide {
    animation: bishopGlide 0.62s ease-in-out;
    transform-origin: 50% 90%;
}

@keyframes royalFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    45% { transform: translateY(-14%) scale(1.06); }
    70% { transform: translateY(-4%) scale(1.02); }
}
.piece-el.piece-float {
    animation: royalFloat 0.56s ease-in-out;
    transform-origin: 50% 90%;
}

.piece-el.knight-wink svg circle:last-of-type {
    animation: knightWinkBlink 0.4s ease-in-out;
    transform-box: fill-box;
    transform-origin: center;
}
@keyframes knightWinkBlink {
    0%, 100% { transform: scaleY(1); }
    45% { transform: scaleY(0.12); }
    65% { transform: scaleY(0.12); }
}

.piece-el.king-fallen {
    transform: rotate(90deg) translateY(8px);
    opacity: 0.55;
    transition: transform 1s ease-in, opacity 1s ease-in;
}
@media (max-width: 720px) {
    .piece-el { font-size: min(9vw, 40px); }
}

/* ---------- Wartestatus ---------- */
.status-line.waiting { color: var(--ink-dim); }
.status-line.my-turn {
    color: var(--gold-bright);
    animation: myTurnPulse 1.4s ease-in-out infinite;
}
@keyframes myTurnPulse {
    0%, 100% { text-shadow: 0 0 0 rgba(226,188,92,0); transform: scale(1); }
    50% { text-shadow: 0 0 14px rgba(226,188,92,.75); transform: scale(1.04); }
}
.waiting-dots::after {
    content: '…'; display: inline-block; width: 1.2em; text-align: left;
    animation: waitingDots 1.4s infinite steps(4);
    overflow: hidden; vertical-align: bottom;
}
@keyframes waitingDots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75%, 100% { content: '...'; } }

/* ---------- Geschlagene Figuren ---------- */
.captured-bar {
    width: min(560px, 92vw); display: flex; flex-direction: column; gap: 8px; margin-top: 14px;
}
.captured-row {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 30px;
    background: var(--board-dark); border: 1px solid var(--line); border-radius: 8px;
    padding: 6px 12px;
}
.captured-row .cap-label { font-size: .72rem; color: var(--parchment); margin-right: 6px; white-space: nowrap; opacity: .85; }
.captured-row .cap-piece { display: inline-flex; width: 22px; height: 22px; cursor: pointer; transition: transform .12s ease; }
.captured-row .cap-piece:hover { transform: scale(1.25); }
.captured-row .cap-piece svg { width: 100%; height: 100%; }

/* ---------- Laufende Spiele oben auf "Spiel"-Seite ---------- */
.active-game-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border: 1px solid var(--gold); border-radius: 8px; margin-bottom: 10px;
    background: rgba(201,161,59,.08);
}
@media (max-width: 700px) {
    .active-game-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .active-game-row > div:last-child { width: 100%; }
    .active-game-row .btn { width: 100%; text-align: center; }
}

/* ---------- Profil / Achievements Modal ---------- */
.ach-filter.active { background: var(--gold); color: #201a10; }
@media (max-width: 700px) {
    .modal { max-height: 88vh; }
}

/* ---------- Rangliste ---------- */
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.lb-table th {
    color: var(--ink-dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .6px;
    border-bottom: 1px solid var(--gold); font-weight: 600;
}
.lb-table td.lb-rank { font-family: 'Fraunces', serif; font-size: 1.1rem; text-align: center; width: 44px; }
.lb-table td.lb-name { font-weight: 600; color: var(--parchment); }
.lb-table td.lb-num { text-align: center; color: var(--ink-dim); }
.lb-table .lb-win { color: var(--success); font-weight: 600; }
.lb-table .lb-loss { color: var(--danger); }
.lb-table tr.lb-me { background: rgba(201,161,59,.1); }
.lb-table tr:last-child td { border-bottom: none; }

@media (max-width: 700px) {
    .lb-table thead { display: none; }
    .lb-table, .lb-table tbody { display: block; width: 100%; }
    .lb-table tr {
        display: flex; flex-wrap: wrap; align-items: center;
        border: 1px solid var(--line); border-radius: 12px;
        padding: 14px 16px; margin-bottom: 12px;
        background: var(--bg-panel-raised);
    }
    .lb-table tr.lb-me { border-color: var(--gold); background: rgba(201,161,59,.08); }
    .lb-table td { display: block; border: none; padding: 0; text-align: left; }

    .lb-table td.lb-rank {
        order: 1; width: auto; font-size: 1.5rem; margin-right: 10px; flex-shrink: 0;
    }
    .lb-table td.lb-name { order: 2; flex: 1; font-size: 1.05rem; }
    .lb-table td.lb-score {
        order: 3; text-align: right; font-family: 'Fraunces', serif;
        font-size: 1.4rem; font-weight: 700; color: var(--gold-bright);
    }
    .lb-table td.lb-score::before { content: none; }

    .lb-table td[data-label]:not(.lb-score) {
        order: 4; flex: 1 1 30%; text-align: center;
        background: var(--bg-deep); border-radius: 8px; padding: 8px 4px;
        margin: 12px 3px 0; font-weight: 700; font-size: .88rem;
    }
    .lb-table td.lb-win { background: rgba(111,143,92,.15); }
    .lb-table td.lb-loss { background: rgba(180,80,58,.15); }
    .lb-table td[data-label]::before {
        content: attr(data-label); display: block; color: var(--ink-dim);
        font-size: .64rem; text-transform: uppercase; letter-spacing: .4px;
        margin-bottom: 3px; font-weight: 500;
    }
    .lb-table td.lb-name::before, .lb-table td.lb-rank::before { content: none; }
}

/* ---------- Freunde-Statistik-Modal (huebsches Design) ---------- */
.stats-modal-fancy { padding-top: 28px; }
.stats-hero {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line);
}
.stats-hero-avatar {
    width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--gold-bright), var(--gold));
    color: #201a10; display: flex; align-items: center; justify-content: center;
    font-family: 'Fraunces', serif; font-size: 1.6rem; font-weight: 700;
    box-shadow: 0 4px 12px rgba(201,161,59,.3);
}
.stats-hero-presence { color: var(--ink-dim); font-size: .85rem; display: flex; align-items: center; }
.presence-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: #6b6558; margin-right: 6px;
}
.presence-dot.online { background: var(--success); box-shadow: 0 0 6px rgba(111,143,92,.8); }

.stats-points-badge {
    background: linear-gradient(135deg, var(--gold-bright), var(--gold));
    color: #201a10; font-weight: 700; font-family: 'Fraunces', serif;
    padding: 8px 14px; border-radius: 20px; font-size: .95rem; white-space: nowrap;
    box-shadow: 0 4px 10px rgba(201,161,59,.3); cursor: default;
}
@media (max-width: 700px) {
    .stats-points-badge { font-size: .82rem; padding: 6px 10px; }
}

.stats-section-label {
    font-family: 'Fraunces', serif; font-size: 1rem; color: var(--parchment);
    margin-bottom: 10px;
}
.stats-ach-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 10px; margin-bottom: 18px; max-height: 220px; overflow-y: auto; padding: 2px;
}
.stats-ach-badge {
    background: var(--bg-panel-raised); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 6px; text-align: center; transition: border-color .15s, transform .15s;
}
.stats-ach-badge:hover { border-color: var(--gold); transform: translateY(-2px); }
.stats-ach-icon { font-size: 1.7rem; margin-bottom: 4px; }
.stats-ach-title {
    font-size: .68rem; color: var(--ink-dim); line-height: 1.2;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.result-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.result-dot.win { background: var(--success); }
.result-dot.loss { background: var(--danger); }
.result-dot.neutral { background: var(--gold); }

@media (max-width: 700px) {
    .stats-hero-avatar { width: 48px; height: 48px; font-size: 1.3rem; }
    .stats-ach-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}

/* ---------- "Push an Gegner gesendet"-Hinweis im Spiel ---------- */
.push-sent-note {
    font-size: .78rem; color: var(--ink-dim); margin-top: 4px;
    display: flex; align-items: center; gap: 6px; justify-content: center;
}
#opponent-presence-note {
    font-size: .88rem; font-weight: 600; margin-top: 0; margin-bottom: 6px;
}

/* ---------- Push-Setup-Modal ---------- */
.push-setup-modal { max-width: 420px; text-align: center; }
.push-setup-modal h3 { margin-bottom: 12px; }
.push-setup-modal ol { text-align: left; }
#push-setup-overlay { z-index: 200; }

/* ---------- Spiel-Chat ---------- */
.chat-messages {
    max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
    padding: 4px 2px; margin-bottom: 10px;
}
.chat-bubble-row { display: flex; justify-content: flex-start; }
.chat-bubble-row.me { justify-content: flex-end; }
.chat-bubble {
    max-width: 80%; background: var(--bg-panel-raised); border: 1px solid var(--line);
    border-radius: 12px; padding: 8px 12px; font-size: .85rem;
}
.chat-bubble-row.me .chat-bubble {
    background: rgba(201,161,59,.18); border-color: rgba(201,161,59,.4);
}
.chat-bubble-sender { font-size: .72rem; font-weight: 700; color: var(--gold-bright); margin-bottom: 2px; }
.chat-bubble-text { color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.chat-bubble-time { font-size: .68rem; color: var(--ink-dim); margin-top: 3px; text-align: right; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input {
    flex: 1; padding: 9px 12px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--bg-deep); color: var(--ink); font-size: .88rem; font-family: inherit;
}
.chat-input-row input:focus { outline: none; border-color: var(--gold); }
@media (max-width: 700px) {
    .chat-messages { max-height: 200px; }
    .chat-bubble { max-width: 90%; }
}

/* ---------- Unentschieden-Angebot ---------- */
.draw-respond-modal-fancy { padding-top: 10px; }
.draw-respond-icon {
    font-size: 2.6rem; text-align: center; margin-bottom: 6px;
    animation: drawPulse 1.6s ease-in-out infinite;
}
@keyframes drawPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

/* ---------- Wiedergabe-Leiste (Partie im Schnelldurchlauf ansehen) ---------- */
.replay-bar {
    width: min(560px, 92vw); margin-top: 14px; background: var(--bg-panel);
    border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.replay-scrub-row { margin-bottom: 8px; }
.replay-scrub-row input[type="range"] {
    width: 100%; -webkit-appearance: none; appearance: none; height: 5px;
    background: var(--bg-deep); border-radius: 4px; outline: none; cursor: pointer;
}
.replay-scrub-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
    border-radius: 50%; background: var(--gold); cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.replay-scrub-row input[type="range"]::-moz-range-thumb {
    width: 15px; height: 15px; border-radius: 50%; background: var(--gold);
    cursor: pointer; border: none;
}
.replay-controls-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.replay-btn {
    background: var(--bg-panel-raised); border: 1px solid var(--line); color: var(--ink);
    width: 34px; height: 34px; border-radius: 6px; cursor: pointer; font-size: .95rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.replay-btn:hover { border-color: var(--gold); color: var(--gold-bright); }
.replay-play-btn { background: var(--gold); color: #201a10; border-color: var(--gold); }
.replay-play-btn:hover { background: var(--gold-bright); color: #201a10; }
#replay-speed {
    background: var(--bg-deep); color: var(--ink); border: 1px solid var(--line);
    border-radius: 6px; padding: 6px 8px; font-size: .82rem; cursor: pointer;
}
.replay-counter {
    margin-left: auto; color: var(--ink-dim); font-size: .8rem; white-space: nowrap;
}
@media (max-width: 700px) {
    .replay-btn { width: 30px; height: 30px; font-size: .85rem; }
    .replay-counter { width: 100%; text-align: center; margin: 4px 0 0; order: 10; }
}

/* ---------- Chat-Hinweis oben im Spiel ---------- */
#chat-toast-container {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    z-index: 150; display: flex; flex-direction: column; gap: 8px;
    width: min(340px, 90vw); pointer-events: none;
}
.chat-top-toast {
    background: linear-gradient(135deg, var(--bg-panel-raised), var(--bg-panel));
    border: 1px solid var(--gold); border-radius: 10px; padding: 10px 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,.4);
    opacity: 0; transform: translateY(-14px);
    transition: opacity .3s ease, transform .3s ease;
}
.chat-top-toast.show { opacity: 1; transform: translateY(0); }
.chat-top-toast-sender {
    font-size: 11px; color: var(--gold-bright); font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px;
}
.chat-top-toast-text { font-size: .88rem; color: var(--parchment); }

/* ---------- Patt-Erklärung ---------- */
.stalemate-box {
    margin-top: 14px; padding: 12px 14px; border-radius: 8px;
    background: rgba(201,161,59,.08); border: 1px solid rgba(201,161,59,.3);
    font-size: .85rem; color: var(--ink-dim); text-align: left;
}
.stalemate-box b { color: var(--gold-bright); }
.stalemate-box ul { color: var(--ink-dim); }
.stalemate-box li { margin-bottom: 3px; }

/* ---------- Rangliste: Score ---------- */
.lb-score { font-weight: 700; color: var(--gold-bright); }
.lb-clickable { cursor: pointer; }
.lb-clickable:hover { background: rgba(201,161,59,.08); }

.score-formula {
    font-family: 'Fraunces', serif; font-size: .95rem; text-align: center;
    color: var(--parchment); background: var(--bg-deep); border-radius: 8px;
    padding: 12px; margin: 12px 0 18px; border: 1px solid var(--line);
}
.score-row {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
    padding: 10px 0; border-bottom: 1px solid var(--line);
}
.score-row:last-child { border-bottom: none; }
.score-row-label { font-weight: 600; color: var(--parchment); }
.score-row-desc { grid-column: 1; color: var(--ink-dim); font-size: .78rem; }
.score-row-value {
    grid-row: 1 / 3; grid-column: 2; align-self: center;
    font-family: 'Fraunces', serif; font-size: 1.1rem; color: var(--gold-bright);
    min-width: 55px; text-align: right;
}
.score-total {
    margin-top: 16px; padding-top: 14px; border-top: 2px solid var(--gold);
    text-align: center; font-size: 1.15rem; color: var(--parchment);
}
.score-total b { font-family: 'Fraunces', serif; font-size: 1.5rem; color: var(--gold-bright); }

/* ---------- Figuren-Stil-Auswahl ---------- */
.piece-style-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px;
}
.piece-style-card {
    position: relative; background: var(--bg-panel-raised); border: 2px solid var(--line);
    border-radius: 10px; padding: 14px 10px; text-align: center; cursor: pointer;
    transition: border-color .15s ease;
}
.piece-style-card:hover { border-color: var(--gold); }
.piece-style-card.active { border-color: var(--gold); background: rgba(201,161,59,.1); }
.piece-style-preview-row { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
.piece-style-preview-icon { width: 34px; height: 34px; }
.piece-style-name { font-size: .85rem; font-weight: 600; color: var(--parchment); }
.piece-style-badge {
    position: absolute; top: 8px; right: 8px; background: var(--gold); color: #201a10;
    font-size: .65rem; font-weight: 700; padding: 2px 8px; border-radius: 10px;
}

/* ---------- Meldung: Aktivität in anderen (nicht geöffneten) Partien ---------- */
#other-game-toast-container {
    position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
    z-index: 160; display: flex; flex-direction: column; gap: 6px;
    width: min(380px, 92vw);
}
.other-game-toast {
    background: rgba(38, 32, 25, 0.68); backdrop-filter: blur(3px);
    border: 1px solid rgba(201,161,59,.35); border-radius: 8px;
    padding: 8px 14px; font-size: .82rem; color: rgba(243,236,221,.92);
    opacity: 0; transform: translateY(-10px); transition: opacity .3s ease, transform .3s ease;
    cursor: pointer; text-align: center;
}
.other-game-toast:hover { background: rgba(38, 32, 25, 0.85); }
.other-game-toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Punkte-Legende (deutlicher als Fließtext) ---------- */
.points-legend { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.points-legend-title { font-size: .8rem; font-weight: 600; color: var(--ink-dim); margin-bottom: 8px; }
.points-legend-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-chip {
    background: var(--bg-deep); border: 1px solid var(--line); border-radius: 20px;
    padding: 5px 12px; font-size: .78rem; color: var(--parchment); white-space: nowrap;
}
.legend-chip b { color: var(--gold-bright); font-weight: 700; margin-left: 2px; }
.legend-chip.good { border-color: rgba(111,143,92,.5); }
.legend-chip.good b { color: var(--success, #6f8f5c); }
.legend-chip.neutral b { color: var(--gold-bright); }
.legend-chip.bad { border-color: rgba(180,80,58,.5); }
.legend-chip.bad b { color: var(--danger); }

/* ---------- Mini-Schachbrett im "Figur geschlagen"-Modal ---------- */
.mini-board-wrap {
    position: relative; width: 200px; height: 200px; margin: 4px auto 16px;
    border: 4px solid var(--bg-panel-raised); border-radius: 4px; overflow: hidden;
}
.mini-board-grid {
    position: absolute; inset: 0; display: grid;
    grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
}
.mini-sq.light { background: var(--board-light, #e8dcc0); }
.mini-sq.dark { background: var(--board-dark, #9c7b52); }
.mini-pieces-layer { position: absolute; inset: 0; }
.mini-piece-el { position: absolute; width: 12.5%; height: 12.5%; }
.mini-piece-el svg { width: 100%; height: 100%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }

/* ---------- Meine Figuren (Verlust-Übersicht) ---------- */
.piece-loss-board { display: flex; flex-direction: column; gap: 10px; }
.piece-loss-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.piece-loss-cell {
    background: var(--bg-panel-raised); border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.piece-loss-icon { width: 38px; height: 38px; }
.piece-loss-count { font-size: .82rem; font-weight: 700; color: var(--ink-dim); }
.piece-loss-count.lost { color: var(--danger); }
@media (max-width: 700px) {
    .piece-loss-row { gap: 4px; }
    .piece-loss-cell { padding: 6px 2px 5px; }
    .piece-loss-icon { width: 26px; height: 26px; }
    .piece-loss-count { font-size: .7rem; }
}

/* ---------- Fliegende Punkte-Anzeige beim Schlagen ---------- */
.floating-points {
    position: absolute; width: 12.5%; height: 12.5%;
    display: flex; align-items: center; justify-content: center;
    color: var(--success); font-weight: 800; font-size: 1.15rem;
    text-shadow: 0 1px 3px rgba(0,0,0,.7), 0 0 8px rgba(111,143,92,.5);
    pointer-events: none; z-index: 6;
    animation: floatUpFade 1.3s ease-out forwards;
}
@keyframes floatUpFade {
    0% { opacity: 0; transform: translateY(6px) scale(0.8); }
    15% { opacity: 1; transform: translateY(0) scale(1.2); }
    70% { opacity: 1; transform: translateY(-28px) scale(1); }
    100% { opacity: 0; transform: translateY(-46px) scale(0.9); }
}

/* ---------- Leerlauf-Animation: Figuren wirken "lebendig" ---------- */
.piece-el.idle-wiggle {
    animation: idleWiggle 0.7s ease-in-out;
    transform-origin: 50% 85%;
}
@keyframes idleWiggle {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    22% { transform: rotate(-4deg) translateY(-1px); }
    50% { transform: rotate(3deg) translateY(-2px); }
    78% { transform: rotate(-1.5deg) translateY(0); }
}
