:root {
    --font-display: "Space Grotesk", sans-serif;
    --font-body: "Manrope", sans-serif;
    --ink: #121417;
    --muted: #5e6570;
    --paper: #f3f6fa;
    --panel: rgba(255, 255, 255, 0.92);
    --accent: #2b67f2;
    --accent-dark: #1e49b8;
    --accent-soft: #78b3ff;
    --shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
    --border: rgba(15, 23, 42, 0.14);
    --stat-bg: #f4f7ff;
    --ghost-bg: #fff;
    --ghost-border: rgba(15, 23, 42, 0.18);
    --reset-bg: #111827;
    --cell-surface: rgba(255, 255, 255, 0.95);
    --menu-hover: rgba(15, 23, 42, 0.06);
    --focus-ring: rgba(43, 103, 242, 0.35);
    --pattern-card-bg: rgba(255, 255, 255, 0.92);
    --pattern-surface: #f8fafc;
    --pattern-border: #64748b;
    --pattern-dot: #0f172a;
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(43, 103, 242, 0.12), transparent 45%),
        radial-gradient(circle at 82% 8%, rgba(242, 176, 84, 0.18), transparent 45%),
        linear-gradient(135deg, #f7f8fc 0%, #eef2f7 40%, #f7f1e8 100%);
    --radius: 18px;
    --radius-sm: 12px;
}

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

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    min-height: 100vh;
    background: var(--page-bg);
}

body[data-mode="dark"] {
    --ink: #f8fafc;
    --muted: #a6b0be;
    --paper: #0f172a;
    --panel: rgba(15, 23, 42, 0.92);
    --accent: #60a5fa;
    --accent-dark: #2563eb;
    --accent-soft: #3b82f6;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    --border: rgba(148, 163, 184, 0.3);
    --stat-bg: rgba(30, 41, 59, 0.9);
    --ghost-bg: rgba(15, 23, 42, 0.72);
    --ghost-border: rgba(148, 163, 184, 0.35);
    --reset-bg: #1f2937;
    --cell-surface: rgba(15, 23, 42, 0.9);
    --menu-hover: rgba(148, 163, 184, 0.18);
    --focus-ring: rgba(96, 165, 250, 0.45);
    --pattern-card-bg: rgba(15, 23, 42, 0.92);
    --pattern-surface: rgba(30, 41, 59, 0.96);
    --pattern-border: rgba(226, 232, 240, 0.7);
    --pattern-dot: #f8fafc;
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(96, 165, 250, 0.22), transparent 45%),
        radial-gradient(circle at 82% 8%, rgba(14, 116, 144, 0.24), transparent 45%),
        linear-gradient(135deg, #0b1220 0%, #0f172a 45%, #111827 100%);
}

