/* ── Palette: ein rostiges Hinterzimmer ───────────────────────── */
:root {
    --soot:    #16130f; /* warmes Fast-Schwarz, Hintergrund      */
    --ash:     #211c16; /* Panel                                 */
    --ash-hi:  #2c251c; /* Panel, erhoeht                        */
    --rust:    #b4451f; /* oxidiertes Rost-Orange, Akzent        */
    --rust-hi: #d05a2c;
    --ember:   #e0982f; /* warmer Hochton: Pot, Chips            */
    --patina:  #5f7a6b; /* oxidiertes Kupfergruen, Filz          */
    --patina-d:#36473e;
    --bone:    #e8ddc7; /* gealtertes Bein/Pergament, Text       */
    --bone-dim:#a99f8b;
    --line:    #4a3f31; /* Trennlinien, gealtertes Metall        */
    --red:     #c0331f; /* Herz/Karo                             */
    --ok:      #87a06f;
    --bad:     #c0552f;

    --display: "Bahnschrift", "Haettenschweiler", "Impact",
               "Arial Narrow", system-ui, sans-serif;
    --body:    "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono:    "Consolas", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    min-height: 100%;
    font-family: var(--body);
    color: var(--bone);
    /* Korn/Grime ueber dem Soot, rein per CSS */
    background-color: var(--soot);
    background-image:
        radial-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
        radial-gradient(rgba(0,0,0,0.30) 1px, transparent 1px);
    background-size: 4px 4px, 7px 7px;
    background-position: 0 0, 2px 3px;
}

/* ── Views ────────────────────────────────────────────────────── */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; }

/* ── Wortmarke ────────────────────────────────────────────────── */
.brand {
    font-family: var(--display);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 0.92;
}
.brand .crusty { color: var(--rust); }
.brand .cards  { color: var(--bone); }

/* ── HOME ─────────────────────────────────────────────────────── */
#home, #auth {
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.home-card {
    width: 100%;
    max-width: 380px;
    background: var(--ash);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
    padding: 2.25rem 2rem 2rem;
}
.home-card .brand { font-size: 2.9rem; margin-bottom: 0.35rem; }
.tagline {
    color: var(--bone-dim);
    font-size: 0.9rem;
    margin: 0 0 2rem;
    border-left: 3px solid var(--rust);
    padding-left: 0.7rem;
}
.home-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.7rem;
}

label {
    display: block;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bone-dim);
    margin: 0 0 0.4rem;
}
input[type="text"], input[type="password"] {
    width: 100%;
    padding: 0.65rem 0.7rem;
    font-size: 1rem;
    font-family: var(--body);
    color: var(--bone);
    background: var(--soot);
    border: 1px solid var(--line);
    border-radius: 3px;
    margin-bottom: 1.2rem;
}
input::placeholder { color: #6c6353; }
input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--rust);
    box-shadow: 0 0 0 3px rgba(180,69,31,0.25);
}

.btn {
    font-family: var(--display);
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bone);
    background: var(--ash-hi);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 0.7rem 1rem;
    cursor: pointer;
    transition: transform .05s ease, filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.btn.primary { background: var(--rust); border-color: var(--rust-hi); }
.btn.primary:hover { background: var(--rust-hi); }
.btn.ghost { background: transparent; }

.btn-row { display: flex; gap: 0.7rem; }
.btn-row .btn { flex: 1; }

.status {
    margin: 1.1rem 0 0;
    min-height: 1.1rem;
    font-size: 0.85rem;
    text-align: center;
    color: var(--bone-dim);
}
.status.error { color: var(--bad); }
.status.ok { color: var(--ok); }

/* ── Tisch-Liste auf HOME ─────────────────────────────────────── */
.games-panel {
    margin-top: 1.3rem;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
}
.games-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}
.link-btn {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bone-dim);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.link-btn:hover { color: var(--ember); }
.games-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.games-list li {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(74,63,49,0.4);
}
.games-list li:last-child { border-bottom: none; }
.game-meta { flex: 1; min-width: 0; }
.game-id {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--bone);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.game-sub {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--bone-dim);
    margin-top: 0.15rem;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.game-sub .badge.open    { color: var(--ok);  border-color: var(--ok); }
