/* ============================================================
   Block Blast Solver - Web App Stylesheet
   Production build | SPA with screen-based navigation
   ============================================================ */

/* ------------------------------------------------------------
   0. FONT FACES
   ------------------------------------------------------------ */

@font-face {
    font-family: 'Montserrat';
    src: url('fonts/Montserrat-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Poppins';
    src: url('fonts/Poppins-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Poppins';
    src: url('fonts/Poppins-Medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Poppins';
    src: url('fonts/Poppins-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Poppins';
    src: url('fonts/Poppins-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Poppins';
    src: url('fonts/Poppins-ExtraBold.ttf') format('truetype');
    font-weight: 800;
    font-display: swap;
    font-style: normal;
}


/* ------------------------------------------------------------
   1. DESIGN TOKENS (CSS Custom Properties)
   ------------------------------------------------------------ */

:root {
    /* Brand colors */
    --primary: #545CF7;
    --primary-dark: #3B3F8C;
    --primary-hover: #4048D6;

    /* Text hierarchy */
    --text-dark: #151C4D;
    --text-secondary: #828489;
    --text-tertiary: #333333;

    /* Surfaces */
    --empty-cell: #EBEEFF;
    --bg-start: #EAECF8;
    --bg-end: #FFFFFF;
    --card-bg: #FFFFFF;
    --card-shadow: 0 2px 12px rgba(84, 92, 247, 0.11);

    /* Button palette */
    --btn-secondary: #E3E3E3;
    --btn-secondary-hover: #D5D5D5;
    --btn-tertiary: #E8EAEE;
    --btn-tertiary-hover: #DCDEE3;

    /* Accent / status */
    --warning: #F3BE4C;
    --warning-bg: rgba(243, 190, 76, 0.15);
    --success: #34C759;
    --error: #FF3B30;

    /* Cell gradients */
    --filled-start: #3B3F8C;
    --filled-end: #545CF7;
    --new-start: #FF7620;
    --new-end: #FF9A53;

    /* Radii */
    --radius-xs: 3px;
    --radius-sm: 4px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Typography */
    --font-heading: 'Montserrat', system-ui, -apple-system, sans-serif;
    --font-body: 'Poppins', system-ui, -apple-system, sans-serif;

    /* Z-index layers */
    --z-base: 1;
    --z-nav: 100;
    --z-overlay: 200;
    --z-toast: 500;
    --z-modal: 600;

    /* Transitions */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 350ms;

    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 40px;
    --space-5xl: 48px;

    /* Safe areas (overridden by env() on notched devices) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}


/* ------------------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------------------ */

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-dark);
    background: linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 30%);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

ul, ol {
    list-style: none;
}

/* Screen reader only */
.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;
}


/* ------------------------------------------------------------
   3. TYPOGRAPHY
   ------------------------------------------------------------ */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: 1.2;
    color: var(--text-dark);
}

h1 {
    font-size: 28px;
    font-weight: 800;
}

h2 {
    font-size: 20px;
    font-weight: 700;
}

h3 {
    font-size: 17px;
    font-weight: 600;
}

h4 {
    font-size: 15px;
    font-weight: 600;
}

.text-secondary {
    color: var(--text-secondary);
}

.text-tertiary {
    color: var(--text-tertiary);
}

.text-primary {
    color: var(--primary);
}

.text-center {
    text-align: center;
}

.text-small {
    font-size: 13px;
}

.text-caption {
    font-size: 12px;
    color: var(--text-secondary);
}


/* ------------------------------------------------------------
   4. LAYOUT CONTAINERS
   ------------------------------------------------------------ */

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
}

.tool-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
}

.content-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
}

.screen-body {
    flex: 1;
    padding: var(--space-lg) var(--space-xl);
    padding-bottom: calc(var(--space-4xl) + var(--safe-bottom));
    overflow-y: auto;
}

.screen-body.centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}


/* ------------------------------------------------------------
   5. SCREEN MANAGEMENT (SPA Navigation)
   ------------------------------------------------------------ */

.screen {
    display: none;
    opacity: 0;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
}