body[data-theme="midnight"] {
    --accent: #38bdf8;
    --accent-dark: #0284c7;
    --accent-soft: #0ea5e9;
    --page-bg:
        radial-gradient(circle at 10% 18%, rgba(56, 189, 248, 0.28), transparent 45%),
        radial-gradient(circle at 85% 12%, rgba(59, 130, 246, 0.25), transparent 45%),
        linear-gradient(135deg, #061024 0%, #0b1b3b 50%, #0f1e2e 100%);
}

body[data-theme="forest"] {
    --accent: #22c55e;
    --accent-dark: #16a34a;
    --accent-soft: #4ade80;
    --page-bg:
        radial-gradient(circle at 14% 18%, rgba(34, 197, 94, 0.28), transparent 45%),
        radial-gradient(circle at 84% 12%, rgba(20, 83, 45, 0.32), transparent 45%),
        linear-gradient(135deg, #071a12 0%, #0e2418 50%, #0f2a1b 100%);
}

body[data-theme="sunset"] {
    --accent: #f97316;
    --accent-dark: #ea580c;
    --accent-soft: #fb923c;
    --page-bg:
        radial-gradient(circle at 14% 18%, rgba(249, 115, 22, 0.25), transparent 45%),
        radial-gradient(circle at 84% 12%, rgba(251, 146, 60, 0.2), transparent 45%),
        linear-gradient(135deg, #fff4eb 0%, #fff1e6 45%, #fef3e8 100%);
}

body[data-theme="lagoon"] {
    --accent: #14b8a6;
    --accent-dark: #0f766e;
    --accent-soft: #5eead4;
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(20, 184, 166, 0.18), transparent 45%),
        radial-gradient(circle at 82% 10%, rgba(45, 212, 191, 0.2), transparent 45%),
        linear-gradient(135deg, #eefdfb 0%, #effaf8 45%, #eff8ff 100%);
}

body[data-theme="studio"] {
    --accent: #1f2937;
    --accent-dark: #0f172a;
    --accent-soft: #64748b;
    --border: rgba(15, 23, 42, 0.12);
    --stat-bg: #f3f4f6;
    --ghost-border: rgba(15, 23, 42, 0.16);
    --reset-bg: #111827;
    --cell-surface: #ffffff;
    --menu-hover: rgba(15, 23, 42, 0.04);
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(15, 23, 42, 0.04), transparent 45%),
        linear-gradient(135deg, #f8fafc 0%, #f1f5f9 55%, #eef2f6 100%);
}

body[data-theme="mono"] {
    --accent: #111827;
    --accent-dark: #0f172a;
    --accent-soft: #475569;
    --shadow: none;
    --border: rgba(15, 23, 42, 0.2);
    --stat-bg: #f4f4f5;
    --ghost-bg: #f8fafc;
    --ghost-border: rgba(15, 23, 42, 0.2);
    --reset-bg: #111827;
    --cell-surface: #ffffff;
    --menu-hover: rgba(15, 23, 42, 0.05);
    --page-bg:
        linear-gradient(135deg, #f7f8fa 0%, #f1f2f4 55%, #eceff2 100%);
    --radius: 10px;
    --radius-sm: 6px;
}

body[data-theme="blueprint"] {
    --accent: #1d4ed8;
    --accent-dark: #1e3a8a;
    --accent-soft: #38bdf8;
    --border: rgba(30, 64, 175, 0.2);
    --stat-bg: #edf4ff;
    --ghost-border: rgba(30, 64, 175, 0.22);
    --reset-bg: #0f172a;
    --cell-surface: rgba(255, 255, 255, 0.95);
    --menu-hover: rgba(30, 64, 175, 0.08);
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(56, 189, 248, 0.18), transparent 45%),
        linear-gradient(135deg, #eef3ff 0%, #e4ecff 50%, #f6f9ff 100%);
    --radius: 14px;
    --radius-sm: 10px;
}

body[data-theme="studio"] .color-blue,
body[data-theme="studio"] .color-red,
body[data-theme="studio"] .color-ivory,
body[data-theme="studio"] .color-green,
body[data-theme="studio"] .color-gold,
body[data-theme="mono"] .color-blue,
body[data-theme="mono"] .color-red,
body[data-theme="mono"] .color-ivory,
body[data-theme="mono"] .color-green,
body[data-theme="mono"] .color-gold {
    --cell-accent: #6b7280;
    --cell-soft: #eef1f5;
}

body[data-theme="studio"] .header,
body[data-theme="mono"] .header {
    background: #e5e7eb;
    color: #111827;
    box-shadow: none;
}

body[data-theme="studio"] .cell.drawn,
body[data-theme="mono"] .cell.drawn {
    color: #111827;
}

body[data-theme="high-contrast"] {
    --ink: #0a0a0a;
    --muted: #1f2937;
    --paper: #ffffff;
    --panel: #ffffff;
    --accent: #0a0a0a;
    --accent-dark: #000000;
    --accent-soft: #1f2937;
    --shadow: none;
    --border: #0a0a0a;
    --stat-bg: #f2f2f2;
    --ghost-bg: #ffffff;
    --ghost-border: #0a0a0a;
    --reset-bg: #000000;
    --cell-surface: #ffffff;
    --menu-hover: rgba(0, 0, 0, 0.08);
    --focus-ring: rgba(0, 0, 0, 0.4);
    --pattern-card-bg: #ffffff;
    --pattern-surface: #ffffff;
    --pattern-border: #0a0a0a;
    --pattern-dot: #000000;
    --page-bg: #ffffff;
}

body[data-theme="color-blind"] {
    --accent: #0072b2;
    --accent-dark: #005a8c;
    --accent-soft: #56b4e9;
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(0, 114, 178, 0.16), transparent 45%),
        radial-gradient(circle at 82% 10%, rgba(230, 159, 0, 0.18), transparent 45%),
        linear-gradient(135deg, #f7faff 0%, #f5f8fb 45%, #f8f5ef 100%);
}

body[data-theme="color-blind"] .ball--blue {
    border-color: #0072b2;
    color: #0b3554;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #d7ecfa 48%, #a9d7ef 100%);
}

body[data-theme="color-blind"] .ball--red {
    border-color: #d55e00;
    color: #6b2f00;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #ffdfc2 48%, #f1b27f 100%);
}

body[data-theme="color-blind"] .ball--ivory {
    border-color: #cc79a7;
    color: #5e2b4a;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #f3d3e4 48%, #e0aac8 100%);
}

body[data-theme="color-blind"] .ball--green {
    border-color: #009e73;
    color: #0b503a;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #ccf2e3 48%, #9bdfc7 100%);
}

body[data-theme="color-blind"] .ball--gold {
    border-color: #e69f00;
    color: #6b4b00;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #ffecb8 48%, #f3cf7a 100%);
}

body[data-theme="color-blind"] .color-blue {
    --cell-accent: #0072b2;
    --cell-soft: #d9eefb;
}

body[data-theme="color-blind"] .color-red {
    --cell-accent: #d55e00;
    --cell-soft: #ffe2c8;
}

body[data-theme="color-blind"] .color-ivory {
    --cell-accent: #cc79a7;
    --cell-soft: #f4d6e6;
}

body[data-theme="color-blind"] .color-green {
    --cell-accent: #009e73;
    --cell-soft: #d0f5e7;
}

body[data-theme="color-blind"] .color-gold {
    --cell-accent: #e69f00;
    --cell-soft: #ffefbf;
}

body[data-mode="dark"][data-theme="midnight"] {
    --accent: #38bdf8;
    --accent-dark: #0284c7;
    --accent-soft: #0ea5e9;
    --page-bg:
        radial-gradient(circle at 10% 18%, rgba(56, 189, 248, 0.3), transparent 45%),
        radial-gradient(circle at 85% 12%, rgba(37, 99, 235, 0.32), transparent 45%),
        linear-gradient(135deg, #040b1a 0%, #0b162e 50%, #0f1e2e 100%);
}

body[data-mode="dark"][data-theme="forest"] {
    --accent: #34d399;
    --accent-dark: #16a34a;
    --accent-soft: #6ee7b7;
    --page-bg:
        radial-gradient(circle at 14% 18%, rgba(34, 197, 94, 0.32), transparent 45%),
        radial-gradient(circle at 84% 12%, rgba(15, 118, 110, 0.32), transparent 45%),
        linear-gradient(135deg, #04140e 0%, #0b1f16 50%, #0c2b1c 100%);
}

body[data-mode="dark"][data-theme="sunset"] {
    --accent: #fb923c;
    --accent-dark: #f97316;
    --accent-soft: #fdba74;
    --page-bg:
        radial-gradient(circle at 12% 18%, rgba(251, 146, 60, 0.3), transparent 45%),
        radial-gradient(circle at 82% 10%, rgba(234, 88, 12, 0.26), transparent 45%),
        linear-gradient(135deg, #1b0f06 0%, #23130a 45%, #2a170d 100%);
}

body[data-mode="dark"][data-theme="lagoon"] {
    --accent: #2dd4bf;
    --accent-dark: #0f766e;
    --accent-soft: #5eead4;
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(45, 212, 191, 0.3), transparent 45%),
        radial-gradient(circle at 82% 10%, rgba(20, 184, 166, 0.28), transparent 45%),
        linear-gradient(135deg, #05121a 0%, #071a22 45%, #0b2127 100%);
}

body[data-mode="dark"][data-theme="studio"] {
    --accent: #e2e8f0;
    --accent-dark: #cbd5e1;
    --accent-soft: #94a3b8;
    --border: rgba(148, 163, 184, 0.3);
    --ghost-border: rgba(148, 163, 184, 0.4);
    --stat-bg: rgba(30, 41, 59, 0.85);
    --menu-hover: rgba(148, 163, 184, 0.16);
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(148, 163, 184, 0.16), transparent 45%),
        linear-gradient(135deg, #0b1220 0%, #0f172a 55%, #111827 100%);
}

body[data-mode="dark"][data-theme="mono"] {
    --accent: #f8fafc;
    --accent-dark: #e2e8f0;
    --accent-soft: #94a3b8;
    --shadow: none;
    --border: rgba(148, 163, 184, 0.35);
    --ghost-bg: rgba(15, 23, 42, 0.82);
    --ghost-border: rgba(148, 163, 184, 0.4);
    --stat-bg: rgba(30, 41, 59, 0.85);
    --menu-hover: rgba(148, 163, 184, 0.18);
    --page-bg:
        linear-gradient(135deg, #0b1220 0%, #0f172a 55%, #111827 100%);
    --radius: 10px;
    --radius-sm: 6px;
}

body[data-mode="dark"][data-theme="blueprint"] {
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
    --accent-soft: #38bdf8;
    --border: rgba(96, 165, 250, 0.3);
    --ghost-border: rgba(96, 165, 250, 0.32);
    --stat-bg: rgba(30, 41, 59, 0.9);
    --menu-hover: rgba(96, 165, 250, 0.18);
    --page-bg:
        radial-gradient(circle at 12% 16%, rgba(56, 189, 248, 0.22), transparent 45%),
        linear-gradient(135deg, #071326 0%, #0b1b36 50%, #0f2136 100%);
}

body[data-mode="dark"][data-theme="studio"] .header,
body[data-mode="dark"][data-theme="mono"] .header {
    background: rgba(148, 163, 184, 0.25);
    color: #f8fafc;
}

body[data-mode="dark"][data-theme="studio"] .cell.drawn,
body[data-mode="dark"][data-theme="mono"] .cell.drawn {
    color: #f8fafc;
}

body[data-mode="dark"][data-theme="high-contrast"] {
    --ink: #ffffff;
    --muted: #d1d5db;
    --paper: #000000;
    --panel: #000000;
    --accent: #ffffff;
    --accent-dark: #f8fafc;
    --accent-soft: #e5e7eb;
    --shadow: none;
    --border: #ffffff;
    --stat-bg: #111827;
    --ghost-bg: #000000;
    --ghost-border: #ffffff;
    --reset-bg: #000000;
    --cell-surface: #000000;
    --menu-hover: rgba(255, 255, 255, 0.15);
    --focus-ring: rgba(255, 255, 255, 0.6);
    --pattern-card-bg: #000000;
    --pattern-surface: #000000;
    --pattern-border: #ffffff;
    --pattern-dot: #ffffff;
    --page-bg: #000000;
}

body[data-mode="dark"][data-theme="color-blind"] {
    --page-bg:
        radial-gradient(circle at 10% 18%, rgba(0, 114, 178, 0.3), transparent 45%),
        radial-gradient(circle at 85% 12%, rgba(214, 94, 0, 0.32), transparent 45%),
        linear-gradient(135deg, #0b111b 0%, #101725 45%, #111827 100%);
}

.app {
    min-height: 100vh;
    width: min(1680px, 96vw);
    margin: 0 auto;
    padding: clamp(18px, 2.6vw, 32px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 999px;
    background: var(--ghost-bg);
    border: 1px solid var(--ghost-border);
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-btn--compact {
    padding: 6px 10px;
    font-size: 12px;
}

.toolbar-btn:hover {
    transform: none;
    box-shadow: none;
    background: var(--menu-hover);
}

.btn-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
}

.toolbar-menu {
    position: relative;
}

.toolbar-menu::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 10px;
}

.toolbar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--paper);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 60;
}

.toolbar-dropdown--language {
    max-height: 260px;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.toolbar-menu:hover .toolbar-dropdown,
.toolbar-menu:focus-within .toolbar-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toolbar-menu.is-suppressed .toolbar-dropdown {
    opacity: 0 !important;
    transform: translateY(-6px) !important;
    pointer-events: none !important;
}

.dropdown-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--muted);
    padding: 4px 8px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 6px;
}

.dropdown-title--section {
    padding-top: 2px;
}

.menu-item {
    width: 100%;
    padding: 8px 10px;
    text-align: left;
    font-size: 13px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink);
}

.menu-item:hover,
.menu-item:focus-visible {
    transform: none;
    box-shadow: none;
    background: var(--menu-hover);
}

.menu-item.is-active {
    border-color: var(--border);
    background: var(--menu-hover);
}

.ad-banner {
    padding: 10px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    font-weight: 600;
}

.ad-banner--collapsed {
    padding: 8px 16px;
}

.ad-banner__expanded {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "label close"
        "slot slot";
    align-items: center;
    gap: 12px;
}

.ad-banner__expanded .ad-label {
    grid-area: label;
}

.ad-banner__expanded .ad-slot {
    grid-area: slot;
    width: 100%;
}

.ad-banner__expanded .ad-close {
    grid-area: close;
    justify-self: end;
}

.ad-banner__collapsed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ad-slot {
    min-height: 90px;
    border-radius: 14px;
    border: 1px dashed var(--ghost-border);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(15, 23, 42, 0.08)),
        var(--ghost-bg);
    display: grid;
    place-items: center;
    text-align: center;
    padding: 12px;
}

.ad-slot__text {
    font-size: 14px;
    color: var(--muted);
    letter-spacing: 0.4px;
}

.ad-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
}

.ad-close,
.ad-toggle {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    padding: 0;
    display: grid;
    place-items: center;
    background: var(--ghost-bg);
    border: 1px solid var(--ghost-border);
    color: var(--muted);
}

.ad-toggle svg {
    width: 16px;
    height: 16px;
}

.ad-close:hover,
.ad-close:focus-visible,
.ad-toggle:hover,
.ad-toggle:focus-visible {
    color: var(--ink);
}

.ad-collapsed-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.ad-upgrade {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.ad-upgrade:hover,
.ad-upgrade:focus-visible {
    color: var(--accent-dark);
}

.mode-indicator {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.mode-selector {
    display: inline-flex;
    align-self: flex-end;
    justify-self: end;
}

.audio-panel {
    display: grid;
    gap: 10px;
}

.audio-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0;
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    color: var(--muted);
    position: relative;
    overflow: hidden;
    --toggle-scale: 0.94;
    transform: scale(var(--toggle-scale));
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.audio-toggle .btn-icon {
    width: 26px;
    height: 26px;
    opacity: 0.35;
}

.audio-toggle--compact {
    min-width: 46px;
}

.audio-toggle--off {
    --toggle-scale: 0.94;
}

.audio-toggle--on {
    min-width: 46px;
    color: #fff;
    background: #0b0f14;
    border-color: transparent;
    --toggle-scale: 1.04;
    animation: toggle-pop 0.26s ease-out;
}

.auto-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    font-weight: 600;
    min-width: 70px;
    height: 46px;
    flex: 0 0 auto;
    color: var(--muted);
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    position: relative;
    overflow: hidden;
    --toggle-scale: 0.94;
    transform: scale(var(--toggle-scale));
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.auto-toggle--off {
    border-style: dashed;
    color: rgba(94, 101, 112, 0.55);
    --toggle-scale: 0.94;
}

.auto-toggle--off .btn-icon {
    opacity: 0.45;
    position: relative;
    z-index: 1;
}

.auto-toggle--off .auto-toggle-label {
    opacity: 0.65;
    position: relative;
    z-index: 1;
}

.auto-toggle .btn-icon {
    width: 20px;
    height: 20px;
}

.auto-toggle--on {
    border-color: transparent;
    color: #fff;
    background: #0b0f14;
    box-shadow: none;
    --toggle-scale: 1.04;
    animation: toggle-pop 0.26s ease-out;
}

.audio-toggle:not(:disabled):hover,
.auto-toggle:not(:disabled):hover {
    transform: scale(var(--toggle-scale));
}

.audio-toggle--on .btn-icon {
    width: 26px;
    height: 26px;
    opacity: 1;
}

.audio-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 10px;
    align-items: center;
    width: 100%;
}

.auto-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
}

.auto-label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.auto-label input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.auto-value {
    font-weight: 600;
    color: var(--ink);
    font-size: 16px;
}

.utility-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: center;
}

.audio-label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    width: 100%;
    min-width: 0;
}

.audio-label input[type="range"] {
    width: 100%;
    max-width: 180px;
    accent-color: var(--accent);
}

.audio-label select {
    font-family: var(--font-body);
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--ink);
    width: 100%;
}

.app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 18px 22px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 20;
}

