/* ─── Schafkopfturnier – Rustikal Bayrisch ─── */
:root {
    --bg: #2c1810;
    --bg2: #1b3a1f;
    --bg3: #2d5a32;
    --felt: #2a5e30;
    --felt-light: #347a3a;
    --wood: #3e2723;
    --wood-light: #5d4037;
    --gold: #d4a017;
    --gold-light: #f0c040;
    --cream: #f5edd6;
    --cream-dark: #d4c5a0;
    --accent: #d4a017;
    --accent2: #8b6914;
    --text: #f5edd6;
    --text-muted: #a89880;
    --success: #4caf50;
    --warning: #f0c040;
    --danger: #c0392b;
    --card-bg: #3a2218;
    --border: #5a3a28;
    --radius: 10px;
    --bayern-blue: #1e73be;
    --bayern-white: #ffffff;
}

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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--wood);
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 40px,
            rgba(0,0,0,0.03) 40px,
            rgba(0,0,0,0.03) 41px
        ),
        linear-gradient(180deg, #2c1810 0%, #3e2723 50%, #2c1810 100%);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

h1 {
    font-size: 1.8rem;
    text-align: center;
    margin: 1rem 0 0.2rem;
    color: var(--gold);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
h2 {
    font-size: 1.3rem;
    margin: 1.5rem 0 0.8rem;
    color: var(--gold-light);
}
h3 { font-size: 1.1rem; color: var(--cream); }
.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-style: italic;
}

/* ─── Cards ─── */
.card {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.8rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.card:hover { border-color: var(--gold); box-shadow: 0 2px 12px rgba(212,160,23,0.2); }
.card h3 { color: var(--gold-light); }
.card p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.3rem; }

/* ─── Badges ─── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.4rem;
}
.badge-setup { background: var(--accent2); color: var(--cream); }
.badge-running { background: var(--success); color: #fff; }
.badge-finished { background: var(--wood-light); color: var(--cream-dark); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: white;
    width: 100%;
}
.btn + .btn { margin-top: 0.5rem; }
.btn-primary {
    background: linear-gradient(135deg, var(--bg3) 0%, var(--felt) 100%);
    border: 1px solid var(--felt-light);
    color: var(--cream);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--felt) 0%, var(--felt-light) 100%); }
.btn-secondary {
    background: var(--wood-light);
    border: 1px solid var(--border);
    color: var(--cream);
}
.btn-secondary:hover { border-color: var(--gold); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--gold); color: var(--wood); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; width: auto; }
.btn-group { display: flex; gap: 0.5rem; }
.btn-group .btn { flex: 1; }

.btn-game-type {
    padding: 1rem;
    font-size: 1.2rem;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--cream);
}
.btn-game-type.active {
    border-color: var(--gold);
    background: var(--felt);
    color: var(--gold-light);
}

.btn-player {
    padding: 0.8rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--cream);
}
.btn-player.active { border-color: var(--gold); background: var(--felt); }

/* ─── Forms ─── */
.form-stack { display: flex; flex-direction: column; gap: 0.6rem; }
.form-row { display: flex; gap: 0.6rem; }
.form-row > * { flex: 1; }

input, textarea, select {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0,0,0,0.3);
    color: var(--cream);
    font-size: 1rem;
    font-family: inherit;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212,160,23,0.2);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ─── App Header ─── */
