/* ==========================================================================
   Remi - only what the tarok styles have no shape for
   ==========================================================================
   Every remi page reuses the tarok markup (.tk, .tk-table, .tk-seat, .tk-card,
   .tk-prompt, .tk-result, .tk-sheet, .tarok-landing__*, .tk-board ...), so
   web/css/tarok.css does the styling and a tarok restyle reaches remi as well.
   This file adds the remi-only furniture - the stock and discard piles, the
   melds on the table, the staging tray, the move log - using the same --tk-*
   tokens so the felt colour, card size and dark mode all follow.
   ========================================================================== */

/* The remi faces are 300x420 (poker ratio 0.714), not the 0.593 tarok scans. Derive the
   width from the S/M/L height the reader picked, exactly like the tarok rule does. Must
   come after tarok.css's [data-card-size] rules - same specificity, so load order decides. */
.tk[data-card-art="remi"] {
    --tk-card-w-base: calc(var(--tk-card-h-base) * 0.714);
}

/* ----- Felt centre ------------------------------------------------------ */

.rm-center {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    color: #fff;
}

.rm-center__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.25rem 2rem;
}

.rm-piles {
    display: flex;
    gap: 1rem;
}

.rm-pile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 0;
    padding: 0.35rem;
    border-radius: 0.6rem;
    color: rgba(255, 255, 255, 0.85);
}

.rm-pile:disabled { cursor: default; }

.rm-pile__label {
    font-size: 0.75rem;
    white-space: nowrap;
}

.rm-pile--live { cursor: pointer; }

.rm-pile--live .tk-card {
    box-shadow: 0 0 0 3px var(--tk-tarok), 0 6px 14px rgba(0, 0, 0, 0.4);
}

@media (hover: hover) {
    .rm-pile--live:hover .tk-card { transform: translateY(-0.4rem); }
}

.rm-card-empty {
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.35);
    box-shadow: none;
}

.rm-turn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    max-width: 24rem;
    text-align: center;
}

.rm-turn__round {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.rm-turn__hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ----- Move log ---------------------------------------------------------- */

.rm-log {
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.65);
}

.rm-log__line--last {
    color: #fff;
    font-weight: 600;
}

/* ----- Melds on the table ------------------------------------------------ */

.rm-melds {
    align-self: stretch;
    background: rgba(0, 0, 0, 0.14);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

/* Below the felt (finished round) the melds sit on the page, not the felt. */
.tk-felt-wrap > #tk-root > .rm-melds {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
}

.rm-melds__title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.rm-melds__empty { font-size: 0.85rem; opacity: 0.75; }

.rm-melds__row,
.rm-staged {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.rm-meld {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.12);
    border: 2px solid transparent;
    border-radius: 0.5rem;
    padding: 0.3rem;
    color: inherit;
}

.rm-meld .tk-card + .tk-card { margin-left: calc(var(--tk-card-w) * var(--rm-meld-overlap, 0.5) * -1); }
.rm-meld[data-owner] { border-left-color: var(--rm-owner); border-left-width: 4px; }
.rm-meld:disabled { cursor: default; }

.rm-meld--target {
    cursor: pointer;
    border-color: rgba(212, 175, 55, 0.55);
}

.rm-meld--target:hover {
    border-color: var(--tk-tarok);
    background: rgba(212, 175, 55, 0.15);
}

.rm-meld__pts {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    white-space: nowrap;
}

/* ----- Staging tray (inside the tarok prompt panel) ----------------------- */

.rm-prompt {
    align-self: center;
    max-width: 100%;
    color: var(--text-primary);
}
.rm-staged { margin-bottom: 0.75rem; }

.rm-meld--staged {
    cursor: pointer;
    background: var(--bg-primary);
    border-color: var(--border-default);
}