.screen.active {
    display: flex;
    opacity: 1;
    animation: screenFadeIn var(--duration-normal) var(--ease-out) forwards;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide-in from right (push navigation) */
.screen.slide-in {
    animation: screenSlideIn var(--duration-slow) var(--ease-out) forwards;
}

@keyframes screenSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide-in from left (pop / back navigation) */
.screen.slide-back {
    animation: screenSlideBack var(--duration-slow) var(--ease-out) forwards;
}

@keyframes screenSlideBack {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* ------------------------------------------------------------
   6. NAVIGATION BAR
   ------------------------------------------------------------ */

.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 var(--space-lg);
    padding-top: var(--safe-top);
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.nav-bar-title,
.nav-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    text-align: center;
    margin: 0;
}

.nav-bar-left,
.nav-bar-right,
.nav-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    z-index: 1;
}

.nav-back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-sm);
    margin-left: calc(-1 * var(--space-sm));
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-out);
}

.nav-back-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.nav-back-btn img {
    width: 24px;
    height: 24px;
}

.nav-back-btn span {
    font-size: 15px;
    font-weight: 500;
    color: var(--primary);
}

.nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-out);
}

.nav-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.nav-icon-btn img {
    width: 24px;
    height: 24px;
}

/* Hide text in nav-bar icon buttons (only show in home-nav) */
.nav-bar .nav-icon-btn span {
    display: none;
}

.nav-right .nav-icon-btn {
    width: auto;
    gap: var(--space-xs);
    padding: 0 var(--space-sm);
}

/* Solve page column-style nav buttons */
.solve-nav {
    height: auto;
    padding-top: calc(var(--safe-top) + var(--space-md));
    padding-bottom: var(--space-md);
    align-items: flex-start;
}

.solve-nav .nav-title {
    font-size: 20px;
    top: calc(var(--safe-top) + var(--space-md) + 4px);
}

.nav-col-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    background: none;
    border: none;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
    z-index: 1;
}

.nav-col-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.nav-col-btn img {
    width: 28px;
    height: 28px;
}

.nav-col-btn span {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 600;
    color: #000000;
    text-align: center;
}


/* ------------------------------------------------------------
   7. HOME SCREEN
   ------------------------------------------------------------ */

.home-screen {
    background: linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 60%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-3xl) var(--space-xl);
    text-align: center;
    position: relative;
}

/* Home nav (top icon buttons) */
.home-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: calc(var(--safe-top) + var(--space-xl)) var(--space-xl) 0;
}

.home-nav-left,
.home-nav-right {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.home-nav .nav-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: auto;
    height: auto;
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-out);
}

.home-nav .nav-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.home-nav .nav-icon-btn img {
    width: 28px;
    height: 28px;
}

.home-nav .nav-icon-btn span {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 600;
    color: #000000;
    display: block;
    text-align: center;
}

/* Home logo area */
.home-logo {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.app-logo {
    width: 120px;
    height: 120px;
    border-radius: 21px;
    border: 3px solid transparent;
    background-clip: padding-box;
    box-shadow: 0 0 0 3px rgba(245, 246, 252, 0.6);
    margin: 0 auto var(--space-xl);
}

.app-title {
    font-family: var(--font-heading);
    font-size: 46px;
    font-weight: 800;
    color: #000000;
    line-height: 1.22;
    margin: 0;
}

.home-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
}

.home-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: var(--space-4xl);
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.home-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 303px;
}

/* Home-specific button styles */
.btn-home-primary,
.btn-home-gray,
.btn-home-outline {
    width: 100%;
    height: auto;
    padding: 9px 0;
    border-radius: 16px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 20px;
    line-height: 1.22;
    gap: 6px;
}

.btn-home-primary img,
.btn-home-gray img,
.btn-home-outline img {
    width: 32px;
    height: 32px;
}

.btn-home-primary {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: inset 0 -2px 4px rgba(255, 255, 255, 0.25);
}

.btn-home-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-home-primary:active:not(:disabled) {
    background: var(--primary-dark);
}

.btn-home-gray {
    background: #E3E3E3;
    color: var(--text-dark);
}

.btn-home-gray:hover:not(:disabled) {
    background: #D5D5D5;
}

/* App Store badge */
.appstore-badge {
    display: inline-block;
    margin-top: var(--space-4xl);
    transition: opacity var(--duration-fast) var(--ease-out);
}

.appstore-badge:hover {
    opacity: 0.8;
}

.appstore-badge img {
    width: 133px;
    height: 44px;
}

/* App Store badge inside tool-container (solve page) */
.tool-container .appstore-badge {
    display: flex;
    justify-content: center;
    margin-top: var(--space-xl);
}

.home-action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    width: 100%;
    padding: var(--space-lg) var(--space-xl);
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    transition: transform var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
    text-align: left;
}