.header-tools {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: flex-end;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.stats {
    justify-self: end;
    align-self: start;
}

.brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 2px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.18);
}

.brand-title {
    font-family: var(--font-display);
    font-size: clamp(20px, 2.2vw, 24px);
    font-weight: 700;
}

.brand-subtitle {
    font-size: 14px;
    color: var(--muted);
}

.brand-meta {
    font-size: 12px;
    color: var(--muted);
}

.brand-meta a {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.brand-meta a:hover,
.brand-meta a:focus-visible {
    color: var(--ink);
}

.stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.stat {
    min-width: 110px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--stat-bg);
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
}

.stat-label--current {
    color: var(--ink);
    font-weight: 700;
}

.stat-value {
    font-family: var(--font-display);
    font-size: clamp(20px, 2.4vw, 24px);
    margin-top: 2px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    flex: 1;
}

.cards-layout {
    display: grid;
    gap: 24px;
    flex: 1;
}

.cards-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cards-hero-content {
    max-width: 600px;
}

.cards-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 3vw, 36px);
    margin: 0;
}

.cards-subtitle {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.6;
}

.cards-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cards-content {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.cards-controls-grid {
    display: grid;
    gap: 12px;
}

.cards-field {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.cards-field select,
.cards-field input[type="number"],
.cards-field input[type="text"] {
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--ink);
}

.cards-toggle {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.cards-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.cards-preview {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.cards-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cards-preview-meta {
    font-size: 12px;
    color: var(--muted);
}

.cards-error {
    font-size: 12px;
    color: var(--accent-dark);
}

.cards-empty {
    font-size: 13px;
    color: var(--muted);
    padding: 12px 0;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.bingo-card {
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    display: grid;
    gap: 10px;
}

.bingo-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.bingo-card__title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ink);
}

.bingo-card__number {
    font-size: 11px;
    color: var(--muted);
}

.bingo-card__grid {
    display: grid;
    grid-template-columns: repeat(var(--card-columns, 5), minmax(0, 1fr));
    gap: 6px;
}

.bingo-card__head {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    text-align: center;
}

.bingo-card__cell {
    min-height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--cell-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
}

.bingo-card__cell.is-free {
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    border-color: transparent;
    color: #fff;
    font-size: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.bingo-card__cell.is-blank {
    background: transparent;
    border-style: dashed;
    color: transparent;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    min-width: 0;
    max-width: 100%;
}

.title {
    font-family: var(--font-display);
    font-size: clamp(24px, 2.6vw, 30px);
    margin: 0;
}

.subtitle {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}

.button-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
}

.draw-btn {
    width: auto;
    min-width: 0;
    justify-self: stretch;
}

.draw-btn--auto {
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}

.draw-btn--running {
    background:
        linear-gradient(90deg, var(--accent), var(--accent-soft)) left /
        calc(var(--auto-progress, 1) * 100%) 100% no-repeat,
        var(--ghost-bg);
    transition: background-size 0.12s linear;
    color: #fff;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
}

button {
    font-family: var(--font-body);
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(17, 24, 39, 0.12);
}

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

.choose-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: #fff;
    font-weight: 700;
    border-color: transparent;
}

.ghost-btn {
    background: var(--ghost-bg);
    border: 1px solid var(--ghost-border);
    color: var(--ink);
}

.reset-btn {
    background: var(--reset-bg);
    color: #fff;
    border-color: transparent;
}

.section-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--muted);
}

