:root {
    --felt-950: #032d1d;
    --felt-900: #06472f;
    --felt-800: #075d3b;
    --felt-700: #0b7650;
    --cream: #fffaf0;
    --ink: #17231d;
    --muted: #637169;
    --gold: #f3c35b;
    --gold-light: #ffe49b;
    --gold-dark: #ae7414;
    --danger: #b63b3b;
    --surface: rgba(255, 252, 245, 0.97);
    --border: #dce4de;
    --shadow: 0 24px 65px rgba(0, 28, 17, 0.32);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { font-family: Inter, Arial, Helvetica, sans-serif; }

.landing-page,
.app-page {
    min-height: 100vh;
    min-height: 100svh;
    padding: clamp(16px, 4vw, 36px);
    background-color: var(--felt-800);
    background-image:
        radial-gradient(circle at 18% 15%, rgba(255, 255, 255, 0.07), transparent 26%),
        radial-gradient(circle at 82% 78%, rgba(0, 0, 0, 0.16), transparent 30%),
        repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px);
}

.landing-page { display: grid; place-items: center; color: var(--cream); }
.app-page { color: var(--ink); }

.welcome-card {
    width: min(100%, 940px);
    padding: clamp(28px, 5vw, 58px);
    text-align: center;
    background: rgba(3, 45, 29, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 28px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold-dark);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .2em;
    text-transform: uppercase;
}

.welcome-card .eyebrow { color: var(--gold); }
.welcome-card h1 { margin: 0; font: 700 clamp(3rem, 9vw, 6.4rem)/.95 Georgia, serif; letter-spacing: -.04em; text-shadow: 0 5px 20px rgba(0, 0, 0, .32); }
.subtitle { max-width: 600px; margin: 18px auto 28px; color: rgba(255, 250, 240, .82); font-size: clamp(1rem, 2.2vw, 1.16rem); line-height: 1.6; }

.game-image {
    display: block;
    width: min(100%, 640px);
    height: auto;
    margin: 0 auto 30px;
    border: 10px solid rgba(255, 255, 255, .95);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0, 22, 13, .44);
    transform: rotate(-1deg);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 22px;
    border: 1px solid transparent;
    border-radius: 14px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

