/* ==========================================================================
   Bingo — sistema visual
   Base cálida y clara, un acento por modo, Línea verde y Bingo ámbar.
   ========================================================================== */

:root {
    --bg: #FAF7F2;
    --surface: #FFFFFF;
    --surface-2: #F6F2EB;
    --cell-bg: #FBF9F5;
    --border: #E9E3D8;
    --border-strong: #D8D0C2;
    --text: #1B2433;
    --text-2: #4A5361;
    --text-3: #6B7380;
    --navy: #24324A;
    --focus: #1B2433;

    /* Acento del modo (Números por defecto) */
    --accent: #EF4444;
    --accent-strong: #DC2626;
    --accent-soft: #FDECEC;
    --accent-ink: #9F1D1D;
    --accent-shadow: rgba(239, 68, 68, 0.35);

    --line: #22A055;
    --line-soft: #EAF7EF;
    --line-ink: #146C3A;
    --bingo: #F2A516;
    --bingo-soft: #FFF5DE;
    --bingo-ink: #8A4B07;

    --radius-lg: 20px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(27, 36, 51, 0.04);
    --shadow: 0 1px 2px rgba(27, 36, 51, 0.04), 0 6px 20px -8px rgba(27, 36, 51, 0.10);

    --header-h: 64px;
    --gutter: 16px;
    --gap: 16px;
    --cols: 10;
    --rows: 10;
    --cell-max: 120px;
    --board-gap: clamp(3px, 0.55vw, 8px);
}

body[data-mode="emojis"] {
    --accent: #EA580C;
    --accent-strong: #C2410C;
    --accent-soft: #FFF1E6;
    --accent-ink: #9A3412;
    --accent-shadow: rgba(234, 88, 12, 0.32);
}

body[data-mode="cofrade"] {
    --accent: #6B3FA0;
    --accent-strong: #57318A;
    --accent-soft: #F3EDFA;
    --accent-ink: #4A2A75;
    --accent-shadow: rgba(107, 63, 160, 0.30);
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

button, select { font: inherit; color: inherit; }

.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;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
    width: 1.25em; height: 1.25em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.eyebrow {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-3);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    min-width: 0;
}

/* ---------- Cabecera ---------- */

.app-header {
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
    width: 30px; height: 30px; flex: none; border-radius: 50%;
    background: var(--accent);
    box-shadow: inset 0 0 0 7px var(--accent), inset 0 0 0 30px var(--surface);
    transition: background-color .3s, box-shadow .3s;
}

.brand-text { min-width: 0; }
.brand-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.brand-mode {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--accent-ink); line-height: 1.2;
}

.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.mode-select select {
    appearance: none; -webkit-appearance: none;
    height: 44px; padding: 0 36px 0 14px;
    border: 1px solid var(--border-strong); border-radius: 12px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A5361' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 18px;
    font-weight: 600; font-size: 0.95rem; color: var(--text);
    cursor: pointer;
}
.mode-select select:hover { border-color: var(--text-3); }

.icon-btn {
    width: 44px; height: 44px; display: inline-grid; place-items: center;
    border: 1px solid var(--border-strong); border-radius: 12px;
    background: var(--surface); color: var(--text-2);
    cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.icon-btn:hover { border-color: var(--text-3); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--text-3); border-style: dashed; }