.rm-meld--bad { border-color: var(--color-danger-500, #dc3545); }

/* ----- Open remi: the shared, rebuildable table ---------------------------- */

/* One area for every meld; groups wrap like words in a paragraph. */
.rm-melds--open .rm-melds__row--open { align-items: flex-start; }

.rm-meld--draft { min-height: calc(var(--tk-card-w) * 1.4 + 0.6rem); }

/* A draft group is both a drop target and a row of tappable cards. */
.rm-meld--draft.rm-meld--target { border-style: dashed; }

/* Cards from the hand that now sit in a meld, so "Back to hand" has an obvious subject. */
.rm-card--new { box-shadow: 0 0 0 2px var(--tk-tarok); }

/* The open card beside the stock: gold when it is in the hand pool, dimmed until you can go out. */
.rm-pile--open .tk-card { opacity: 0.92; }
.rm-pile--used .tk-card { outline: 3px solid var(--tk-tarok); outline-offset: 1px; }

.rm-prompt__blocker { color: var(--color-danger-500, #dc3545); }

/* A total at or over the knock-out mark. */
.rm-over-limit { font-weight: 700; }

/* ----- Hand ------------------------------------------------------------- */

/* The just-taken discard, so it is easy to spot in the fan. */
.rm-card--taken { outline: 3px solid var(--tk-tarok); outline-offset: 1px; }

/* Hand reorder: relative so offsetLeft is measured inside the fan; no text selection or iOS
   callout while a finger holds a card. Native scroll stays until the hold starts a drag. */
.rm-hand { position: relative; }
.rm-hand .tk-card {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: pan-x pan-y;
}
.rm-hand--dragging { cursor: grabbing; }

/* The lifted copy that follows the pointer. */
.rm-card--ghost {
    position: fixed;
    z-index: 2000;
    margin: 0;
    pointer-events: none;
    transform: translateY(-0.5rem) rotate(-3deg) scale(1.04);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.4);
}
.rm-card--ghost__count {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--tk-tarok);
    color: #111;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.4rem;
    text-align: center;
}

/* Where the card will land. */
.rm-card--placeholder { outline: 2px dashed var(--tk-tarok); outline-offset: -2px; }
.rm-card--placeholder .tk-card__art { opacity: 0.3; }
.rm-card--hidden { display: none; }

/* The card that just moved or arrived: a gold ring that pulses once and fades in ~2 s. The
   negative delay (set inline) lets a re-render carry on fading instead of restarting. */
.rm-card--moved {
    position: relative;
    z-index: 3;
    animation: rm-moved-glow 2s ease-out var(--rm-moved-delay, 0s) both;
}
@keyframes rm-moved-glow {
    0% { box-shadow: 0 0 0 3px var(--tk-tarok), 0 0 4px 0 transparent; }
    15% { box-shadow: 0 0 0 4px var(--tk-tarok), 0 0 18px 4px var(--tk-tarok); }
    60% { box-shadow: 0 0 0 3px var(--tk-tarok), 0 0 10px 1px var(--tk-tarok); }
    100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .rm-card--moved { animation-name: rm-moved-fade; }
    @keyframes rm-moved-fade {
        0%, 70% { box-shadow: 0 0 0 3px var(--tk-tarok); }
        100% { box-shadow: 0 0 0 0 transparent; }
    }
}

.rm-hand-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.75rem;
}

.rm-hand-tools .btn-link { padding: 0; font-size: 0.8rem; }

/* ----- Result ------------------------------------------------------------ */

.rm-result__hands {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.75rem 0;
}

.rm-result__row {
    display: grid;
    grid-template-columns: minmax(7rem, 10rem) 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
}

.rm-result__row--winner { background: rgba(22, 163, 74, 0.1); }

.rm-result__who {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    min-width: 0;
}

.rm-result__cards {
    display: flex;
    flex-wrap: wrap;
}

.rm-result__cards .tk-card + .tk-card { margin-left: calc(var(--tk-card-w) * -0.5); }

.rm-result__pen {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 575.98px) {
    .rm-result__row { grid-template-columns: 1fr auto; }
    .rm-result__cards { grid-column: 1 / -1; order: 3; }
}

/* ----- Landing hero fan --------------------------------------------------- */

.rm-hero-fan {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.rm-hero-fan img {
    width: 4.5rem;
    border-radius: 0.45rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin: 0 -0.75rem;
}

.rm-hero-fan img:nth-child(1) { transform: rotate(-16deg) translateY(10px); }
.rm-hero-fan img:nth-child(2) { transform: rotate(-8deg) translateY(2px); }
.rm-hero-fan img:nth-child(4) { transform: rotate(8deg) translateY(2px); }
.rm-hero-fan img:nth-child(5) { transform: rotate(16deg) translateY(10px); }

/* Six quick-start tiles (2, 3 and 4 players) - three columns instead of tarok's two. The
   tarok rule drops to one column on a phone, and that still wins below 576px. */
@media (min-width: 576px) {
    .tarok-quickstart--three {
        grid-template-columns: repeat(3, 1fr);
        max-width: 42rem;
    }
}

/* Open remi: the 5 and 6 player cards only exist while the switch is on, and then the row
   becomes five wide (cpu 2-6 above friends 2-6) on a tablet or wider. */
.tarok-quickstart--open-switchable .tarok-quickstart__open-only {
    display: none;
}
.tarok-quickstart--open-switchable.is-open-remi .tarok-quickstart__open-only {
    display: flex;
}
@media (min-width: 768px) {
    .tarok-quickstart--open-switchable.is-open-remi {
        grid-template-columns: repeat(5, 1fr);
        max-width: 64rem;
    }
}

/* The between-rounds card sits centred on the felt, as the tarok result does. */
.rm-center > .tk-result {
    align-self: center;
    width: 100%;
    max-width: 40rem;
}

/* ----- Last turn: what the others laid or moved ------------------------------ */

/* Laid from a hand (or a discard just thrown): a steady gold ring. */
.rm-card--laid { box-shadow: 0 0 0 3px var(--tk-tarok), 0 0 8px 1px var(--tk-tarok); }

/* A table card that changed meld: dashed gold outline. */
.rm-card--shifted { outline: 2px dashed var(--tk-tarok); outline-offset: 1px; }

/* A taken discard flying to its player's seat (fixed copy, removed after the move). */
.rm-fly-ghost {
    position: fixed;
    z-index: 2000;
    margin: 0;
    pointer-events: none;
    transform-origin: center;
    transition: transform 500ms ease, opacity 500ms ease;
}

.rm-log__line--last {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}
.rm-log__replay {
    flex: 0 0 auto;
    align-self: center;
    padding: 0.1rem 0.3rem;
    border: 0;
    background: transparent;
    color: var(--tk-tarok);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}
.rm-log__replay:hover,
.rm-log__replay:focus-visible { color: inherit; }

/* ==========================================================================
   Table v2 (issue #75): badges around the felt, responsive layout, touch
   ========================================================================== */

.rm-tk { overflow-x: clip; }

/* ----- Opponent badges ---------------------------------------------------- */

.rm-seats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}
.rm-seat-slot { display: contents; }

/* A seat is only a bubble: avatar, card count on one corner, a gold dot once opened.
   The name lives in the hover title / long-press tip (web/js/remi/press.js). */
.rm-seat {
    position: relative;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    box-shadow: none;
}
.rm-seat .tk-avatar { flex: 0 0 auto; width: 2.5rem; height: 2.5rem; }
.rm-seat__count {
    position: absolute;
    top: -0.25rem;
    right: -0.35rem;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: #2b2b33;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
}
.rm-seat__opened {
    position: absolute;
    right: -0.1rem;
    bottom: -0.1rem;
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 50%;
    background: var(--tk-tarok);
    border: 2px solid #1b1b1f;
}
.rm-seat.tk-seat--turn { background: transparent; box-shadow: 0 0 0 3px var(--tk-tarok); }
.rm-seat.tk-seat--away { opacity: 0.5; }

/* ----- Points counter + long-press bubble ------------------------------------ */

.rm-counter {
    align-self: center;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.rm-counter--ok { background: rgba(22, 163, 74, 0.18); color: #15803d; }

.rm-press-tip {
    position: fixed;
    z-index: 3000;
    max-width: min(18rem, calc(100vw - 16px));
    padding: 0.45rem 0.7rem;
    border-radius: 0.5rem;
    background: rgba(20, 20, 24, 0.94);
    color: #fff;
    font-size: 0.85rem;
    line-height: 1.3;
    pointer-events: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

[data-press] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ----- Touch: drag cards, 44px targets ------------------------------------------ */

.rm-tk .tk-hand .tk-card { touch-action: pan-x pan-y; }
.rm-tk .rm-meld .tk-card { touch-action: none; }
.rm-tk .rm-pile { min-width: 44px; min-height: 44px; }
.rm-tk .tk-choices .btn,
.rm-tk .rm-hand-tools .btn { min-height: 44px; }

/* ----- Hand: bottom, centred, overlap from JS, lower edge clipped -------------------- */

.rm-tk .tk-hand.rm-hand {
    padding: 1.9rem 0.75rem 0;
    height: calc(var(--tk-card-h) * 0.82 + 1.9rem);
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    align-items: flex-start;
    justify-content: safe center;
}
.rm-tk .tk-hand.rm-hand .tk-card { margin-right: calc(var(--tk-card-w) * var(--rm-hand-overlap, 0.22) * -1); }
.rm-tk .tk-hand.rm-hand .tk-card:last-child { margin-right: 0; }

/* ----- Melds: wrapping grid, overlapped cards, scroll when crowded ---------------------- */

.rm-tk .rm-melds { overflow-y: auto; }
.rm-tk .rm-melds .tk-card--mini {
    --tk-card-w: calc(var(--tk-card-w-base) * var(--rm-meld-scale, 0.82));
    --tk-card-h: calc(var(--tk-card-h-base) * var(--rm-meld-scale, 0.82));
}
.rm-tk .rm-meld .tk-card + .tk-card { margin-left: calc(var(--tk-card-w) * var(--rm-meld-overlap, 0.5) * -1); }
.rm-tk .rm-melds__row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.3rem 0.4rem; }
.rm-tk .rm-meld { padding: 0.2rem; }

/* ----- Wide screens (landscape): opponents on the sides, stock left, melds right ---------- */

@media (orientation: landscape) and (min-width: 768px) {
    .rm-tk .tk-table.rm-table {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-rows: auto minmax(0, 1fr);
        grid-template-areas: "w n e" "w c e";
        align-items: start;
        column-gap: 1rem;
    }
    .rm-tk .rm-seats { display: contents; }
    .rm-tk .rm-seat-slot { display: flex; flex-wrap: wrap; gap: 0.5rem; }
    .rm-tk .rm-seat-slot--n { grid-area: n; justify-content: center; }
    .rm-tk .rm-seat-slot--w { grid-area: w; flex-direction: column; flex-wrap: nowrap; align-items: center; align-self: center; }
    .rm-tk .rm-seat-slot--e { grid-area: e; flex-direction: column; flex-wrap: nowrap; align-items: center; align-self: center; }
    .rm-tk .tk-table.rm-table > .rm-center { grid-area: c; }

}

/* The centre splits into piles (left) and melds (right) only when the felt is wide enough:
   700px with no side seats, 1000px when opponents sit west and east. The felt (.tk-table) is
   the query container, and the seats are siblings that come before the centre. */
@container (min-width: 700px) {
    .rm-tk .rm-seats:not(:has(.rm-seat-slot--w, .rm-seat-slot--e)) ~ .rm-center:not(.tk-center--result) {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        gap: 0.75rem 1.25rem;
        align-items: start;
    }
    .rm-tk .rm-seats:not(:has(.rm-seat-slot--w, .rm-seat-slot--e)) ~ .rm-center > .rm-center__top { grid-column: 1; grid-row: 1; flex-direction: column; align-items: flex-start; justify-content: flex-start; }
    .rm-tk .rm-seats:not(:has(.rm-seat-slot--w, .rm-seat-slot--e)) ~ .rm-center > .rm-log { grid-column: 1; grid-row: 2; text-align: left; }
    .rm-tk .rm-seats:not(:has(.rm-seat-slot--w, .rm-seat-slot--e)) ~ .rm-center > .rm-melds { grid-column: 2; grid-row: 1 / span 2; }
    .rm-tk .rm-seats:not(:has(.rm-seat-slot--w, .rm-seat-slot--e)) ~ .rm-center > .rm-prompt { grid-column: 1 / -1; grid-row: 3; }
}
@container (min-width: 1000px) {
    .rm-tk .rm-seats:has(.rm-seat-slot--w, .rm-seat-slot--e) ~ .rm-center:not(.tk-center--result) {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        gap: 0.75rem 1.25rem;
        align-items: start;
    }
    .rm-tk .rm-seats:has(.rm-seat-slot--w, .rm-seat-slot--e) ~ .rm-center > .rm-center__top { grid-column: 1; grid-row: 1; flex-direction: column; align-items: flex-start; justify-content: flex-start; }
    .rm-tk .rm-seats:has(.rm-seat-slot--w, .rm-seat-slot--e) ~ .rm-center > .rm-log { grid-column: 1; grid-row: 2; text-align: left; }
    .rm-tk .rm-seats:has(.rm-seat-slot--w, .rm-seat-slot--e) ~ .rm-center > .rm-melds { grid-column: 2; grid-row: 1 / span 2; }
    .rm-tk .rm-seats:has(.rm-seat-slot--w, .rm-seat-slot--e) ~ .rm-center > .rm-prompt { grid-column: 1 / -1; grid-row: 3; }
}

/* ----- Phones: one row of badges on top, tighter chrome ------------------------------------ */

@media (max-width: 575.98px) {
    .rm-tk.container { padding-left: 0.5rem; padding-right: 0.5rem; }
    .rm-tk .tk-table.rm-table { padding: 0.75rem 0.5rem; }
    .rm-seat { width: 2.35rem; height: 2.35rem; }
    .rm-seat .tk-avatar { width: 2.1rem; height: 2.1rem; }
}

/* ----- Drag targets and card flights (issue #75, phase 2) ---------------------------------- */

.rm-drop--over {
    outline: 3px solid var(--tk-tarok);
    outline-offset: 2px;
    background: rgba(212, 175, 55, 0.18);
    border-radius: 0.6rem;
}
.rm-pile--discard.rm-drop--over .tk-card { box-shadow: 0 0 0 3px var(--tk-tarok), 0 6px 14px rgba(0, 0, 0, 0.4); }

.rm-fly-ghost { will-change: transform, opacity; }

/* ----- Quickstart: table settings (issue #75) ------------------------------------------------- */

.rm-qs-settings {
    max-width: 34rem;
    margin: 0 auto 1.25rem;
    text-align: left;
    --rm-gold: var(--tk-tarok, #d4af37);
}

.rm-qs-settings__summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--card-border, var(--border-default));
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    box-shadow: var(--card-shadow, none);
    transition: border-color 0.15s ease;
}
.rm-qs-settings__summary::-webkit-details-marker { display: none; }
.rm-qs-settings__summary:hover { border-color: var(--rm-gold); }
.rm-qs-settings[open] > .rm-qs-settings__summary { border-radius: 1rem 1rem 0 0; border-bottom-color: transparent; }

.rm-qs-settings__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--rm-gold) 18%, transparent);
    color: var(--rm-gold);
    font-size: 0.85rem;
}