.section-card {
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel);
    display: grid;
    gap: 12px;
    width: 100%;
}

.section-card--collapsed {
    padding: 6px 10px;
}

.section-card .section-label {
    color: var(--ink);
    font-weight: 700;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.section-header--collapsed {
    border: 1px solid var(--border);
    background: var(--ghost-bg);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    width: 100%;
}

.section-card .section-header--collapsed {
    border: none;
    background: transparent;
    padding: 0;
}

.section-header--collapsed .section-toggle {
    border-color: transparent;
    background: transparent;
    color: var(--ink);
    padding: 4px 6px;
}

.section-close {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--muted);
    font-size: 12px;
    padding: 0;
    line-height: 1;
}

.section-close:hover {
    transform: none;
    box-shadow: none;
    color: var(--ink);
    background: var(--menu-hover);
}

.section-toggle {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--muted);
    font-size: 12px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.section-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.section-toggle-icon {
    width: 14px;
    height: 14px;
}

.section-toggle:hover {
    transform: none;
    box-shadow: none;
    color: var(--ink);
    background: var(--menu-hover);
}

.icon-btn {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--muted);
    font-size: 12px;
    padding: 0;
}

.icon-btn:hover {
    transform: none;
    box-shadow: none;
    color: var(--ink);
    background: var(--menu-hover);
}