.home-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(84, 92, 247, 0.16);
}

.home-action-btn:active {
    transform: scale(0.98);
}

.home-action-btn img {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.home-action-btn .action-text h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.home-action-btn .action-text p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Home bottom nav icons */
.home-nav-icons {
    display: flex;
    justify-content: center;
    gap: var(--space-3xl);
    margin-top: var(--space-5xl);
}

.home-nav-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    transition: opacity var(--duration-fast) var(--ease-out);
}

.home-nav-icon:hover {
    opacity: 0.7;
}

.home-nav-icon img {
    width: 28px;
    height: 28px;
    opacity: 0.6;
}

.home-nav-icon span {
    font-size: 11px;
    color: var(--text-secondary);
}

/* SEO content (below fold on home screen) */
.seo-content {
    text-align: left;
    max-width: 800px;
    margin: var(--space-5xl) auto 0;
    padding: 0 var(--space-xl);
}

.content-section {
    margin-bottom: var(--space-5xl);
}

.content-section h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-md);
    border-bottom: 3px solid var(--primary);
    display: inline-block;
}

.content-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
    margin-top: var(--space-xl);
}

.content-section p,
.content-section li {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.content-section ul {
    list-style: disc;
    padding-left: var(--space-2xl);
}

.content-section ul li {
    margin-bottom: var(--space-sm);
    padding-left: var(--space-sm);
}

.steps-list {
    padding-left: 0;
    list-style: none;
    counter-reset: steps;
}

.steps-list li {
    margin-bottom: var(--space-xl);
    padding-left: 44px;
    position: relative;
    counter-increment: steps;
}

.steps-list li::before {
    content: counter(steps);
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary) 0%, #6C63FF 100%);
    color: #FFFFFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.score-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: var(--space-lg) 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(84, 92, 247, 0.08);
}

.score-table th,
.score-table td {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-size: 14px;
}

.score-table th {
    font-weight: 600;
    color: #FFFFFF;
    background: linear-gradient(135deg, var(--primary) 0%, #6C63FF 100%);
}

.score-table td {
    color: var(--text-secondary);
    border-bottom: 1px solid #F0F0F5;
}

.score-table tr:last-child td {
    border-bottom: none;
}

.score-table tbody tr {
    transition: background var(--duration-fast) var(--ease-out);
}

.score-table tbody tr:hover {
    background: rgba(84, 92, 247, 0.04);
}

.score-table tbody tr:last-child td:first-child {
    font-weight: 600;
    color: var(--primary);
}

.faq-item {
    margin-bottom: var(--space-lg);
    padding: var(--space-xl);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 4px rgba(84, 92, 247, 0.06);
    border: 1px solid rgba(84, 92, 247, 0.06);
    transition: box-shadow var(--duration-fast) var(--ease-out);
}

.faq-item:hover {
    box-shadow: 0 2px 12px rgba(84, 92, 247, 0.1);
}

.faq-item:last-child {
    margin-bottom: 0;
}

.faq-item h3 {
    margin-top: 0;
}

.site-footer {
    text-align: center;
    padding: var(--space-4xl) var(--space-xl) var(--space-3xl);
    border-top: 1px solid #F0F0F5;
    margin-top: var(--space-4xl);
}

.site-footer p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
}

.footer-links a {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease-out);
}

.footer-links a:hover {
    text-decoration: none;
    background: rgba(84, 92, 247, 0.06);
}


/* ------------------------------------------------------------
   8. CARDS (Shared)
   ------------------------------------------------------------ */

.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    padding: var(--space-2xl);
}

.card + .card {
    margin-top: var(--space-lg);
}


/* ------------------------------------------------------------
   9. BUTTONS
   ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 16px;
    height: 56px;
    border: none;
    border-radius: var(--radius-lg);
    padding: 0 var(--space-2xl);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out),
                opacity var(--duration-fast) var(--ease-out);
    user-select: none;
    -webkit-user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Primary (flat purple — matches Figma solve button) */
.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
    font-size: 20px;
    box-shadow: inset 0 -2px 4px rgba(255, 255, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
    background: var(--primary-dark);
}

/* Outline (bordered) */
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(84, 92, 247, 0.06);
}

.btn-outline:active:not(:disabled) {
    background: rgba(84, 92, 247, 0.12);
}