.icon-btn[aria-expanded="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.icon-btn .icon { width: 22px; height: 22px; }
.icon-btn--sm { width: 36px; height: 36px; border-radius: 10px; }
.icon-btn--sm .icon { width: 18px; height: 18px; }

/* ---------- Botones ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 16px;
    border: 2px solid transparent; border-radius: var(--radius);
    font-weight: 800; font-size: 0.95rem; letter-spacing: 0.04em; text-transform: uppercase;
    cursor: pointer; user-select: none; -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    transition: background-color .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-draw {
    width: 100%; min-height: 68px;
    background: var(--accent); color: #fff;
    font-size: clamp(1.15rem, 1.5vw, 1.4rem);
    box-shadow: 0 8px 20px -8px var(--accent-shadow);
}
.btn-draw .icon { width: 1.3em; height: 1.3em; stroke-width: 2.4; }
.btn-draw:hover:not(:disabled) { background: var(--accent-strong); }
.btn-draw:disabled {
    background: var(--accent-soft); color: var(--accent-ink);
    border-color: var(--accent-soft); box-shadow: none; cursor: not-allowed;
}
body.is-spinning .btn-draw:disabled { cursor: progress; }
body.is-spinning .btn-draw .icon { animation: spin 0.8s linear infinite; }

.btn-line { background: var(--line-soft); border-color: var(--line); color: var(--line-ink); }
.btn-line:hover:not(:disabled) { background: #D9F0E2; }
.btn-line.is-called,
.btn-line:disabled {
    background: transparent; border-style: dashed; border-color: #B7CBBE;
    color: #4F6B5A; cursor: not-allowed;
}

.btn-bingo { background: var(--bingo-soft); border-color: var(--bingo); color: var(--bingo-ink); }
.btn-bingo:hover { background: #FFEBC0; }
.btn-bingo.is-flash { background: var(--bingo); color: var(--text); animation: flash .5s ease-in-out 4; }

.kbd-hint { margin-top: 8px; font-size: 0.75rem; color: var(--text-3); text-align: center; }
kbd {
    display: inline-block; min-width: 1.6em; padding: 1px 6px;
    border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px;
    background: var(--surface); font: 600 0.72rem/1.4 'Inter', system-ui, sans-serif; color: var(--text-2);
}
@media (hover: none) { .kbd-hint { display: none; } }

/* ---------- Panel actual ---------- */

.current-card {
    --stage: clamp(7rem, 30vw, 9rem);
    display: flex; align-items: center; gap: 16px; padding: 16px;
}

.current-stage {
    position: relative; flex: none;
    width: var(--stage); height: var(--stage);
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    transition: background-color .3s;
}
.current-stage::before {
    content: ''; position: absolute; inset: -6px; border-radius: 50%;
    border: 3px solid transparent;
}
body.is-spinning .current-stage::before {
    border-top-color: var(--accent); border-right-color: var(--accent);
    animation: spin 0.7s linear infinite;
}

.current-value {
    font-size: calc(var(--stage) * 0.5); font-weight: 800; line-height: 1;
    letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
    color: var(--accent-strong);
}
body:not([data-mode="numbers"]) .current-value { font-size: calc(var(--stage) * 0.56); letter-spacing: 0; }
.current-value.is-empty { color: var(--text-3); opacity: .5; font-size: calc(var(--stage) * 0.42); }
.current-stage:has(.is-empty) { background: var(--surface-2); }
.current-value.tick { animation: tick 90ms ease-out; }
.current-value.reveal { animation: reveal 380ms cubic-bezier(.2, .9, .3, 1.3); }

.current-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.current-phrase {
    font-size: 0.98rem; font-weight: 500; color: var(--text-2);
    min-height: 2.8em; overflow-wrap: anywhere;
}
.current-phrase.is-hint { color: var(--text-3); }

.counters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.counter {
    min-width: 0; padding: 8px 10px; border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.counter dt { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.counter dd { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 4px; font-size: 1.5rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.counter dd small { font-size: 0.8rem; font-weight: 600; color: var(--text-3); }

/* ---------- Últimas ---------- */

.recent-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.recent-list { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 3rem; }
.recent-list:empty { display: none; }
.recent-empty { font-size: 0.9rem; color: var(--text-3); min-height: 3rem; display: flex; align-items: center; }
.recent-empty[hidden] { display: none; }

.recent-item {
    flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface-2); border: 1px solid var(--border);
    font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; color: var(--text-2);
}
.recent-item.is-latest {
    width: 3.1rem; height: 3.1rem; font-size: 1.3rem; font-weight: 800;
    background: var(--accent-strong); border-color: var(--accent-strong); color: #fff;
}
body:not([data-mode="numbers"]) .recent-item { font-size: 1.35rem; }
body:not([data-mode="numbers"]) .recent-item.is-latest {
    font-size: 1.7rem; background: var(--accent-soft); border: 2px solid var(--accent);
}

/* ---------- Tablero ---------- */

.board-panel { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.board-header {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.board-title { font-size: 1rem; font-weight: 700; }

.marker {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border);
}
.marker .icon { width: 14px; height: 14px; stroke-width: 3; }
.marker.active { background: var(--line-soft); color: var(--line-ink); border-color: var(--line); }

.board-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: var(--board-gap);
    width: 100%;
    max-width: calc(var(--cols) * var(--cell-max));
    margin: auto;
    container-type: inline-size;
}

.cell {
    position: relative; aspect-ratio: 1; min-width: 0;
    display: grid; place-items: center;
    border-radius: 18%;
    background: var(--cell-bg);
    border: 1px solid var(--border);
    color: #7A8391;
    font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
    font-size: clamp(0.7rem, 2.6vw, 1.6rem);
    font-size: calc(100cqi / var(--cols) * 0.42);
    transition: background-color .25s, color .25s, border-color .25s, transform .25s;
}
body:not([data-mode="numbers"]) .cell { font-size: clamp(0.9rem, 3.4vw, 2.2rem); font-size: calc(100cqi / var(--cols) * 0.56); }
body:not([data-mode="numbers"]) .cell .glyph { filter: grayscale(1); opacity: .38; transition: opacity .25s, filter .25s; }

/* Salido */
.cell.is-drawn { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
body:not([data-mode="numbers"]) .cell.is-drawn { background: var(--accent-soft); border: 2px solid var(--accent); }
body:not([data-mode="numbers"]) .cell.is-drawn .glyph { filter: none; opacity: 1; }

/* Último */
.cell.is-last {
    z-index: 1; transform: scale(1.08);
    background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 800;
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--accent), 0 8px 18px -6px var(--accent-shadow);
}
body:not([data-mode="numbers"]) .cell.is-last { background: var(--accent); border-color: var(--accent-strong); }

/* ---------- Cantar (Línea / Bingo) ---------- */

.calls { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Herramientas ---------- */

.tools-panel { display: flex; flex-direction: column; gap: 8px; }
.tools-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }

.tool-btn {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px;
    padding: 10px 12px; text-align: left;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); cursor: pointer;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    transition: background-color .15s, border-color .15s;
}
.tool-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.tool-btn .icon { width: 22px; height: 22px; color: var(--text-2); }
.tool-text { display: flex; flex-direction: column; min-width: 0; }
.tool-text strong { font-size: 0.92rem; font-weight: 700; }
.tool-text small { font-size: 0.76rem; color: var(--text-3); }
.tool-btn--danger .icon, .tool-btn--danger strong { color: #B42318; }
.tool-btn:disabled { cursor: progress; opacity: .7; background: var(--surface-2); }
.tool-btn.is-busy .icon { animation: spin 1s linear infinite; }

/* ---------- Celebración y avisos ---------- */

.celebration {
    position: fixed; left: 50%; top: 42%; z-index: 80;
    transform: translate(-50%, -50%) scale(.9);
    padding: 0.3em 0.8em; border-radius: 28px;
    font-size: clamp(3rem, 11vw, 8rem); font-weight: 800; letter-spacing: 0.02em; line-height: 1.1;
    white-space: nowrap; pointer-events: none;
    background: var(--surface); border: 4px solid currentColor;
    box-shadow: 0 30px 60px -20px rgba(27, 36, 51, .35);
    opacity: 0; visibility: hidden;
    transition: opacity .2s, transform .25s cubic-bezier(.2, .9, .3, 1.3), visibility 0s .25s;
}
.celebration.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); transition-delay: 0s; }
.celebration.is-line { color: var(--line-ink); background: var(--line-soft); }
.celebration.is-bingo { color: var(--bingo-ink); background: var(--bingo-soft); }

.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90;
    transform: translate(-50%, 12px);
    max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px;
    background: var(--text); color: #fff; font-weight: 600; font-size: 0.95rem;
    box-shadow: var(--shadow);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .2s, transform .2s, visibility 0s .2s;
}
.toast.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.toast.is-error { background: #B42318; }

/* ---------- Animaciones ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes tick {
    from { transform: translateY(-18%); opacity: .35; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes reveal {
    0% { transform: scale(.7); opacity: .4; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes flash { 50% { box-shadow: 0 0 0 6px rgba(242, 165, 22, .35); } }

/* ==========================================================================
   Layouts
   ========================================================================== */

/* Móvil (< 640 px): una columna, barra de juego fija abajo */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "current" "recent" "board" "bar";
    gap: 12px;
    padding: 12px max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}