.button:hover { filter: brightness(1.04); transform: translateY(-1px); }
.button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .45; transform: none; }
.button-primary { color: #2d2009; background: linear-gradient(180deg, var(--gold-light), var(--gold)); box-shadow: 0 5px 0 var(--gold-dark), 0 10px 22px rgba(0, 0, 0, .2); }
.button-secondary { color: var(--felt-900); background: #fff; border-color: #cdd9d1; }
.button-danger { color: #fff; background: var(--danger); }
.button-large { min-width: 190px; min-height: 56px; font-size: 1.05rem; border-radius: 999px; }
.button-small { min-height: 42px; padding: 9px 14px; font-size: .9rem; }

.auth-card,
.content-card {
    width: min(100%, 1080px);
    margin: clamp(12px, 4vw, 48px) auto;
    padding: clamp(24px, 5vw, 48px);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 26px;
    box-shadow: var(--shadow);
}

.auth-card, .narrow-card { max-width: 580px; }
.page-title { margin: 0; color: var(--felt-950); font: 700 clamp(2rem, 6vw, 3.2rem)/1.05 Georgia, serif; }
.page-intro { margin: 12px 0 28px; color: var(--muted); font-size: 1.06rem; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--felt-700); font-weight: 800; text-decoration: none; }

.form-stack { display: grid; gap: 20px; margin-top: 26px; }
.form-stack label { display: grid; gap: 8px; color: var(--felt-950); font-weight: 800; }
.form-stack input,
.form-stack select { width: 100%; min-height: 52px; padding: 12px 14px; color: var(--ink); font: inherit; background: #fff; border: 1px solid #b9c8bf; border-radius: 12px; }
.form-actions, .toolbar, .row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.forgot-password-row { padding-top: 28px; text-align: center; }
.forgot-password-link { display: inline-flex; min-height: 44px; padding: 10px 12px; align-items: center; justify-content: center; color: var(--felt-700); font-weight: 800; text-align: center; text-underline-offset: 3px; }
.password-reset-note { margin: 20px 0 0; padding: 14px 16px; color: var(--muted); font-size: .9rem; line-height: 1.5; background: #edf4ef; border-radius: 12px; }

.alert { margin: 22px 0; padding: 14px 16px; border-radius: 12px; font-weight: 700; }
.alert-error { color: #7a1e1e; background: #fde8e8; border: 1px solid #f4bcbc; }
.alert-success { color: #155c3b; background: #e3f6eb; border: 1px solid #addbc0; }
.empty-state { margin: 24px 0; padding: 24px; text-align: center; color: var(--muted); background: #f1f6f2; border: 1px dashed #adc0b4; border-radius: 16px; }

.app-header { width: min(100%, 1080px); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; color: #fff; }
.app-header h1 { margin: 0; font: 700 clamp(1.7rem, 5vw, 2.8rem)/1.1 Georgia, serif; }
.app-header .eyebrow { color: var(--gold); }
.app-shell { width: min(100%, 1080px); margin: 28px auto; }
.app-shell > .page-intro { color: rgba(255, 255, 255, .78); }

.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(14px, 3vw, 24px); }
.menu-card { min-height: 190px; padding: clamp(22px, 4vw, 34px); display: flex; flex-direction: column; justify-content: center; color: var(--ink); text-decoration: none; background: var(--surface); border: 2px solid transparent; border-radius: 22px; box-shadow: 0 16px 40px rgba(0, 30, 18, .25); transition: transform 160ms ease, border-color 160ms ease; }
.menu-card:hover, .menu-card:focus-visible { transform: translateY(-3px); border-color: var(--gold); outline: none; }
.menu-card strong { color: var(--felt-950); font: 700 clamp(1.45rem, 4vw, 2rem)/1.15 Georgia, serif; }
.menu-card small { margin-top: 7px; color: var(--muted); font-size: .96rem; }
.menu-icon { margin-bottom: 12px; color: var(--gold-dark); font-size: 2rem; }

.page-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.count-badge, .you-badge { display: inline-block; color: var(--felt-900); background: #e3efe7; border-radius: 999px; font-size: .8rem; font-weight: 800; }
.count-badge { padding: 8px 12px; white-space: nowrap; }
.you-badge { padding: 3px 7px; }
.toolbar { margin-bottom: 22px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { color: var(--felt-900); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; background: #edf4ef; }
tbody tr:last-child td { border-bottom: 0; }
.row-actions { justify-content: flex-end; }
.row-actions form { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; margin: 30px 0; padding: 22px; text-align: center; background: #edf4ef; border: 1px solid var(--border); border-radius: 16px; }
.matchup strong { color: var(--felt-950); font: 700 1.25rem/1.2 Georgia, serif; }
.matchup span { color: var(--muted); font-size: .85rem; font-weight: 800; text-transform: uppercase; }
.score-page { max-width: 1240px; }
.score-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.save-status { min-height: 20px; color: var(--muted); font-size: .86rem; font-weight: 700; }
.save-status.is-error { color: var(--danger); }
.score-layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
.score-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; }
.score-table { min-width: 610px; table-layout: fixed; }
.score-game-col { width: 180px; }
.score-points-col { width: 115px; }
.score-diff-col { width: 75px; }
.score-table th { padding: 11px 8px; text-align: center; }
.score-table td { height: 64px; padding: 7px; text-align: center; }
.score-table .score-total-row th, .score-table .score-total-row td { height: 64px; color: var(--felt-900); font-size: 1.1rem; font-weight: 900; background: #e5f2e9; border-top: 3px solid var(--gold-dark); }
.score-table .winner-row td { height: auto; padding: 16px; color: var(--felt-950); font-size: 1.15rem; font-weight: 900; background: #f4cc69; border-top: 0; }
.winner-row[hidden] { display: none; }
.score-table .game-label { width: 30%; text-align: left; font-weight: 800; }
.game-label-content { display: flex; min-height: 48px; align-items: center; gap: 10px; white-space: nowrap; }
.game-label-text { flex: 1 1 auto; line-height: 1.2; }
.contract-icon { display: inline-flex; flex: 0 0 58px; width: 58px; min-height: 44px; color: #111; align-items: center; justify-content: center; vertical-align: middle; font-family: Arial, sans-serif; font-weight: 900; line-height: 1; }
.contract-suit { font-size: 2.2rem; }
.contract-red { color: #db1830; }
.contract-arrow { font-size: 2.55rem; }
.contract-arrow-down { color: #06345b; }
.contract-gusti { flex-direction: column; font-size: .78rem; line-height: 1.05; white-space: nowrap; }
.contract-gusti span:first-child { padding-bottom: 3px; border-bottom: 2px solid #111; }
.contract-gusti span:last-child { padding-top: 3px; }
.contract-tutti { display: inline-grid; grid-template-columns: repeat(2, 20px); grid-template-rows: repeat(2, 20px); gap: 0 2px; font-size: 1.45rem; line-height: .9; }
.contract-misere { color: #d39500; font-size: 2.55rem; }
.contract-joker { gap: 4px; white-space: nowrap; }
.joker-head { display: block; width: 35px; height: 35px; object-fit: contain; }
.joker-letter { color: #111; font: 900 1.6rem/1 Georgia, serif; }
.contract-slalom img { display: block; width: 43px; height: 43px; object-fit: contain; }
.score-input { width: 100%; min-width: 0; min-height: 44px; padding: 6px; color: var(--felt-950); font: 800 1rem/1 Arial, sans-serif; text-align: center; background: #fff; border: 1px solid #b9c8bf; border-radius: 10px; }
.score-input:focus { border-color: var(--gold-dark); }
.diff-value { display: inline-grid; place-items: center; min-width: 48px; min-height: 42px; color: var(--felt-900); font-size: 1.1rem; font-weight: 900; background: #e5f2e9; border-radius: 10px; }
.diff-value:empty { background: transparent; }
.score-actions-panel { margin: -8px 0 18px; }
.score-actions-panel summary { width: fit-content; color: var(--felt-700); font-size: .82rem; font-weight: 800; cursor: pointer; }
.score-actions-panel summary::marker { color: var(--gold-dark); }
.score-actions-panel[open] summary { margin-bottom: 10px; }
.score-actions-panel .actions-show-label,
.score-actions-panel[open] .actions-hide-label { display: inline; }
.score-actions-panel .actions-hide-label,
.score-actions-panel[open] .actions-show-label { display: none; }
.score-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 10px; }
.trash-section + .trash-section { margin-top: 30px; }
.trash-section h2 { margin: 0 0 12px; color: var(--felt-950); }
.field-help { margin: -4px 0 4px; color: var(--muted); font-size: .86rem; line-height: 1.45; }

@media (max-width: 720px) {
    .landing-page, .app-page { padding: 14px; }
    .welcome-card, .auth-card, .content-card { border-radius: 20px; }
    .game-image { border-width: 7px; }
    .app-header { align-items: flex-start; }
    .menu-grid { grid-template-columns: 1fr; }
    .menu-card { min-height: 145px; }
    .table-wrap { overflow: visible; border: 0; }
    table, tbody, tr, td { display: block; width: 100%; }
    thead { display: none; }
    tr { margin-bottom: 14px; padding: 10px 14px; background: #fff; border: 1px solid var(--border); border-radius: 14px; }
    td { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
    td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
    td.row-actions { display: flex; justify-content: flex-start; padding-top: 14px; border: 0; }
}

@media (max-width: 430px) {
    .app-header { display: grid; }
    .app-header .button { justify-self: start; }
    .form-actions .button, .toolbar .button { flex: 1 1 auto; }
    td { grid-template-columns: 1fr; }
    .matchup { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .button, .menu-card { transition: none; }
}

@media (max-width: 720px) {
    .score-heading { flex-wrap: wrap; align-items: start; }
    .score-page { padding: 18px 14px; }
    .score-actions-panel { margin-top: -4px; }
    .score-actions .button { flex: 1 1 145px; }
    .score-table-wrap { overflow-x: auto; border: 1px solid var(--border); }
    .score-table { display: table; width: 100%; min-width: 440px; }
    .score-game-col { width: 140px; }
    .score-points-col { width: 90px; }
    .score-diff-col { width: 60px; }
    .score-table thead { display: table-header-group; }
    .score-table tbody { display: table-row-group; }
    .score-table tfoot { display: table-footer-group; }
    .score-table tr { display: table-row; padding: 0; border: 0; border-radius: 0; }
    .score-table th, .score-table td { display: table-cell; width: auto; border-bottom: 1px solid var(--border); }
    .score-table th:first-child, .score-table td.game-label { width: 140px; }
    .score-table td::before { content: none; }
    .score-table th { padding: 9px 5px; font-size: .7rem; }
    .score-table td { height: 58px; padding: 5px; }
    .score-input { min-height: 40px; padding: 4px; font-size: .95rem; }
    .diff-value { min-width: 38px; min-height: 38px; font-size: 1rem; }
    .contract-icon { flex-basis: 48px; width: 48px; }
}