/* Gray (secondary with subtle border) */
.btn-gray {
    background: rgba(84, 92, 247, 0.04);
    color: var(--text-dark);
    border: 1.5px solid rgba(84, 92, 247, 0.18);
}

.btn-gray:hover:not(:disabled) {
    background: rgba(84, 92, 247, 0.08);
    border-color: rgba(84, 92, 247, 0.3);
}

/* Tertiary (lighter gray) */
.btn-tertiary {
    background: var(--btn-tertiary);
    color: var(--text-tertiary);
}

.btn-tertiary:hover:not(:disabled) {
    background: var(--btn-tertiary-hover);
}

/* Button sizes */
.btn-sm {
    height: 40px;
    font-size: 14px;
    padding: 0 var(--space-lg);
    border-radius: var(--radius-md);
}

.btn-lg {
    height: 60px;
    font-size: 17px;
    padding: 0 var(--space-3xl);
}

/* Full-width button */
.btn-full {
    width: 100%;
    max-width: 303px;
    margin-left: auto;
    margin-right: auto;
}

/* Large button */
.btn-large {
    height: 60px;
    font-size: 17px;
    padding: 0 var(--space-3xl);
}

/* Pill shape */
.btn-pill {
    border-radius: var(--radius-full);
    padding: 0 var(--space-xl);
    height: 40px;
    font-size: 14px;
}

/* Button with icon */
.btn {
    gap: var(--space-sm);
}

.btn img {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

/* Full-width button row */
.btn-row {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-2xl);
}

.btn-row .btn {
    flex: 1;
}

/* Stacked buttons */
.btn-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-2xl);
}

.btn-stack .btn {
    width: 100%;
}


/* ------------------------------------------------------------
   10. SECTION LABELS
   ------------------------------------------------------------ */

.section-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--space-md);
}

.section-label h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 0;
}

.section-label span {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.6);
}


/* ------------------------------------------------------------
   11. GRID EDITOR (8x8 Board)
   ------------------------------------------------------------ */

.grid-editor {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    aspect-ratio: 1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.grid-editor .cell {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background-color: var(--empty-cell);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: transform 0.1s var(--ease-out);
    outline: none;
    border: none;
}

.grid-editor .cell:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    z-index: var(--z-base);
}

.grid-editor .cell.filled {
    background-color: transparent;
    background-image: url('assets/icon_block_placed.png');
    background-size: cover;
}

.grid-editor .cell:active {
    transform: scale(0.92);
}


/* ------------------------------------------------------------
   12. FIGURE EDITORS (5x5 Block Shape)
   ------------------------------------------------------------ */

.figures-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.figure-editor {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    aspect-ratio: 1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.figure-editor .cell {
    aspect-ratio: 1;
    border-radius: var(--radius-xs);
    background-color: var(--empty-cell);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: transform 0.1s var(--ease-out);
    outline: none;
    border: none;
}

.figure-editor .cell:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    z-index: var(--z-base);
}

.figure-editor .cell.filled {
    background-color: transparent;
    background-image: url('assets/icon_block_ready.png');
    background-size: cover;
}

.figure-editor .cell:active {
    transform: scale(0.88);
}


/* ------------------------------------------------------------
   13. RECOGNITION SCREEN
   ------------------------------------------------------------ */



/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--empty-cell);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}



/* ------------------------------------------------------------
   14. MANUAL INPUT SCREEN
   ------------------------------------------------------------ */

#screen-manual {
    background: linear-gradient(180deg, var(--bg-start) 0%, #FFFFFF 20%, #FFFFFF 100%);
}


/* ------------------------------------------------------------
   15. RESULTS SCREEN
   ------------------------------------------------------------ */


/* Stats card with decorative background */
.stats-card {
    position: relative;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: var(--space-2xl) var(--space-lg);
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('assets/bg_solver_stats.png');
    background-size: cover;
    background-position: center;
    opacity: 0.12;
    pointer-events: none;
}

.stat {
    text-align: center;
    position: relative;
    z-index: var(--z-base);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: rgba(84, 92, 247, 0.15);
}

/* Step cards */
.step-card {
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.step-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.step-number {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-dark);
}

.step-score {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: var(--empty-cell);
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.step-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}

.step-content {
    display: flex;
    gap: var(--space-lg);
    align-items: flex-start;
}

/* Figure preview (mini block shape in step card) */
.figure-preview {
    display: inline-grid;
    gap: 2px;
    flex-shrink: 0;
}

.fp-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--empty-cell);
}