.game-sub .badge.running { color: var(--ember); border-color: var(--ember); }
.game-sub .badge.closed  { color: var(--bad); border-color: var(--bad); }
.games-list .btn { padding: 0.45rem 0.85rem; font-size: 0.9rem; }
.games-empty {
    font-size: 0.82rem;
    color: var(--bone-dim);
    text-align: center;
    margin: 0.4rem 0 0;
}

/* ── LOBBY ────────────────────────────────────────────────────── */
#lobby { flex-direction: column; align-items: center; padding: 1.5rem; }
.lobby-card {
    width: 100%;
    max-width: 480px;
    background: var(--ash);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
    overflow: hidden;
}
.lobby-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    background: var(--ash-hi);
}
.lobby-head .brand { font-size: 1.3rem; }
.code-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--ember);
    background: var(--soot);
    border: 1px dashed var(--line);
    border-radius: 3px;
    padding: 0.3rem 0.55rem;
    cursor: pointer;
}
.code-chip small {
    color: var(--bone-dim);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.62rem;
}
.seat-list { list-style: none; margin: 0; padding: 0.5rem 0; }
.seat-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid rgba(74,63,49,0.4);
}
.seat-list li:last-child { border-bottom: none; }
.seat-num {
    font-family: var(--mono);
    color: var(--bone-dim);
    font-size: 0.8rem;
    width: 1.6rem;
}
.seat-name { flex: 1; font-weight: 600; }
.badge {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    border-radius: 2px;
    border: 1px solid var(--line);
    color: var(--bone-dim);
}
.badge.host { color: var(--ember); border-color: var(--ember); }
.badge.you  { color: var(--rust); border-color: var(--rust); }
.lobby-foot {
    display: flex;
    gap: 0.7rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--line);
    background: var(--ash-hi);
}
.lobby-foot .btn { flex: 1; }
.lobby-hint {
    text-align: center;
    color: var(--bone-dim);
    font-size: 0.8rem;
    padding: 0.5rem 1.25rem 0.9rem;
}

/* ── GAME / der Tisch ─────────────────────────────────────────── */
#game { flex-direction: column; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--ash);
}
.topbar .brand { font-size: 1.1rem; }
.street-tag {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ember);
}

.table-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1rem 1.5rem;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.opponents {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
    width: 100%;
}

.seat {
    min-width: 130px;
    background: var(--ash);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.55rem 0.7rem;
    position: relative;
}
.seat.turn {
    border-color: var(--ember);
    box-shadow: 0 0 0 1px var(--ember), 0 0 18px rgba(224,152,47,0.35);
    animation: pulse 1.6s ease-in-out infinite;
}
.seat.folded { opacity: 0.45; }
.seat-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.seat .name { font-weight: 600; font-size: 0.92rem; }
.seat .chips {
    font-family: var(--mono);
    color: var(--ember);
    font-size: 0.85rem;
}
.seat .sub {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--bone-dim);
    margin-top: 0.2rem;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.pos {
    font-family: var(--mono);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--soot);
    background: var(--patina);
    border-radius: 50%;
    width: 1.15rem;
    height: 1.15rem;
    display: inline-grid;
    place-items: center;
}
.pos.bb { background: var(--ember); }

.mini-cards { display: flex; gap: 0.25rem; margin-top: 0.45rem; }

/* Der Filz */
.felt {
    width: 100%;
    max-width: 720px;
    border-radius: 140px / 88px;
    background:
        radial-gradient(ellipse at center, var(--patina) 0%, var(--patina-d) 72%, #283731 100%);
    border: 10px solid #2a2118;
    box-shadow:
        inset 0 0 0 2px var(--rust),
        inset 0 0 0 6px rgba(0,0,0,0.25),
        inset 0 0 60px rgba(0,0,0,0.5),
        0 18px 44px rgba(0,0,0,0.55);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    position: relative;
}
.pot {
    font-family: var(--mono);
    text-align: center;
}
.pot .label {
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--bone-dim);
}
.pot .amount {
    font-family: var(--display);
    font-size: 2.2rem;
    color: var(--ember);
    text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}
.pot .bet { font-size: 0.75rem; color: var(--bone-dim); }

.board { display: flex; gap: 0.5rem; }