.link-btn {
    border: none;
    background: transparent;
    color: var(--accent);
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
}

.link-btn:hover {
    transform: none;
    box-shadow: none;
    color: var(--accent-dark);
}

.reveal-row {
    display: flex;
    align-items: center;
}

.reveal-btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 999px;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--muted);
}

.reveal-btn:hover {
    transform: none;
    box-shadow: none;
    color: var(--ink);
    background: var(--menu-hover);
}

.current-area,
.recent-area,
.history-area {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.recent-area.section-card {
    gap: 12px;
}

.current-ball {
    display: flex;
    justify-content: center;
}

.current-ball .ball {
    animation: pop 0.35s ease;
}

.recent-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    align-items: center;
    min-height: clamp(64px, 7vw, 80px);
    overflow: visible;
    padding: 4px 2px;
    min-width: 0;
    max-width: 100%;
}

.recent-balls .ball--compact {
    flex: 0 0 auto;
}

.recent-balls--all {
    min-height: 0;
    padding-bottom: 2px;
}

.recent-area--wide {
    display: none;
}

.recent-area--wide .recent-balls {
    flex-wrap: nowrap;
}

.recent-area--wide .recent-balls--all {
    flex-wrap: wrap;
}

.recent-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.recent-toggle {
    font-size: 12px;
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding-right: 4px;
    min-width: 0;
    max-width: 100%;
}

.history-chip {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--cell-accent, #d3d0c5);
    background: var(--cell-soft, #f7f2e8);
    font-size: 14px;
    font-weight: 600;
}

.app-footer {
    display: grid;
    gap: 18px;
    align-items: start;
    padding: 22px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 16px;
    font-size: 14px;
}

.footer-links a,
.footer-links button {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 14px;
}

.footer-links a:hover,
.footer-links a:focus-visible,
.footer-links button:hover,
.footer-links button:focus-visible {
    color: var(--ink);
}

.footer-link.is-primary {
    color: var(--ink);
    font-weight: 700;
}

.footer-link.is-primary:hover,
.footer-link.is-primary:focus-visible {
    color: var(--accent-dark);
}

.footer-meta {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    width: 100%;
}

.footer-credit {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    width: 100%;
}

.footer-credit a {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.footer-credit a:hover,
.footer-credit a:focus-visible {
    color: var(--ink);
}

.ball {
    display: grid;
    place-items: center;
    grid-template-rows: auto auto;
    width: clamp(60px, 7.6vw, 82px);
    height: clamp(60px, 7.6vw, 82px);
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.02;
    border: 4px solid transparent;
    box-shadow:
        inset 0 10px 20px rgba(255, 255, 255, 0.9),
        inset 0 -20px 30px rgba(15, 23, 42, 0.5),
        inset 0 0 0 6px rgba(255, 255, 255, 0.24),
        0 16px 26px rgba(15, 23, 42, 0.26),
        0 8px 14px rgba(15, 23, 42, 0.18);
}

.ball::before {
    content: "";
    position: absolute;
    inset: 7%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        inset 0 0 20px rgba(255, 255, 255, 0.65),
        inset 0 -10px 18px rgba(15, 23, 42, 0.28);
    opacity: 0.98;
}

.ball::after {
    content: "";
    position: absolute;
    top: 5%;
    left: 10%;
    width: 50%;
    height: 50%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.5) 42%, rgba(255, 255, 255, 0) 70%);
    opacity: 0.9;
}