.rm-qs-settings__head { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.rm-qs-settings__title { font-weight: 600; font-size: 0.95rem; }
.rm-qs-settings__sum {
    font-size: 0.78rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rm-qs-settings.is-custom .rm-qs-settings__title::after {
    content: '';
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    margin-left: 0.4rem;
    border-radius: 50%;
    background: var(--rm-gold);
    vertical-align: middle;
}
.rm-qs-settings__chev { flex: 0 0 auto; font-size: 0.75rem; opacity: 0.6; transition: transform 0.2s ease; }
.rm-qs-settings[open] .rm-qs-settings__chev { transform: rotate(180deg); }

.rm-qs-settings__card {
    padding: 0.25rem 0.9rem 0.75rem;
    border: 1px solid var(--card-border, var(--border-default));
    border-top: 0;
    border-radius: 0 0 1rem 1rem;
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--card-shadow, none);
}

.rm-qs-settings__row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-top: 1px solid var(--card-border, var(--border-default));
}
.rm-qs-settings__row:first-child { border-top: 0; }
.rm-qs-settings__row[hidden] { display: none; }
.rm-qs-settings__label { font-size: 0.9rem; font-weight: 500; }
.rm-qs-settings__control { justify-self: end; }

.rm-seg {
    display: inline-flex;
    padding: 0.2rem;
    gap: 0.15rem;
    border: 1px solid var(--card-border, var(--border-default));
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-primary) 5%, transparent);
}
.rm-seg__btn {
    min-width: 2.75rem;
    min-height: 2.5rem;
    padding: 0 0.75rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.rm-seg__btn:hover { background: color-mix(in srgb, var(--rm-gold) 18%, transparent); }
.rm-seg__btn.is-active { background: var(--rm-gold); color: #1b1b1f; }

.rm-step {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem;
    border: 1px solid var(--card-border, var(--border-default));
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-primary) 5%, transparent);
}
.rm-step__btn {
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 0.8rem;
    transition: background-color 0.15s ease;
}
.rm-step__btn:hover { background: color-mix(in srgb, var(--rm-gold) 25%, transparent); }
.rm-step__value {
    min-width: 3.25rem;
    text-align: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.rm-step__value.is-default { opacity: 0.55; font-weight: 500; }

.rm-qs-settings__note { margin: 0.25rem 0 0; font-size: 0.8rem; opacity: 0.8; }
.rm-qs-settings__reset {
    display: block;
    margin: 0.5rem 0 0 auto;
    padding: 0.25rem 0.5rem;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 0.8rem;
    opacity: 0.7;
}
.rm-qs-settings__reset:hover { opacity: 1; text-decoration: underline; }

.tarok-quickstart__form button.is-blocked,
.tarok-quickstart__form button:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 479.98px) {
    .rm-qs-settings__row { grid-template-columns: auto 1fr; }
    .rm-qs-settings__control { grid-column: 1 / -1; justify-self: stretch; }
    .rm-seg, .rm-step { display: flex; }
    .rm-seg__btn { flex: 1 1 0; }
    .rm-step__value { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .rm-qs-settings__summary, .rm-qs-settings__chev, .rm-seg__btn, .rm-step__btn { transition: none; }
}

/* ----- Results drawer (issue #75, phase 3) ------------------------------------------------------ */

.rm-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1900;
    width: min(26rem, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #222);
    border-left: 1px solid var(--border-default, #ddd);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.25);
    transform: translateX(105%);
    transition: transform 280ms cubic-bezier(.2, .7, .3, 1);
    visibility: hidden;
}
.rm-drawer.is-open { transform: none; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .rm-drawer { transition: none; } }

.rm-drawer__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-default, #ddd);
}
.rm-drawer__tabs { display: flex; gap: 0.25rem; padding: 0.5rem 0.75rem 0; overflow-x: auto; }
.rm-drawer__tab {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0.4rem 0.8rem;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: inherit;
    font-size: 0.9rem;
}
.rm-drawer__tab.is-active { border-bottom-color: var(--tk-tarok); font-weight: 700; }
.rm-drawer__body { flex: 1 1 auto; overflow-y: auto; padding: 1rem; }
.rm-drawer__result.tk-prompt { box-shadow: none; padding: 0; background: transparent; }
.rm-drawer__setting { margin-bottom: 1rem; }
.rm-drawer__setting-label { font-size: 0.8rem; opacity: 0.75; margin-bottom: 0.25rem; }
.rm-drawer__head { margin-top: 1.5rem; }
.rm-drawer__rules { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; font-size: 0.9rem; }
.rm-drawer__rules dt { font-weight: 400; opacity: 0.8; }
.rm-drawer__rules dd { margin: 0; font-weight: 600; text-align: right; }

/* ----- Open remi: the open card lies sideways under the stock (issue #75) ---------------------- */

.rm-tk .rm-piles .rm-pile:first-child { position: relative; z-index: 1; }
/* Stock on top, the open card lies sideways right under it (the stock covers its top edge). */
.rm-tk .rm-piles--open { flex-direction: column; align-items: center; gap: 0; }
.rm-tk .rm-pile--open { margin-top: 0.15rem; padding: 0.1rem; }
.rm-tk .rm-pile--open .tk-card {
    rotate: 90deg;
    /* The footprint of a rotated card is height x width: pad the sides, trim top and bottom. */
    margin: calc((var(--tk-card-w) - var(--tk-card-h)) / 2) calc((var(--tk-card-h) - var(--tk-card-w)) / 2);
}

/* Next below the opening threshold is still pressable (it explains and returns the cards). */
.rm-btn--soft { opacity: 0.7; }

/* ----- Round 2 (issue #75): icon buttons, floating bar, folded log ---------------------------- */

.rm-prompt:empty { display: none; }

.rm-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.4rem; }
.rm-ibtn { position: relative; min-width: 44px; min-height: 44px; padding: 0 0.7rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; font-size: 1rem; }
.rm-ibtn__pts { font-size: 0.75rem; font-weight: 700; }
.rm-ibtn.is-off { opacity: 0.45; cursor: default; box-shadow: none; }
.rm-hand-tools .rm-ibtn { min-width: 44px; padding: 0 0.5rem; }

