:root {
    --felt: #0b4a30;
    --felt-deep: #072e1e;
    --felt-hi: #11633f;
    --felt-line: rgba(243, 234, 211, 0.35);
    --wood: #5d3a1e;
    --wood-hi: #7a4f28;
    --cream: #f3ead3;
    --muted: #b3cdbb;
    --faint: #7fa38c;
    --gold: #d9b24a;
    --gold-deep: #a8842e;
    --card: #fdfbf5;
    --suit-red: #c8322b;
    --suit-black: #23232b;
    --hit: #c0392b;
    --stand: #d9b24a;
    --dbl: #2fa477;
    --split: #4a7dce;
    --surr: #9a6bc9;
    --radius: 14px;
    --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
    --display: 'Limelight', 'Georgia', serif;
}

* { box-sizing: border-box; }

html { background: var(--felt-deep); }
body {
    margin: 0;
    color: var(--cream);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    accent-color: var(--gold);
    background:
        radial-gradient(110vw 80vh ellipse at 50% -10%, var(--felt-hi), var(--felt) 55%, var(--felt-deep) 100%);
    background-attachment: fixed;
}

[v-cloak] { display: none; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

a.skip {
    position: absolute; left: -9999px; top: 0;
    background: var(--gold); color: #241708; padding: 0.6rem 1rem; z-index: 50;
    border-radius: 0 0 8px 0; font-weight: 700;
}
a.skip:focus { left: 0; }

.wrap {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
    flex: 1;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.8rem;
}

.home-link {
    position: relative; display: inline-flex; border-radius: 12px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}
.home-link img { width: 64px; height: 64px; display: block; transition: transform 0.15s ease; }
.home-link:hover img, .home-link:focus-visible img { transform: rotate(-8deg) scale(1.08); }
.home-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.home-link .tip {
    position: absolute; top: calc(100% + 9px); left: 0;
    background: var(--gold); color: #241708;
    font-size: 0.78rem; font-weight: 700;
    white-space: nowrap; padding: 0.4rem 0.7rem; border-radius: 8px;
    opacity: 0; transform: translateY(-4px); pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 30;
}
.home-link .tip::before {
    content: ''; position: absolute; top: -4px; left: 16px;
    width: 8px; height: 8px; background: var(--gold);
    transform: rotate(45deg);
}
.home-link:hover .tip, .home-link:focus-visible .tip { opacity: 1; transform: translateY(0); }

.mute-btn {
    appearance: none; border: 1px solid var(--felt-line);
    background: rgba(0,0,0,0.25);
    border-radius: 9px; padding: 0.35rem 0.55rem; cursor: pointer; font-size: 0.95rem;
    color: var(--cream);
}
.mute-btn:hover { border-color: var(--gold); }
.mute-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

h1 {
    font-family: var(--display);
    font-size: 2.6rem;
    line-height: 1.08;
    margin: 0 0 0.5rem;
    font-weight: 400;
    color: var(--gold);
    text-shadow: 0 0 26px rgba(217, 178, 74, 0.35), 0 2px 0 rgba(0,0,0,0.55);
    letter-spacing: 0.02em;
}
.lede {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 1.6rem;
    max-width: 54ch;
}

/* ===== View tabs ===== */
.views { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 1.6rem; }
.view-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    border: 1.5px solid var(--felt-line);
    border-radius: 999px;
    padding: 0.5rem 1.05rem;
    cursor: pointer;
    font-size: 0.92rem; font-weight: 700; color: var(--cream);
    background: rgba(0,0,0,0.22);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.view-chip:hover { border-color: var(--gold); }
.view-chip.on {
    background: var(--gold); color: #241708; border-color: var(--gold);
    box-shadow: 0 0 16px rgba(217, 178, 74, 0.35);
}
.view-chip:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
@supports not selector(.x:has(a)) {
    .view-chip:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
}

/* ===== The table (felt) ===== */
.table-zone {
    background: radial-gradient(130% 150% at 50% -20%, var(--felt-hi), var(--felt) 62%, #09402a);
    border: 9px solid var(--wood);
    box-shadow:
        inset 0 0 0 2px var(--gold-deep),
        inset 0 10px 40px rgba(0, 0, 0, 0.35),
        0 16px 44px rgba(0, 0, 0, 0.5);
    border-radius: 26px 26px 46% 46% / 26px 26px 22% 22%;
    padding: 1.5rem 1.25rem 2.4rem;
    text-align: center;
}
.deck-label {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--faint); margin: 0 0 0.55rem;
}
.felt-print {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em;
    text-transform: uppercase; color: rgba(243, 234, 211, 0.4);
    margin: 1.1rem 0;
}
.cards-row {
    display: flex; justify-content: center; align-items: center; gap: 0.6rem;
    min-height: 108px;
}

.pcard {
    width: clamp(60px, 17vw, 84px);
    aspect-ratio: 5 / 7;
    background: var(--card);
    border-radius: 9px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0,0,0,0.08);
    color: var(--suit-black);
    flex-shrink: 0;
}
.pcard.red { color: var(--suit-red); }
.pcard.deal { animation: dealin 0.4s cubic-bezier(0.22, 1.2, 0.36, 1); }
@keyframes dealin {
    from { transform: translateY(-34px) rotate(-7deg); opacity: 0; }
    to { transform: translateY(0) rotate(0); opacity: 1; }
}
.pcard .corner {
    position: absolute; top: 6px; left: 7px;
    font-size: clamp(0.78rem, 2.4vw, 0.95rem); font-weight: 800; line-height: 1.02;
    text-align: center;
}
.pcard .corner.flip {
    top: auto; left: auto; bottom: 6px; right: 7px;
    transform: rotate(180deg);
}
.pcard .mid {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-weight: 800;
}
.pcard .mid .r { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1; }
.pcard .mid .s { font-size: clamp(1rem, 3.4vw, 1.35rem); line-height: 1.15; }
.pcard.back {
    background:
        repeating-linear-gradient(45deg, #7c1f1f 0 5px, #942929 5px 10px);
    border: 5px solid var(--card);
}

.hand-total {
    display: inline-flex; align-items: center; gap: 0.45rem;
    margin-top: 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--felt-line);
    border-radius: 999px;
    padding: 0.32rem 0.9rem;
    font-size: 0.88rem; font-weight: 700; color: var(--cream);
}