.ball strong {
    font-size: clamp(22px, 3.6vw, 28px);
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(15, 23, 42, 0.35);
}

.ball em {
    font-style: normal;
    font-size: clamp(20px, 3.1vw, 26px);
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(15, 23, 42, 0.35);
}

.ball--number-only {
    grid-template-rows: 1fr;
}

.ball--number-only em {
    font-size: clamp(22px, 4vw, 30px);
}

.ball--hero {
    width: clamp(96px, 14vw, 148px);
    height: clamp(96px, 14vw, 148px);
}

.ball--hero strong {
    font-size: clamp(34px, 5.8vw, 46px);
}

.ball--hero em {
    font-size: clamp(26px, 4.6vw, 36px);
}

.ball--compact {
    width: clamp(56px, 7vw, 72px);
    height: clamp(56px, 7vw, 72px);
}

.ball--compact strong {
    font-size: clamp(20px, 3.2vw, 24px);
}

.ball--compact em {
    font-size: clamp(18px, 2.8vw, 22px);
}

.ball--compact.ball--number-only em {
    font-size: clamp(20px, 3.1vw, 24px);
}

.ball--blue {
    border-color: #1f5be3;
    color: #0f2a66;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #d4e2ff 48%, #a8c4f5 100%);
}

.ball--red {
    border-color: #e04222;
    color: #7c2411;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #ffd2c4 48%, #f6a38f 100%);
}

.ball--ivory {
    border-color: #8b6b5a;
    color: #4a3326;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #f1dfcf 48%, #d7bca6 100%);
}

.ball--green {
    border-color: #219a57;
    color: #0f4f2b;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #d2f1df 48%, #9bd9b7 100%);
}

.ball--gold {
    border-color: #d59a00;
    color: #7b5600;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #ffe1a6 48%, #f7c269 100%);
}