.rm-log-holder { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.rm-log-toggle.rm-ibtn { min-height: 32px; min-width: 44px; color: rgba(255, 255, 255, 0.75); }
.rm-log-holder.is-open .rm-log-toggle { color: #fff; }
.rm-tk .rm-seats:not(:has(.rm-seat-slot--w, .rm-seat-slot--e)) ~ .rm-center > .rm-log-holder,
.rm-tk .rm-seats:has(.rm-seat-slot--w, .rm-seat-slot--e) ~ .rm-center > .rm-log-holder { align-items: flex-start; }

/* The floating bar (every device, round 3). No card behind it: the icon buttons float over the table. */
.rm-dock {
    position: fixed;
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    background: none;
    max-width: calc(100vw - 8px);
}
.rm-dock[hidden] { display: none; }
.rm-dock--column { flex-direction: column; }
.rm-dock__grip { min-width: 32px; min-height: 44px; border: 0; border-radius: 999px; background: rgba(20, 20, 24, 0.55); color: rgba(255, 255, 255, 0.85); touch-action: none; cursor: grab; user-select: none; }
.rm-dock.is-dragging .rm-dock__grip { cursor: grabbing; color: #fff; }
.rm-dock.is-dragging { user-select: none; }
.rm-dock__body .rm-actions { flex-wrap: nowrap; gap: 0.35rem; }
.rm-dock--column .rm-dock__body .rm-actions { flex-direction: column; }
.rm-dock .rm-ibtn { border-radius: 999px; background: rgba(20, 20, 24, 0.78); color: #fff; border: 1px solid rgba(255, 255, 255, 0.18); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); backdrop-filter: blur(6px); }
.rm-dock .rm-ibtn.btn-primary, .rm-dock .rm-ibtn.btn-success { background: rgba(37, 99, 235, 0.9); border-color: rgba(255, 255, 255, 0.3); }
.rm-dock .rm-counter { background: rgba(20, 20, 24, 0.78); color: #fff; border-radius: 999px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.rm-dock .rm-counter--ok { background: rgba(22, 163, 74, 0.85); color: #fff; }
@media (max-width: 575.98px) {
    .rm-dock .rm-ibtn { min-width: 40px; padding: 0 0.5rem; }
}

/* Only cards matter: the round label and the turn hints go (the turn flag stays, the opening
   threshold is in the points counter tip). */
.rm-tk .rm-turn__round,
.rm-tk .rm-turn__hint,
.rm-tk .rm-turn .tk-turnflag__hint { display: none; }
.rm-tk .rm-turn .tk-turnflag { padding: 0.3rem 0.9rem; }
.rm-tk .rm-prompt.tk-prompt { padding: 0.5rem 0.75rem; }


/* ----- Round 3 (issue #75): the whole game on one screen, no page scroll ------------------------
   Only while a game is on (table.js sets body.remi-playing; lobby and result keep the normal page). */
@supports (height: 100dvh) {
    html:has(body.remi-playing) { height: 100dvh; }
    body.remi-playing { height: 100dvh; }
}
html:has(body.remi-playing), body.remi-playing { height: 100vh; overflow: hidden; }
body.remi-playing { display: flex; flex-direction: column; }
body.remi-playing .tarok-app__footer,
body.remi-playing .cookie-settings-chip,
body.remi-playing .tk-meta-line { display: none !important; }
body.remi-playing .tarok-app__header { flex: 0 0 auto; padding-top: 0.15rem; padding-bottom: 0.15rem; }
body.remi-playing .tarok-app__main { flex: 1 1 auto !important; min-height: 0; display: flex; flex-direction: column; }
body.remi-playing .rm-tk.container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    max-width: 100%;
}
body.remi-playing .rm-tk > .d-flex.justify-content-between { flex: 0 0 auto; margin-bottom: 0.25rem !important; }
body.remi-playing .rm-tk h1 { display: none; }
body.remi-playing .rm-tk > #tk-flash { flex: 0 0 auto; }
body.remi-playing .rm-tk .tk-felt-wrap { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
body.remi-playing .rm-tk #tk-root { flex: 1 1 auto; min-height: 0; gap: 0.5rem !important; }
body.remi-playing .rm-tk .tk-table.rm-table { flex: 1 1 auto; min-height: 0; overflow: hidden; }
@media not ((orientation: landscape) and (min-width: 768px)) {
    body.remi-playing .rm-tk .tk-table.rm-table { display: flex; flex-direction: column; }
}
body.remi-playing .rm-tk .tk-table.rm-table > .rm-center { flex: 1 1 auto; min-height: 0; }
body.remi-playing .rm-tk .rm-melds { min-height: 0; overflow-y: auto; }
body.remi-playing .rm-tk .rm-hand { flex: 0 0 auto; }