.app-header {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #1a3320 0%, #1b3a1f 50%, #1a3320 100%);
    border-bottom: 2px solid var(--gold);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 52px;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.header-back {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 1.5rem;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}
.header-title {
    flex: 1;
    text-align: center;
    overflow: hidden;
    min-width: 0;
}
.header-title-main {
    font-weight: 700;
    font-size: 1.1rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--cream);
}
.header-sub {
    font-size: 0.75rem;
    color: var(--gold);
    display: block;
    font-style: italic;
}
.header-action {
    background: none;
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 0.35rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ─── Bottom Navigation ─── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: linear-gradient(0deg, #1a3320 0%, #1b3a1f 100%);
    border-top: 2px solid var(--gold);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.4);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0 0.4rem;
    color: var(--cream-dark);
    text-decoration: none;
    font-size: 0.65rem;
    gap: 0.15rem;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.bottom-nav-item.active { color: var(--gold); }
.bottom-nav-item:active { opacity: 0.7; }

body.has-bottom-nav { padding-bottom: 64px; }

/* ─── Table Card (Tisch-Karte) ─── */
.table-card {
    background: var(--felt);
    border: 2px solid #4a7a4e;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.3);
}
.table-card:hover { border-color: var(--gold); box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 2px 12px rgba(212,160,23,0.2); }
.table-card.complete { border-color: var(--success); opacity: 0.8; }

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    color: var(--cream);
}

.table-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    font-size: 0.9rem;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 0.5rem;
    border: 1px dashed rgba(255,255,255,0.15);
}
.table-players .seat { padding: 0.3rem 0.5rem; color: var(--cream); }
.table-players .divider {
    grid-column: 1 / -1;
    border-top: 1px dashed rgba(255,255,255,0.2);
}

.stock-badge {
    display: inline-block;
    background: var(--gold);
    color: var(--wood);
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.progress-bar {
    height: 5px;
    background: rgba(0,0,0,0.3);
    border-radius: 3px;
    margin-top: 0.5rem;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%);
    transition: width 0.3s;
    border-radius: 3px;
}

/* ─── Game Entry ─── */
.game-entry { padding: 1rem 0; }
.game-entry .step { display: none; }
.game-entry .step.active { display: block; }

.step-title {
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ─── Ranking ─── */
.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th {
    text-align: left;
    padding: 0.6rem;
    border-bottom: 2px solid var(--gold);
    font-size: 0.8rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ranking-table td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--border);
}
.ranking-table tr:first-child td {
    font-weight: 700;
    color: var(--gold-light);
    font-size: 1.05rem;
}
.ranking-table .rank { width: 2rem; text-align: center; }
.ranking-table .points { text-align: right; font-variant-numeric: tabular-nums; }
.positive { color: var(--success); }
.negative { color: var(--danger); }

/* ─── Rank decorations ─── */
.ranking-table tr:nth-child(1) .rank::before { content: "🏆"; }
.ranking-table tr:nth-child(2) .rank::before { content: "🥈"; }
.ranking-table tr:nth-child(3) .rank::before { content: "🥉"; }

/* ─── Game History ─── */
.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.game-item .game-num {
    width: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.game-item .game-info { flex: 1; }
.game-item .game-points { font-weight: 600; white-space: nowrap; }

/* ─── Info Page ─── */
.info-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); }

/* ─── Toggle ─── */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
}
.toggle {
    width: 50px;
    height: 28px;
    background: var(--wood-light);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle.active { background: var(--success); }
.toggle::after {
    content: '';
    width: 22px;
    height: 22px;
    background: var(--cream);
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: left 0.2s;
}
.toggle.active::after { left: 25px; }

/* ─── Beamer View ─── */
.beamer-container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem 2rem;
    font-size: 1.3rem;
    background: linear-gradient(135deg, #1a2a10 0%, #2c1810 50%, #1a2a10 100%);
}
.beamer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 3px solid var(--gold);
    color: var(--gold);
    font-weight: 700;
}
.beamer-content {
    flex: 1;
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
    overflow: hidden;
}
.beamer-ranking { flex: 2; }
.beamer-awards { flex: 1; }
.beamer-ticker {
    padding: 0.8rem 1rem;
    background: rgba(0,0,0,0.4);
    border-top: 3px solid var(--gold);
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    color: var(--cream);
}

.beamer-table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
}