.ball--neutral {
    border-color: #9ca3af;
    color: #1f2937;
    background: radial-gradient(circle at 28% 28%, #ffffff 0%, #e4e7ec 48%, #c9d1dc 100%);
}

.board-panel {
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    display: grid;
    gap: 14px;
}

.board {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(16, minmax(0, 1fr));
    grid-auto-flow: column;
    gap: 4px;
    min-height: clamp(420px, 55vh, 560px);
}

.board--numeric {
    grid-template-columns: repeat(var(--board-columns, 10), minmax(0, 1fr));
    grid-template-rows: repeat(var(--board-rows, 10), auto);
    grid-auto-flow: row;
    align-content: start;
}

.header {
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: clamp(22px, 2.8vw, 28px);
    border-radius: 12px;
    border: none;
    background: var(--cell-accent, #1f5be3);
    color: #fff;
    letter-spacing: 2px;
    text-transform: uppercase;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.cell {
    display: grid;
    place-items: center;
    min-height: 40px;
    border-radius: 10px;
    border: 1px solid var(--cell-accent, #c5ccd6);
    background: var(--cell-surface);
    font-weight: 600;
    font-size: clamp(20px, 3.3vw, 28px);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.board--numeric .cell {
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 1 / 1;
}

.cell.drawn {
    background: var(--cell-accent, #1f5be3);
    color: #fff;
    border-color: var(--cell-accent, #1f5be3);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.cell.current {
    transform: scale(1.02);
    box-shadow: 0 0 0 2px var(--cell-accent, #d3d0c5), 0 10px 16px rgba(15, 23, 42, 0.18);
    animation: blink 1.8s ease-in-out infinite;
}

.color-blue {
    --cell-accent: #1f5be3;
    --cell-soft: #e3ecff;
}

.color-red {
    --cell-accent: #e04222;
    --cell-soft: #ffe4db;
}

.color-ivory {
    --cell-accent: #8b6b5a;
    --cell-soft: #f4ebe1;
}

.color-green {
    --cell-accent: #219a57;
    --cell-soft: #def7e8;
}

.color-gold {
    --cell-accent: #d59a00;
    --cell-soft: #fff0c2;
}

.pattern-card {
    padding: 16px;
    width: min(100%, 420px);
    justify-self: center;
}

.win-condition-card {
    width: min(100%, 420px);
    justify-self: center;
}

.win-condition-body {
    display: grid;
    gap: 12px;
}

.win-condition-field {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.win-condition-field select,
.win-condition-field input[type="text"] {
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--ink);
}

.section-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.toolbar-dropdown--pattern {
    min-width: 260px;
}

.menu-item--pattern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pattern-option-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
}

.pattern-mini {
    display: grid;
    grid-template-columns: repeat(5, 6px);
    gap: 2px;
}

.pattern-mini-cell {
    width: 6px;
    height: 6px;
    border-radius: 2px;
    border: 1px solid var(--pattern-border);
    background: var(--pattern-surface);
}

.pattern-mini-cell.is-active {
    background: var(--pattern-dot);
    border-color: var(--pattern-dot);
}

.pattern-mini-cell.is-free {
    background: transparent;
    border-style: dashed;
}

.pattern-clear {
    font-size: 12px;
}

.pattern-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
    justify-items: center;
    width: 100%;
}

.pattern-head {
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    border-radius: 0;
    background: transparent;
    border: none;
    color: var(--pattern-dot);
    letter-spacing: 2px;
    height: auto;
    padding-bottom: 4px;
}

.pattern-cell {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    border-radius: 10px;
    background: var(--pattern-surface);
    border: 1px solid var(--pattern-border);
    padding: 0;
}

.pattern-cell.is-free {
    border-style: dashed;
}

.pattern-cell:hover {
    transform: none;
    box-shadow: none;
    border-color: rgba(17, 24, 39, 0.4);
}

.pattern-dot {
    width: 30%;
    height: 30%;
    min-width: 14px;
    min-height: 14px;
    border-radius: 999px;
    background: var(--pattern-dot);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.pattern-cell.is-active .pattern-dot {
    opacity: 1;
}

.pattern-free {
    position: absolute;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--pattern-dot);
}

.pattern-collapsed {
    display: flex;
}

.board-secondary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    width: 100%;
}

.pattern-stack,
.history-stack {
    display: grid;
    gap: 12px;
}

.pattern-stack {
    justify-items: center;
    margin-top: 16px;
}

.history-area {
    width: 100%;
}

.game-history {
    display: grid;
    gap: 12px;
    width: 100%;
}

.game-history-body {
    display: grid;
    gap: 12px;
}

.game-history-list {
    display: grid;
    gap: 12px;
}

.game-item {
    display: grid;
    gap: 6px;
}

.game-current-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--accent);
}

.game-card {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--pattern-card-bg);
    display: grid;
    gap: 10px;
}

.game-card--current {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(14, 116, 144, 0.08));
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

.game-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.game-header-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.game-header-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.game-header-actions .link-btn {
    white-space: nowrap;
}

.winner-btn {
    display: inline-flex;
    align-items: center;
    max-width: 200px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-mode {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
}

.game-meta {
    font-size: 12px;
    color: var(--ink);
    opacity: 0.85;
}

.game-load {
    font-size: 12px;
}

.game-info {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
}

.game-stat {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.game-detail {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.game-winner {
    display: grid;
    gap: 4px;
    font-size: 13px;
    color: var(--ink);
}

.game-winner span {
    opacity: 0.85;
}

.game-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

.game-actions-left {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.history-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.pagination-meta {
    font-size: 12px;
    color: var(--muted);
}

.game-actions .ghost-btn {
    padding: 6px 10px;
    font-size: 12px;
}

.remove-btn {
    font-size: 12px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.remove-btn:hover,
.remove-btn:focus-visible {
    color: var(--ink);
}

.game-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    opacity: 0.65;
}

.game-enter-active,
.game-leave-active {
    transition: opacity 0.12s ease;
}

.game-enter-from,
.game-leave-to {
    opacity: 0;
}

.notes-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.notes-icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

.history-hint {
    display: block;
    font-size: 14px;
    color: var(--ink);
    opacity: 0.85;
    text-align: center;
    width: 100%;
}

.history-hint-text {
    display: inline;
    font-weight: 500;
}

.history-login {
    font-size: 14px;
    display: inline;
    margin-right: 4px;
}

.remove-icon {
    width: 12px;
    height: 12px;
}

.auth-panel {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: grid;
    gap: 10px;
}

.auth-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--ink);
    font-weight: 700;
}

.auth-row {
    display: grid;
    gap: 8px;
}

.auth-label {
    display: grid;
    gap: 4px;
    font-size: 12px;
    color: var(--ink);
    opacity: 0.75;
}

.auth-label input {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--ink);
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.auth-actions .ghost-btn {
    padding: 8px 12px;
    font-size: 12px;
}

.auth-google {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    width: 100%;
    text-align: center;
}

.auth-google img {
    width: 18px;
    height: 18px;
}

.auth-status {
    font-size: 12px;
    color: var(--ink);
    opacity: 0.7;
}

.auth-user {
    font-size: 12px;
    color: var(--ink);
    opacity: 0.75;
}

.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 25, 0.45);
    display: grid;
    place-items: start center;
    padding: 80px 20px;
    z-index: 200;
}

.auth-modal__panel {
    width: min(440px, 92vw);
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
    display: grid;
    gap: 12px;
    max-height: calc(100vh - 140px);
    overflow: auto;
    animation: modal-in 0.2s ease;
}

.auth-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.auth-modal__title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}

.dialog-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 25, 0.45);
    display: grid;
    place-items: start center;
    padding: 80px 20px;
    z-index: 210;
}

.dialog-modal__panel {
    width: min(420px, 92vw);
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
    display: grid;
    gap: 12px;
    animation: modal-in 0.2s ease;
}

.dialog-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.dialog-modal__header--no-title {
    justify-content: flex-end;
}

.dialog-modal__title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

.dialog-modal__message {
    font-size: 14px;
    color: var(--ink);
    opacity: 0.8;
}

.dialog-inline-link {
    padding: 0;
    font-size: 14px;
    line-height: 1.4;
    display: inline;
}

.dialog-modal .section-close {
    border-color: var(--accent);
    color: var(--ink);
    background: var(--ghost-bg);
    font-weight: 700;
}

.dialog-modal__input {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--ink);
    width: 100%;
}

.dialog-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.dialog-modal__actions .link-btn {
    margin-right: auto;
}

.notes-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 25, 0.45);
    display: grid;
    place-items: start center;
    padding: 80px 20px;
    z-index: 215;
}

.notes-modal__panel {
    width: min(560px, 94vw);
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
    display: grid;
    gap: 12px;
    animation: modal-in 0.2s ease;
}

.notes-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.notes-modal__title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

.notes-modal__input {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    color: var(--ink);
    width: 100%;
    min-height: 180px;
    resize: vertical;
}

.notes-modal__meta {
    font-size: 12px;
    color: var(--muted);
    text-align: right;
}

.notes-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.calls-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 25, 0.45);
    display: grid;
    place-items: start center;
    padding: 80px 20px;
    z-index: 212;
}

.calls-modal__panel {
    width: min(680px, 94vw);
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
    display: grid;
    gap: 12px;
    max-height: calc(100vh - 140px);
    overflow: hidden;
    animation: modal-in 0.2s ease;
}

.calls-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.calls-modal__title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