.fp-cell.filled {
    background: linear-gradient(135deg, var(--new-start), var(--new-end));
}

/* Step grid (8x8 result display) */
.step-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

.step-cell {
    aspect-ratio: 1;
    border-radius: var(--radius-xs);
    background: var(--empty-cell);
    transition: background var(--duration-fast) var(--ease-out);
}

.step-cell.filled {
    background: linear-gradient(135deg, var(--filled-start), var(--filled-end));
}

.step-cell.new {
    background: linear-gradient(135deg, var(--new-start), var(--new-end));
    animation: cellPop 0.3s var(--ease-spring);
}

.step-cell.cleared {
    position: relative;
    animation: cellClear 0.4s var(--ease-out) forwards;
}

.step-cell.cleared::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.25);
}

@keyframes cellPop {
    0% { transform: scale(0.6); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes cellClear {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 0.3; }
}

/* No solution */
.no-solution {
    text-align: center;
    padding: var(--space-4xl) var(--space-xl);
}

.no-solution h3 {
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
}

.no-solution p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Results bottom actions */
.results-bottom-actions {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    padding: var(--space-lg) var(--space-xl);
    padding-bottom: calc(var(--space-lg) + var(--safe-bottom));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 20%, #FFFFFF 40%);
    z-index: var(--z-overlay);
    display: flex;
    gap: var(--space-md);
}


/* ------------------------------------------------------------
   16. LOADING OVERLAY
   ------------------------------------------------------------ */

.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-5xl) 0;
}

.loading-overlay[hidden] {
    display: none;
}

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Full-screen loading state */
.loading-fullscreen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
    min-height: 300px;
}




/* ------------------------------------------------------------
   18. SETTINGS SCREEN
   ------------------------------------------------------------ */


/* Settings card (group) */
.settings-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.settings-card + .settings-card {
    margin-top: var(--space-xl);
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-xl) var(--space-xl) var(--space-lg);
}

.settings-card-header img {
    width: 28px;
    height: 28px;
}

.settings-card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

/* Form actions row */
.actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Settings row */
.settings-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    min-height: 52px;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}

.settings-row:hover {
    background: rgba(0, 0, 0, 0.02);
}

.settings-row:active {
    background: rgba(0, 0, 0, 0.04);
}

.settings-row img {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.settings-row .settings-row-label {
    flex: 1;
    font-size: 15px;
    color: var(--text-dark);
}

.settings-row .settings-row-value {
    font-size: 14px;
    color: var(--text-secondary);
}

.settings-row-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.settings-row-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.settings-row .settings-row-chevron {
    width: 16px;
    height: 16px;
    opacity: 0.3;
}

/* Settings divider */
.settings-divider {
    height: 1px;
    background: #F0F0F5;
    margin: 0 var(--space-xl);
}

/* Strategy selection cards */
.strategy-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
    position: relative;
}

.strategy-card:hover {
    background: rgba(0, 0, 0, 0.02);
}

.strategy-card.selected {
    background: rgba(84, 92, 247, 0.04);
}

.strategy-card .strategy-radio {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-top: 1px;
}

.strategy-card .strategy-info {
    flex: 1;
}

.strategy-card .strategy-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.strategy-card .strategy-info p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Settings radio (simple label-based radio row) */
.settings-radio {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}

.settings-radio:hover {
    background: rgba(0, 0, 0, 0.02);
}

.settings-radio input[type="radio"] {
    display: none;
}

.settings-radio input[type="radio"]:checked ~ .radio-icon {
    opacity: 1;
}

.settings-radio span {
    flex: 1;
    font-size: 15px;
    color: var(--text-dark);
}

.settings-radio .radio-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Language selector */
.language-option {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}

.language-option:hover {
    background: rgba(0, 0, 0, 0.02);
}

.language-option.selected {
    background: rgba(84, 92, 247, 0.04);
}

.language-option .language-check {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.language-option .language-name {
    flex: 1;
    font-size: 15px;
    color: var(--text-dark);
}

/* Privacy info section */
.settings-privacy-info {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-xl);
}

.settings-privacy-info img {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.settings-privacy-info .privacy-text h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-xs);
}

.settings-privacy-info .privacy-text p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}


/* ------------------------------------------------------------
   19. TUTORIAL SCREEN
   ------------------------------------------------------------ */


/* Tutorial step row */
.tutorial-step-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-lg);
    padding: var(--space-lg) 0;
}

