:root {
    --sage: #8AA68C;
    --sage-dark: #6F8C73;
    --sage-darker: #5B7660;
    --sage-light: #DCE8DD;
    --cream: #F7F6F2;
    --ink: #3A3A35;
    --muted: #8A8A82;
    --miss: #C1554D;
    --border: #E2E0D8;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--cream);
    color: var(--ink);
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-tap-highlight-color: transparent;
}

.app-header {
    background: var(--sage-dark);
    color: #fff;
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.app-logo {
    width: 30px;
    height: 30px;
}

.session-code-badge {
    background: rgba(255,255,255,0.18);
    border-radius: 8px;
    padding: 4px 10px;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.08em;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 16px 96px;
}

/* ── Cards / panels ──────────────────────────────────────────────────── */

.card {
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.card h2 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    color: var(--sage-darker);
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-title-row h2 {
    margin: 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--sage);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    min-height: 48px;
    width: 100%;
    transition: background 0.15s ease;
}

.btn:active {
    background: var(--sage-darker);
}

.btn-secondary {
    background: #fff;
    color: var(--sage-darker);
    border: 1.5px solid var(--sage);
}

.btn-secondary:active {
    background: var(--sage-light);
}

.btn-block + .btn-block {
    margin-top: 10px;
}

.btn-row {
    display: flex;
    gap: 10px;
}

.btn-row .btn {
    width: auto;
    flex: 1;
}

/* ── Forms ────────────────────────────────────────────────────────────── */

label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 4px;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    font-size: 1.1rem;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    margin-bottom: 12px;
    -webkit-appearance: none;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--sage);
}

.form-row {
    margin-bottom: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

.checkbox-row label {
    margin: 0;
    font-weight: 500;
    color: var(--ink);
}

/* ── Flash messages ───────────────────────────────────────────────────── */

.flash {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 0.92rem;
    font-weight: 500;
}

.flash-danger {
    background: #FBE7E5;
    color: var(--miss);
    border: 1px solid #F3CCC8;
}

.flash-success {
    background: var(--sage-light);
    color: var(--sage-darker);
    border: 1px solid var(--sage);
}

/* ── Sessiecode / start ──────────────────────────────────────────────── */

.code-display {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-align: center;
    color: var(--sage-darker);
    margin: 8px 0 4px;
}

.code-hint {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.session-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.session-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.session-list li:last-child {
    border-bottom: none;
}

.session-list .meta {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ── Ronde-info ───────────────────────────────────────────────────────── */

.round-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.round-label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.cards-count {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--sage-darker);
    text-align: center;
    line-height: 1;
}

.cards-count-label {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

/* ── Troefkleur ───────────────────────────────────────────────────────── */

.trump-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--sage-light);
    color: var(--sage-darker);
    border-radius: 8px;
    padding: 4px 10px;
    font-weight: 700;
    font-size: 0.9rem;
}

/* ── Voorspellingen / resultaten invoer ──────────────────────────────── */

.player-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.player-input-row:last-child {
    border-bottom: none;
}

.player-input-row .player-name {
    font-weight: 600;
    flex: 1;
}

.player-input-row .dealer-tag {
    font-size: 0.7rem;
    color: var(--sage-darker);
    background: var(--sage-light);
    border-radius: 6px;
    padding: 2px 6px;
    font-weight: 700;
    margin-left: 6px;
}

.player-input-row input[type="number"],
.player-input-row select {
    width: 76px;
    margin: 0;
    text-align: center;
    text-align-last: center;
}

.player-input-row .readonly-value {
    width: 76px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding-top: 10px;
    font-weight: 700;
}

.total-row.ok { color: var(--sage-darker); }
.total-row.bad { color: var(--miss); }

.warning-text {
    color: var(--miss);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 6px;
}

/* ── Scoreboard ───────────────────────────────────────────────────────── */

.score-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.score-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.score-list li:last-child {
    border-bottom: none;
}

.score-list .rank {
    color: var(--muted);
    font-weight: 700;
    width: 24px;
}

.score-list .name {
    flex: 1;
    font-weight: 600;
}

.score-list .score {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--sage-darker);
    font-family: "SF Mono", "Courier New", monospace;
}

/* ── Rondehistorie / scoreblaadje ─────────────────────────────────────── */

.history-wrap {
    overflow-x: auto;
}

table.history {
    border-collapse: collapse;
    width: 100%;
    font-family: "SF Mono", "Courier New", monospace;
    font-size: 0.85rem;
}

table.history th,
table.history td {
    padding: 6px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.history th {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 700;
}

table.history td.round-cards {
    color: var(--muted);
    font-weight: 700;
}

.delta-cell {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 2px;
}

.delta-cell.positive {
    color: var(--sage-darker);
}

.bol {
    display: inline-block;
    width: 1.3em;
    height: 1.3em;
    border-radius: 50%;
    background: var(--miss);
    vertical-align: middle;
}

.redo-icon-btn {
    border: none;
    background: none;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    margin-left: 4px;
    cursor: pointer;
    vertical-align: middle;
}

.redo-icon-btn:active {
    color: var(--sage-darker);
}

/* ── Eindstand ────────────────────────────────────────────────────────── */

.standings li.winner .score {
    color: var(--miss);
}

.standings li.winner .name::after {
    content: ' 👑';
}

/* ── Bottom bar ───────────────────────────────────────────────────────── */

.bottombar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.bottombar .container-inner {
    max-width: 480px;
    margin: 0 auto;
}

/* ── Misc ─────────────────────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

a.link {
    color: var(--sage-darker);
    font-weight: 600;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}