/* ===== Action chips ===== */
.actions {
    display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap;
    margin-top: 1.1rem;
}
.act {
    appearance: none; cursor: pointer; font-family: inherit;
    border-radius: 999px;
    padding: 0.72rem 1.25rem;
    font-size: 0.92rem; font-weight: 800; letter-spacing: 0.05em;
    color: #fff;
    border: 3px dashed rgba(255, 255, 255, 0.5);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), inset 0 2px 6px rgba(255,255,255,0.18);
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    transition: transform 0.1s, filter 0.15s, opacity 0.15s;
}
.act:hover:not(:disabled) { filter: brightness(1.12); }
.act:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.45); }
.act:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.act:disabled { opacity: 0.35; cursor: not-allowed; }
.act.hit { background: var(--hit); }
.act.stand { background: var(--stand); color: #241708; text-shadow: none; border-color: rgba(0,0,0,0.25); }
.act.double { background: var(--dbl); }
.act.split { background: var(--split); }
.act.surrender { background: var(--surr); }

.keys-hint { font-size: 0.72rem; color: var(--faint); margin-top: 0.7rem; }
.keys-hint kbd {
    font-family: var(--mono); background: rgba(0,0,0,0.3); border: 1px solid var(--felt-line);
    border-radius: 4px; padding: 0 0.3em; font-size: 0.72rem;
}

/* ===== Feedback ===== */
.feedback {
    margin-top: 1.1rem;
    border-radius: var(--radius);
    padding: 1.05rem 1.2rem;
    text-align: left;
    border: 1.5px solid;
}
.feedback.good { background: rgba(47, 164, 119, 0.14); border-color: var(--dbl); }
.feedback.bad { background: rgba(192, 57, 43, 0.16); border-color: var(--hit); }
.feedback .fb-head {
    display: flex; align-items: center; gap: 0.5rem;
    font-family: var(--display); font-weight: 400; font-size: 1.25rem;
    margin: 0 0 0.3rem; letter-spacing: 0.02em;
}
.feedback.good .fb-head { color: #8fe0bb; }
.feedback.bad .fb-head { color: #ffab9e; }
.feedback .fb-why { font-size: 0.92rem; line-height: 1.6; color: var(--cream); margin: 0; }
.feedback .fb-why strong { color: var(--gold); }
.fb-row { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin-top: 0.85rem; }

.btn {
    appearance: none; border-radius: 12px;
    padding: 0.8rem 1.5rem;
    font-size: 0.98rem; font-weight: 800; cursor: pointer; font-family: inherit;
    letter-spacing: 0.03em;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    transition: filter 0.15s, transform 0.1s;
}
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(180deg, #e8c766, #bd923a);
    color: #241708;
    border: 1px solid #8a5f1d;
    box-shadow: 0 3px 0 #6d4a14, 0 0 18px rgba(217, 178, 74, 0.25);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
    background: rgba(0,0,0,0.25); color: var(--cream);
    border: 1px solid var(--felt-line);
}
.btn-ghost:hover { border-color: var(--gold); }

button.linkish {
    appearance: none; border: none; background: none; padding: 0;
    font-size: 0.85rem; color: var(--muted); text-decoration: underline;
    cursor: pointer; font-family: inherit;
}
button.linkish:hover { color: var(--gold); }
button.linkish:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ===== Practice settings ===== */
.drill-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.8rem; flex-wrap: wrap; margin-top: 1rem;
}
.focus-set { display: flex; gap: 6px; flex-wrap: wrap; }
.focus-chip {
    display: inline-flex; align-items: center;
    border: 1px solid var(--felt-line); border-radius: 999px;
    padding: 0.3rem 0.75rem; cursor: pointer;
    font-size: 0.78rem; font-weight: 700; color: var(--muted);
    background: rgba(0,0,0,0.2);
}
.focus-chip:hover { border-color: var(--gold); }
.focus-chip.on { background: var(--cream); color: #17402c; border-color: var(--cream); }
.focus-chip:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
@supports not selector(.x:has(a)) {
    .focus-chip:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
}
label.surr-toggle {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-size: 0.82rem; color: var(--muted); cursor: pointer;
}
label.surr-toggle input { width: 15px; height: 15px; }
label.surr-toggle input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ===== Chart ===== */
.chart-note { font-size: 0.85rem; color: var(--muted); line-height: 1.55; margin: 0 0 1rem; max-width: 60ch; }
.legend { display: flex; gap: 0.5rem 1.1rem; flex-wrap: wrap; margin: 0 0 1.1rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.lg {
    width: 20px; height: 20px; border-radius: 5px; display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 0.68rem; font-weight: 800; color: #fff;
}
h2.chart-h {
    font-family: var(--display); font-weight: 400; font-size: 1.35rem;
    color: var(--gold); letter-spacing: 0.02em; margin: 1.6rem 0 0.6rem;
}
.chart-scroll { overflow-x: auto; border-radius: 10px; }
table.strat {
    border-collapse: collapse; width: 100%; min-width: 520px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px; overflow: hidden;
}
table.strat caption { text-align: left; }
table.strat th {
    font-size: 0.75rem; font-weight: 800; color: var(--cream);
    padding: 0.4rem 0.3rem; background: rgba(0,0,0,0.35);
}
table.strat th[scope="row"] { white-space: nowrap; padding: 0.3rem 0.6rem; font-size: 0.8rem; }
table.strat td {
    text-align: center; padding: 0;
}
.cellbox {
    margin: 2px; border-radius: 5px;
    font-size: 0.72rem; font-weight: 800; color: #fff;
    padding: 0.34rem 0;
    min-width: 34px;
}
.cellbox.c-H { background: var(--hit); }
.cellbox.c-S { background: var(--stand); color: #241708; }
.cellbox.c-D, .cellbox.c-Ds { background: var(--dbl); }
.cellbox.c-P { background: var(--split); }
.cellbox.c-Su { background: var(--surr); }
.cellbox.hot { outline: 3px solid var(--cream); outline-offset: 1px; }
.chart-foot { font-size: 0.78rem; color: var(--faint); line-height: 1.55; margin-top: 0.8rem; }

/* ===== Stats ===== */
.stat-grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.4rem; }
.stat-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--felt-line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem; text-align: center;
}
.stat-card .num { font-family: var(--display); font-weight: 400; font-size: 2rem; color: var(--gold); line-height: 1.1; }
.stat-card .lbl { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 0.25rem; }
.kind-bars { margin: 0 0 1.4rem; }
.kind-bar { margin-bottom: 0.7rem; }
.kind-bar .kb-label { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; margin-bottom: 0.3rem; }
.kind-bar .kb-label span:last-child { color: var(--muted); font-weight: 600; }
.kb-track { height: 10px; border-radius: 999px; background: rgba(0,0,0,0.35); overflow: hidden; }
.kb-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
h2.stats-h {
    font-family: var(--display); font-weight: 400; font-size: 1.35rem;
    color: var(--gold); letter-spacing: 0.02em; margin: 1.5rem 0 0.6rem;
}
.miss-list { list-style: none; margin: 0; padding: 0; }
.miss-list li {
    display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
    padding: 0.55rem 0; font-size: 0.92rem;
    border-bottom: 1px dashed var(--felt-line);
}
.miss-list .mkey { font-weight: 800; }
.miss-list .mbest { color: var(--muted); font-size: 0.82rem; }
.miss-list .mcount { color: var(--gold); font-weight: 800; white-space: nowrap; }
.empty-note { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }

table.bust {
    border-collapse: collapse; width: 100%; max-width: 460px;
    background: rgba(0,0,0,0.25); border-radius: 10px; overflow: hidden;
}
table.bust th, table.bust td {
    padding: 0.45rem 0.4rem; text-align: center; font-size: 0.85rem;
}
table.bust th { background: rgba(0,0,0,0.35); font-size: 0.75rem; }
table.bust td.hotrow { color: var(--gold); font-weight: 800; }

.foot {
    text-align: center; padding: 1.5rem 1rem 2rem;
    font-size: 0.8rem; color: var(--faint); line-height: 1.6;
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
    .pcard.deal { animation: none; }
    .act, .btn, .view-chip, .home-link img, .home-link .tip { transition: none; }
}

@media (max-width: 480px) {
    h1 { font-size: 2rem; }
    .wrap { padding-top: 1.25rem; }
    .act { padding: 0.62rem 0.95rem; font-size: 0.85rem; }
}