.tutorial-step-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.tutorial-step-content {
    flex: 1;
}

.tutorial-step-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: var(--space-xs);
}

.tutorial-step-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Connector line between steps */
.tutorial-steps-list {
    position: relative;
}

.tutorial-steps-list::before {
    content: '';
    position: absolute;
    left: 22px;
    top: 52px;
    bottom: 52px;
    width: 2px;
    background: var(--empty-cell);
    z-index: 0;
}

.tutorial-step-row {
    position: relative;
    z-index: var(--z-base);
}

/* Tutorial container aliases */
.tutorial-steps {
    position: relative;
}

.tutorial-step-divider {
    height: 1px;
    background: var(--empty-cell);
    margin: 0 0 0 var(--space-5xl);
}

/* TIPS alert card (yellow) */
.tips-card {
    background: var(--warning-bg);
    border: 1px solid rgba(243, 190, 76, 0.3);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
}

.tips-card img {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.tips-card .tips-content {
    flex: 1;
}

.tips-card .tips-label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: #B8860B;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-xs);
}

.tips-card p {
    font-size: 14px;
    color: var(--text-tertiary);
    line-height: 1.5;
}



/* ------------------------------------------------------------
   20. FAILURE SCREEN
   ------------------------------------------------------------ */


.failure-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    max-width: 303px;
}

.failure-actions .btn {
    width: 100%;
}

/* Failure content (centered card) */
.failure-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 320px;
}

.failure-content h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
}

.failure-content p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 280px;
    margin-bottom: var(--space-3xl);
    line-height: 1.5;
}

.failure-icon {
    width: 120px;
    height: 120px;
    margin-bottom: var(--space-3xl);
    opacity: 0.85;
}

/* Divider line (decorative image separator) */
.divider-line {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: var(--space-xl) auto;
    opacity: 0.5;
}

/* Bottom action buttons (results screen) */
.bottom-actions {
    text-align: center;
    padding: var(--space-xl) 0;
    max-width: 303px;
    margin: 0 auto;
}

.bottom-actions h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: var(--space-xl);
}

.bottom-actions .btn {
    margin-bottom: var(--space-md);
}

/* Example section (tutorial) */
.example-section {
    text-align: center;
}

.example-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.example-header img {
    width: 24px;
    height: 24px;
}

.example-header span {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
}

.example-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.example-image {
    width: 100%;
    max-width: 360px;
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
}

.example-content p {
    font-size: 14px;
    color: var(--text-secondary);
}


/* ------------------------------------------------------------
   21. TOAST NOTIFICATIONS
   ------------------------------------------------------------ */

#toast-container {
    position: fixed;
    top: calc(var(--space-xl) + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    pointer-events: none;
    width: 100%;
    max-width: 400px;
    padding: 0 var(--space-xl);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-xl);
    background: var(--text-dark);
    color: #FFFFFF;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    animation: toastIn var(--duration-normal) var(--ease-spring) forwards;
    max-width: 100%;
}

.toast.toast-out {
    animation: toastOut var(--duration-normal) var(--ease-out) forwards;
}

.toast img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toast.toast-success {
    background: #1B5E20;
}

.toast.toast-error {
    background: #B71C1C;
}

.toast.toast-warning {
    background: #E65100;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-16px) scale(0.95);
    }
}


/* ------------------------------------------------------------
   22. RECOGNITION RESULT OVERLAY
   ------------------------------------------------------------ */

.recognition-result-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
}

.recognition-result-badge.correct {
    background: rgba(52, 199, 89, 0.12);
    color: #1B8A38;
}

.recognition-result-badge.incorrect {
    background: rgba(255, 59, 48, 0.12);
    color: #CC3129;
}

.recognition-result-badge img {
    width: 18px;
    height: 18px;
}


/* ------------------------------------------------------------
   23. FILE INPUT / IMAGE UPLOAD
   ------------------------------------------------------------ */

.image-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4xl) var(--space-xl);
    border: 2px dashed rgba(84, 92, 247, 0.3);
    border-radius: var(--radius-md);
    background: rgba(84, 92, 247, 0.03);
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out);
    text-align: center;
}

.image-upload-area:hover {
    border-color: var(--primary);
    background: rgba(84, 92, 247, 0.06);
}

.image-upload-area img {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-lg);
    opacity: 0.6;
}

.image-upload-area h3 {
    font-size: 15px;
    color: var(--text-dark);
    margin-bottom: var(--space-xs);
}