.award-card {
    background: linear-gradient(135deg, var(--card-bg) 0%, #4a2a18 100%);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 0.8rem;
    animation: fadeIn 0.5s ease;
    box-shadow: 0 2px 8px rgba(212,160,23,0.15);
}
.award-card .award-title {
    color: var(--gold);
    font-weight: 700;
    font-size: 1.1rem;
}
.award-card .award-player {
    font-size: 1.3rem;
    margin: 0.3rem 0;
    color: var(--cream);
}
.award-card .award-value { color: var(--text-muted); font-size: 0.9rem; }

/* ─── Countdown ─── */
.countdown {
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--gold);
}

/* ─── Misc ─── */
.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.hidden { display: none !important; }

.player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}
.player-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--felt);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid #4a7a4e;
    color: var(--cream);
}
.player-tag .remove {
    cursor: pointer;
    color: var(--danger);
    font-weight: 700;
}
.player-tag.absent { opacity: 0.5; text-decoration: line-through; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
    .container { padding: 0.5rem; }
    h1 { font-size: 1.4rem; }
    .btn { padding: 0.6rem 1rem; }
}

/* ─── Farb-Buttons (Bayerische Kartenfarben) ─── */
/* ─── Modal Dialog ─── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}
.modal-box {
    background: var(--card-bg);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-box h3 {
    color: var(--gold);
    margin-bottom: 0.8rem;
    font-size: 1.15rem;
}
.modal-box p {
    color: var(--cream);
    margin-bottom: 1rem;
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-line;
}
.modal-buttons {
    display: flex;
    gap: 0.5rem;
}
.modal-buttons .btn { font-size: 0.95rem; }

/* ─── Toast Notification ─── */
.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--felt);
    border: 1px solid var(--gold);
    color: var(--cream);
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    z-index: 1001;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease;
    max-width: 90%;
    text-align: center;
}
.toast.toast-error {
    background: var(--danger);
    border-color: #e74c3c;
}
.toast.toast-gold {
    background: linear-gradient(135deg, #5a3a10, #7a5a20);
    border-color: var(--gold);
    color: var(--gold-light);
    font-weight: 600;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Stock-Anzeige (prominent am Tisch) ─── */
.stock-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #5a3a10 0%, #7a5a20 100%);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    margin: 0.8rem 0;
    font-size: 1.1rem;
    color: var(--gold-light);
    box-shadow: 0 2px 8px rgba(212,160,23,0.25);
}
.stock-display strong {
    font-size: 1.5rem;
    color: var(--gold-light);
    margin: 0 0.3rem;
}

/* ─── Stock-Einzahlung in der Historie ─── */
.stock-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    background: rgba(212,160,23,0.08);
    border-left: 3px solid var(--gold);
    color: var(--text-muted);
    font-style: italic;
}

.farbe-btn {
    padding: 0.8rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--cream);
    font-family: inherit;
    position: relative;
    padding-left: 2.5rem;
}
.farbe-btn.active { border-color: var(--gold); background: var(--felt); }
.farbe-btn::before {
    position: absolute;
    left: 0.7rem;
    font-size: 1.2rem;
}
.farbe-btn[data-farbe="eichel"] { border-left: 4px solid #8B6914; }
.farbe-btn[data-farbe="eichel"]::before { content: "🌰"; }
.farbe-btn[data-farbe="gras"] { border-left: 4px solid #2d7a32; }
.farbe-btn[data-farbe="gras"]::before { content: "🍀"; }
.farbe-btn[data-farbe="schellen"] { border-left: 4px solid #d4a017; }
.farbe-btn[data-farbe="schellen"]::before { content: "🔔"; }

/* ─── Schafkopf Spielart-Buttons mit Symbolen ─── */
.btn-game-type[data-type="rufspiel"]::before { content: "🤝 "; }
.btn-game-type[data-type="wenz"]::before { content: "👑 "; }
.btn-game-type[data-type="solo"]::before { content: "⚔️ "; }

/* ─── Bavarian Raute (Rautenmuster-Dekoration) ─── */
.bayern-border {
    background-image: repeating-linear-gradient(
        45deg,
        var(--bayern-blue) 0px,
        var(--bayern-blue) 10px,
        var(--bayern-white) 10px,
        var(--bayern-white) 20px
    );
    height: 4px;
}