.current-card { grid-area: current; }
.recent-card { grid-area: recent; }
.board-panel { grid-area: board; }

.play-bar {
    grid-area: bar;
    position: sticky; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr); gap: 8px;
    margin-inline: calc(var(--gutter) * -1);
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: rgba(250, 247, 242, 0.96);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 20px -14px rgba(27, 36, 51, .25);
}
.play-bar .calls { display: contents; }
.play-bar .calls-title { display: none; }
.play-bar .btn-line { grid-column: 1; grid-row: 1; }
.play-bar .draw-wrap { grid-column: 2; grid-row: 1; min-width: 0; }
.play-bar .btn-bingo { grid-column: 3; grid-row: 1; }
.play-bar .btn-draw { min-height: 56px; padding: 0 8px; gap: 6px; font-size: clamp(0.92rem, 4.1vw, 1.15rem); letter-spacing: 0.02em; white-space: nowrap; }
.play-bar .btn-line, .play-bar .btn-bingo { min-height: 56px; padding: 0 6px; font-size: 0.8rem; gap: 5px; letter-spacing: 0.02em; }
.play-bar .btn-line.is-called .btn-text { font-size: 0.68rem; line-height: 1.1; }
.play-bar .kbd-hint { display: none; }

.board-panel { padding: 12px; }