.image-upload-area p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Hidden file input */
.image-upload-area input[type="file"] {
    display: none;
}


/* ------------------------------------------------------------
   24. CONFIRMATION / DIALOG
   ------------------------------------------------------------ */

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    animation: backdropFadeIn var(--duration-normal) var(--ease-out);
}

.dialog-backdrop[hidden] {
    display: none;
}

.dialog {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 320px;
    width: 100%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
    animation: dialogSlideUp var(--duration-slow) var(--ease-spring);
}

.dialog h3 {
    margin-bottom: var(--space-sm);
}

.dialog p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-2xl);
}

.dialog-actions {
    display: flex;
    gap: var(--space-md);
}

.dialog-actions .btn {
    flex: 1;
    height: 48px;
}

@keyframes backdropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialogSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ------------------------------------------------------------
   25. MISC UTILITIES
   ------------------------------------------------------------ */

/* Flex helpers */
.flex-row {
    display: flex;
    align-items: center;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-1 {
    flex: 1;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* Spacing helpers */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

/* Divider */
.divider {
    height: 1px;
    background: #F0F0F5;
    margin: var(--space-lg) 0;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--empty-cell);
    color: var(--primary);
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg,
        #F0F0F5 25%,
        #E8E8F0 50%,
        #F0F0F5 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Haptic pulse (subtle animation for interactive feedback) */
@keyframes hapticPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.96); }
    100% { transform: scale(1); }
}

.haptic {
    animation: hapticPulse 0.15s var(--ease-out);
}


/* ------------------------------------------------------------
   26. RESPONSIVE BREAKPOINTS
   ------------------------------------------------------------ */

/* Small phones (< 375px) */
@media (max-width: 374px) {
    :root {
        --space-xl: 16px;
        --space-2xl: 20px;
    }

    .app-logo {
        width: 88px;
        height: 88px;
    }

    .app-title {
        font-size: 36px;
    }

    .btn-home-primary,
    .btn-home-gray,
    .btn-home-outline {
        font-size: 17px;
    }

    .btn-home-primary img,
    .btn-home-gray img,
    .btn-home-outline img {
        width: 26px;
        height: 26px;
    }

    .grid-editor {
        gap: 2px;
    }

    .figure-editor {
        gap: 1px;
    }

    .figures-row {
        gap: var(--space-sm);
    }

    .stat-value {
        font-size: 24px;
    }

    .step-grid {
        max-width: 260px;
    }

    .btn {
        height: 50px;
        font-size: 15px;
    }
}

/* Standard phones (375px - 480px) */
@media (max-width: 480px) {
    .tool-container,
    .content-container {
        padding: 0 var(--space-lg);
    }

    .nav-bar {
        padding: 0 var(--space-md);
    }

    .figures-row {
        gap: var(--space-sm);
    }

    .stats-card {
        gap: var(--space-xl);
        padding: var(--space-lg);
    }

    .step-content {
        flex-direction: column;
        align-items: center;
    }

    .step-info {
        margin-left: 0;
    }

    .step-header {
        flex-wrap: wrap;
    }

    .btn-row {
        flex-direction: column;
    }

    .btn-row .btn {
        width: 100%;
    }

    .home-nav-icons {
        gap: var(--space-2xl);
    }

    .tutorial-step-row {
        gap: var(--space-md);
    }

    .tutorial-step-icon {
        width: 36px;
        height: 36px;
    }
}

/* Tablets and wider phones (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    .step-grid {
        max-width: 360px;
    }
}

/* Tablets and desktops (768px+) */
@media (min-width: 768px) {
    /* Sub-pages: contained card appearance on desktop */
    #screen-recognition,
    #screen-manual,
    #screen-results,
    #screen-settings,
    #screen-tutorial,
    #screen-failure {
        width: 100%;
        max-width: 600px;
        margin: var(--space-2xl) auto;
        border-radius: var(--radius-xl);
        box-shadow: 0 0 60px rgba(84, 92, 247, 0.08);
        overflow: hidden;
        min-height: calc(100vh - var(--space-5xl));
        min-height: calc(100dvh - var(--space-5xl));
    }

    /* White background for screens without their own background */
    #screen-recognition,
    #screen-results,
    #screen-settings,
    #screen-tutorial,
    #screen-failure {
        background: #FFFFFF;
    }

    /* Round nav-bar top corners to match card radius */
    #screen-recognition .nav-bar,
    #screen-manual .nav-bar,
    #screen-results .nav-bar,
    #screen-settings .nav-bar,
    #screen-tutorial .nav-bar,
    #screen-failure .nav-bar {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    /* Results fixed bottom bar aligns with card bottom */
    .results-bottom-actions {
        bottom: var(--space-2xl);
        border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    }

    .step-grid {
        max-width: 380px;
    }

    .home-actions {
        max-width: 380px;
    }
}