/* Karten */
.card {
    width: 46px;
    height: 64px;
    border-radius: 5px;
    background: var(--bone);
    color: #1c1814;
    border: 1px solid #cbbfa3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    font-family: var(--display);
    user-select: none;
    animation: deal .28s ease both;
}
.card .card-rank { font-size: 1.35rem; font-weight: 700; }
.card .card-suit { font-size: 1rem; margin-top: 2px; }
.card.red { color: var(--red); }
.card.black { color: #1c1814; }
.card.slot {
    background: transparent;
    border: 1px dashed rgba(232,221,199,0.25);
    box-shadow: none;
    animation: none;
}
.card.back {
    background:
        repeating-linear-gradient(45deg, #7c2e15 0 5px, #5e2310 5px 10px);
    border-color: #3a1408;
}
.card.mini {
    width: 26px; height: 37px; border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.card.mini .card-rank { font-size: 0.8rem; }
.card.mini .card-suit { font-size: 0.62rem; }

/* ── Showdown-Panel ───────────────────────────────────────────── */
.badge.win { color: var(--ember); border-color: var(--ember); }
.seat.won {
    border-color: var(--ember);
    box-shadow: 0 0 0 1px var(--ember), 0 0 18px rgba(224,152,47,0.3);
}

.showdown {
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: rgba(22,19,15,0.78);
    border: 1px solid var(--ember);
    border-radius: 5px;
    padding: 0.7rem 0.9rem;
    box-shadow: 0 10px 28px rgba(0,0,0,0.5);
}
.showdown[hidden] { display: none; }
.showdown-title {
    font-family: var(--display);
    font-size: 0.85rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ember);
    text-align: center;
}
.showdown-winner {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(74,63,49,0.6);
}
.showdown-winner:first-of-type { border-top: none; padding-top: 0; }
.showdown-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.showdown-name { font-weight: 600; }
.card-line { display: flex; align-items: center; gap: 0.5rem; }
.card-line-label {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--bone-dim);
    min-width: 4.5rem;
}

/* Mein Sitz */
.me {
    width: 100%;
    max-width: 720px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--ash);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.8rem 1rem;
}
.me.turn {
    border-color: var(--ember);
    box-shadow: 0 0 0 1px var(--ember), 0 0 22px rgba(224,152,47,0.3);
}
.me-info .name { font-family: var(--display); font-size: 1.2rem; letter-spacing: 0.04em; }
.me-info .chips { font-family: var(--mono); color: var(--ember); }
.me-info .me-status { font-family: var(--mono); font-size: 0.72rem; color: var(--bone-dim); }
.my-cards { display: flex; gap: 0.4rem; }

/* Action-Leiste */
.actions {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.6rem;
}
.actions .btn { padding: 0.6rem 0.9rem; font-size: 0.95rem; }
.raise-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}
.raise-input {
    flex: 1;
    min-width: 5ch;
    padding: 0.55rem 0.6rem;
    font-family: var(--mono);
    font-size: 1rem;
    color: var(--bone);
    background: var(--soot);
    border: 1px solid var(--line);
    border-radius: 3px;
}
.raise-input:focus {
    outline: none;
    border-color: var(--rust);
    box-shadow: 0 0 0 3px rgba(180,69,31,0.25);
}
.raise-hint { font-family: var(--mono); font-size: 0.8rem; color: var(--bone-dim); min-width: 3ch; }
.wait-line {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--bone-dim);
}

/* ── Toast ────────────────────────────────────────────────────── */
#toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    background: var(--ash-hi);
    border: 1px solid var(--rust);
    color: var(--bone);
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
    border-radius: 3px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 50;
}
#toast.show { opacity: 1; }

@keyframes deal {
    from { opacity: 0; transform: translateY(-8px) rotate(-3deg); }
    to   { opacity: 1; transform: none; }
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 1px var(--ember), 0 0 14px rgba(224,152,47,0.25); }
    50%      { box-shadow: 0 0 0 1px var(--ember), 0 0 24px rgba(224,152,47,0.5); }
}

@media (prefers-reduced-motion: reduce) {
    .card { animation: none; }
    .seat.turn { animation: none; }
}

@media (max-width: 540px) {
    .home-card .brand { font-size: 2.3rem; }
    .felt { padding: 1.5rem 1rem; }
    .card { width: 40px; height: 56px; }
    .me { flex-direction: column; align-items: stretch; text-align: center; }
    .my-cards { justify-content: center; }
}