.calls-list {
    display: grid;
    gap: 10px;
    overflow: auto;
    max-height: min(55vh, 520px);
    padding-right: 4px;
}

.calls-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.calls-item {
    display: grid;
    grid-template-columns: 34px auto;
    align-items: center;
    gap: 12px;
}

.calls-index {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--ghost-border);
    background: var(--ghost-bg);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.winner-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 25, 0.45);
    display: grid;
    place-items: start center;
    padding: 80px 20px;
    z-index: 214;
}

.winner-modal__panel {
    width: min(420px, 92vw);
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
    display: grid;
    gap: 12px;
    animation: modal-in 0.2s ease;
}

.winner-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.winner-modal__title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

.winner-modal__name {
    font-family: var(--font-display);
    font-size: clamp(18px, 2.2vw, 22px);
    font-weight: 700;
    color: var(--ink);
    text-align: center;
    word-break: break-word;
}

.winner-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.info-panel {
    padding: 20px 22px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    display: grid;
    gap: 12px;
}

.info-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(20px, 2vw, 24px);
}

.info-intro,
.info-outro {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.6;
}

.info-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
    font-size: 14px;
    color: var(--ink);
    line-height: 1.5;
}

.app-header,
.controls,
.board-panel,
.info-panel,
.app-footer {
    animation: lift-in 0.6s ease both;
}

.controls {
    animation-delay: 0.05s;
}

.board-panel {
    animation-delay: 0.1s;
}

.app-footer {
    animation-delay: 0.15s;
}

.live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.recent-enter-active,
.recent-leave-active {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.recent-leave-active {
    position: absolute;
}

.recent-move {
    transition: transform 0.2s ease;
}

.recent-enter-from,
.recent-leave-to {
    transform: translateY(6px);
    opacity: 0;
}

body[data-mode="dark"] .color-blue {
    --cell-soft: rgba(59, 130, 246, 0.24);
}

body[data-mode="dark"] .color-red {
    --cell-soft: rgba(248, 113, 113, 0.22);
}

body[data-mode="dark"] .color-ivory {
    --cell-soft: rgba(148, 122, 104, 0.28);
}

body[data-mode="dark"] .color-green {
    --cell-soft: rgba(34, 197, 94, 0.22);
}

body[data-mode="dark"] .color-gold {
    --cell-soft: rgba(250, 204, 21, 0.22);
}

@keyframes pop {
    0% {
        transform: scale(0.94);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes toggle-pop {
    0% {
        transform: scale(0.94);
    }
    65% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1.04);
    }
}

@keyframes lift-in {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.02);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes modal-in {
    0% {
        opacity: 0;
        transform: translateY(-6px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .ad-banner,
    .app-header,
    .cards-hero,
    .cards-controls,
    .app-footer {
        display: none !important;
    }

    .app {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .cards-layout {
        gap: 12px;
    }

    .bingo-card {
        box-shadow: none;
        background: #ffffff;
        border-color: #000000;
        page-break-inside: avoid;
    }

    .bingo-card__cell {
        border-color: #000000;
    }
}

@media (min-width: 1280px) {
    .app {
        width: min(1800px, 96vw);
    }

    .layout {
        grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    }

    .board {
        grid-template-columns: 88px repeat(15, minmax(0, 1fr));
        grid-template-rows: repeat(5, minmax(0, 1fr));
        grid-auto-flow: row;
        min-height: 360px;
    }

    .board--numeric {
        grid-template-columns: repeat(var(--board-columns, 10), minmax(0, 1fr));
        grid-template-rows: repeat(var(--board-rows, 10), auto);
        grid-auto-flow: row;
        min-height: clamp(420px, 55vh, 560px);
    }

    .cell {
        min-height: 40px;
    }
}

@media (min-width: 1101px) {
    .recent-area--wide {
        display: grid;
    }

    .recent-area--narrow {
        display: none;
    }
}

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .cards-content {
        grid-template-columns: 1fr;
    }

    .board {
        min-height: 420px;
    }

    .board-secondary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .app {
        padding: 18px;
    }

    .toolbar-actions {
        width: 100%;
    }

    .toolbar-dropdown {
        right: auto;
        left: 0;
    }

    .audio-controls {
        width: 100%;
    }

    .audio-label {
        width: 100%;
    }

    .app-header {
        grid-template-columns: 1fr;
    }

    .header-tools {
        width: 100%;
        justify-self: start;
        justify-content: flex-start;
    }

    .brand {
        justify-self: start;
    }

    .stats {
        justify-self: start;
    }

    .ad-banner__expanded {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "label close"
            "slot slot";
    }

    .ad-banner__expanded .ad-label {
        grid-area: label;
    }

    .ad-banner__expanded .ad-slot {
        grid-area: slot;
        min-height: 160px;
    }

    .ad-banner__expanded .ad-close {
        grid-area: close;
        justify-self: end;
    }

    .ad-banner__collapsed {
        flex-direction: column;
        align-items: flex-start;
    }

    .ad-collapsed-actions {
        width: 100%;
        justify-content: space-between;
    }

    .button-row {
        gap: 8px;
    }

    .draw-btn {
        font-size: 15px;
        padding: 10px 12px;
    }

    .audio-toggle {
        width: 42px;
        height: 42px;
        padding: 0;
    }

    .auto-toggle {
        height: 42px;
        padding: 0 10px;
    }

    .board-panel {
        padding: 12px;
    }

    .board {
        gap: 4px;
    }

    .app-footer {
        grid-template-columns: 1fr;
    }

    .auth-modal {
        padding-top: 60px;
    }

    .dialog-modal {
        padding-top: 60px;
    }

    .notes-modal {
        padding-top: 60px;
    }

    .calls-modal {
        padding-top: 60px;
    }

    .winner-modal {
        padding-top: 60px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