/* Wide screens */
@media (min-width: 1024px) {
    body {
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding: var(--space-3xl);
    }

    /* Adjust card spacing for body padding */
    #screen-recognition,
    #screen-manual,
    #screen-results,
    #screen-settings,
    #screen-tutorial,
    #screen-failure {
        margin-top: 0;
        margin-bottom: 0;
        min-height: calc(100vh - var(--space-3xl) * 2);
        min-height: calc(100dvh - var(--space-3xl) * 2);
    }

    /* Results fixed bottom bar aligns with body padding */
    .results-bottom-actions {
        bottom: var(--space-3xl);
    }
}


/* ------------------------------------------------------------
   27. PRINT STYLES
   ------------------------------------------------------------ */

@media print {
    body {
        background: #FFFFFF;
        color: #000000;
        font-size: 12pt;
    }

    .app-container {
        max-width: 100%;
        box-shadow: none;
    }

    /* Hide non-essential UI */
    .nav-bar,
    .home-screen,
    .toast-container,
    .loading-overlay {
        display: none !important;
    }

    /* Cards: remove shadow, add border */
    .card,
    .stats-card,
    .step-card {
        box-shadow: none;
        border: 1px solid #DDD;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .stats-card::before {
        display: none;
    }

    /* Ensure colors print correctly */
    .stat-value {
        color: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .step-cell,
    .step-cell.filled,
    .step-cell.new,
    .step-cell.cleared {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .step-cell.filled {
        background: #545CF7 !important;
    }

    .step-cell.new {
        background: #FF7620 !important;
    }

    .step-cell.cleared {
        opacity: 0.3;
    }

    .step-grid {
        max-width: 240px;
        gap: 1px;
    }

    /* Page margins */
    @page {
        margin: 1.5cm;
    }

    /* Step cards: force page breaks between steps if needed */
    .step-card {
        margin-bottom: 12pt;
    }

    /* Remove animations */
    * {
        animation: none !important;
        transition: none !important;
    }
}


/* ------------------------------------------------------------
   28. DARK MODE (optional future support)
   ------------------------------------------------------------ */

@media (prefers-color-scheme: dark) {
    /* Placeholder: uncomment and customize when dark mode is implemented */
    /*
    :root {
        --text-dark: #F0F0F5;
        --text-secondary: #9CA3AF;
        --text-tertiary: #D1D5DB;
        --empty-cell: #2A2A3E;
        --bg-start: #0F0F1A;
        --bg-end: #1A1A2E;
        --card-bg: #1E1E32;
        --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
        --btn-secondary: #2A2A3E;
        --btn-secondary-hover: #35354A;
        --btn-tertiary: #252538;
        --btn-tertiary-hover: #303045;
    }

    body {
        color-scheme: dark;
    }

    .nav-bar {
        background: rgba(30, 30, 50, 0.85);
    }

    .settings-divider {
        background: #2A2A3E;
    }
    */
}


/* ------------------------------------------------------------
   29. ACCESSIBILITY ENHANCEMENTS
   ------------------------------------------------------------ */

/* High contrast mode */
@media (forced-colors: active) {
    .cell,
    .step-cell,
    .fp-cell {
        border: 1px solid ButtonText;
    }

    .cell.filled,
    .step-cell.filled,
    .step-cell.new,
    .fp-cell.filled {
        forced-color-adjust: none;
    }

    .btn {
        border: 1px solid ButtonText;
    }

    .toast {
        border: 1px solid CanvasText;
    }
}

/* Focus-visible for all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Reduce motion: disable all animated transitions */
@media (prefers-reduced-motion: reduce) {
    .screen.active,
    .screen.slide-in,
    .screen.slide-back {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .toast,
    .toast.toast-out {
        animation: none;
    }

    .dialog {
        animation: none;
    }

    .step-cell.new {
        animation: none;
    }

    .step-cell.cleared {
        animation: none;
        opacity: 0.3;
    }

    .skeleton {
        animation: none;
        background: #F0F0F5;
    }
}