/* Herramientas como panel desplegable (< 1100 px) */
.tools-panel {
    position: fixed; z-index: 60;
    top: calc(var(--header-h) + 8px); right: max(var(--gutter), env(safe-area-inset-right));
    width: min(21rem, calc(100vw - 2 * var(--gutter)));
    max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto;
    padding: 12px; border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: 0 24px 48px -16px rgba(27, 36, 51, .28);
}
.tools-panel:not(.is-open) { display: none; }

.toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

@media (max-width: 359px) {
    :root { --gutter: 12px; }
    .brand-mark { display: none; }
    .mode-select select { padding-left: 10px; padding-right: 30px; background-position: right 6px center; font-size: 0.88rem; }
    .play-bar .btn-line .icon, .play-bar .btn-bingo .icon { display: none; }
    .current-card { --stage: 6rem; gap: 12px; padding: 12px; }
}

/* Tablet vertical / ventanas medias (≥ 640 px) */
@media (min-width: 640px) {
    :root { --gutter: 20px; --gap: 16px; }
    .layout {
        gap: var(--gap);
        padding: var(--gap) var(--gutter) var(--gutter);
        grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
        grid-template-areas:
            "current recent"
            "bar     bar"
            "board   board";
    }
    .current-card { --stage: clamp(8rem, 17vw, 10.5rem); padding: 20px; gap: 20px; }
    .recent-card { justify-content: center; padding: 20px; }
    .recent-item { width: 2.75rem; height: 2.75rem; font-size: 1.05rem; }
    .recent-item.is-latest { width: 3.4rem; height: 3.4rem; font-size: 1.45rem; }

    .play-bar {
        position: static; margin: 0; padding: 0; background: none; border: 0; box-shadow: none;
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); gap: 12px;
    }
    .play-bar .btn-draw, .play-bar .btn-line, .play-bar .btn-bingo { min-height: 68px; }
    .play-bar .btn-draw { padding: 0 16px; gap: 8px; font-size: clamp(1.1rem, 2.2vw, 1.35rem); }
    .play-bar .btn-line, .play-bar .btn-bingo { font-size: 0.95rem; padding: 0 12px; gap: 8px; }
    .play-bar .btn-line.is-called .btn-text { font-size: 0.85rem; }

    .board-panel { padding: 18px; }
    /* El tablero intenta caber en la altura sin bajar de un tamaño legible */
    .board-grid {
        --board-offset: 470px;
        width: min(100%, max(28rem, calc((100vh - var(--board-offset)) * var(--cols) / var(--rows))));
        width: min(100%, max(28rem, calc((100dvh - var(--board-offset)) * var(--cols) / var(--rows))));
    }

    .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* Composición de pantalla horizontal: columna izquierda + tablero (iPad horizontal) */
@media (min-width: 800px) and (orientation: landscape), (min-width: 1100px) {
    .layout {
        min-height: calc(100vh - var(--header-h));
        min-height: calc(100dvh - var(--header-h));
        grid-template-columns: minmax(16rem, 19rem) minmax(0, 1fr);
        grid-template-rows: auto auto auto 1fr;
        grid-template-areas:
            "current board"
            "draw    board"
            "recent  board"
            "calls   board";
        align-items: start;
    }
    .board-panel { align-self: stretch; }

    .play-bar { display: contents; }
    .play-bar .draw-wrap { grid-area: draw; }
    .play-bar .calls { grid-area: calls; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .play-bar .calls-title { display: block; grid-column: 1 / -1; }
    .play-bar .btn-line, .play-bar .btn-bingo { grid-column: auto; grid-row: auto; min-height: 56px; }
    .play-bar .btn-draw { min-height: 72px; }
    .play-bar .kbd-hint { display: block; }

    .current-card {
        --stage: clamp(6.5rem, 18vh, 12rem);
        flex-direction: column; text-align: center; gap: 14px; padding: 20px;
    }
    .current-info { display: contents; }
    .current-card .eyebrow { order: -1; }
    .counters { align-self: stretch; }
    .counter dd { justify-content: center; }
    .current-phrase { font-size: 1.02rem; }
    .recent-card { padding: 14px 16px; }
    .recent-item { width: 2.7rem; height: 2.7rem; font-size: 1rem; }
    .recent-item.is-latest { width: 3.2rem; height: 3.2rem; font-size: 1.35rem; }

    .board-grid {
        --board-offset: 190px;
        width: min(100%, max(20rem, calc((100vh - var(--board-offset)) * var(--cols) / var(--rows))));
        width: min(100%, max(20rem, calc((100dvh - var(--board-offset)) * var(--cols) / var(--rows))));
    }
}

@media (min-width: 800px) and (orientation: landscape) and (max-height: 720px) {
    .current-card { --stage: clamp(6rem, 16vh, 8.5rem); gap: 8px; padding: 14px 16px; }
    .recent-card { padding: 10px 14px; gap: 6px; }
    .current-phrase { min-height: 0; }
    .play-bar .btn-draw { min-height: 60px; }
    .play-bar .btn-line, .play-bar .btn-bingo { min-height: 48px; }
    .counter dd { font-size: 1.3rem; }
}

/* Escritorio / proyector (≥ 1100 px): tres zonas */
@media (min-width: 1100px) {
    :root { --gutter: 24px; --gap: 20px; }
    .layout {
        grid-template-columns: clamp(17rem, 24vw, 21rem) minmax(0, 1fr) clamp(12.5rem, 17vw, 16rem);
        grid-template-rows: auto auto 1fr;
        grid-template-areas:
            "current board calls"
            "draw    board tools"
            "recent  board tools";
    }
    .play-bar .calls { grid-template-columns: 1fr; gap: 12px; }
    .play-bar .btn-line, .play-bar .btn-bingo { min-height: 64px; font-size: 1.05rem; justify-content: flex-start; padding: 0 18px; }
    .board-panel { padding: 20px; }
    .board-title { font-size: 1.1rem; }

    .settings-toggle { display: none; }
    .tools-panel,
    .tools-panel:not(.is-open) {
        grid-area: tools; align-self: end;
        display: flex; position: static; width: auto; max-height: none; overflow: visible;
        padding: 16px; box-shadow: var(--shadow);
    }
    .tools-close { display: none; }
    .board-grid { --board-offset: 200px; --cell-max: 130px; }
    body[data-mode="cofrade"] .board-grid { --cell-max: 170px; }
}

/* Movimiento reducido: sin giros ni rebotes; el estado se comunica igual por texto y color */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    body.is-spinning .current-stage::before { border-color: transparent; border-top-color: var(--accent); }
    .cell.is-last { transform: none; }
}
