/* Copyright (c) 2024-2026 Jericho Crosby (Chalwk). All Rights Reserved. */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');

html,
body {
    height: 100%;
    margin: 0;
}

main {
    height: 100%;
}

:root {
    --primary: #4a86e8;
    --primary-rgb: 74, 134, 232;

    /* semantic tokens (overridden by theme classes) */
    --bg: #f9fafb;
    --surface: #ffffff;
    --surface-alt: #f3f4f6;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --toast-bg: #111827;
    --toast-text: #ffffff;
    --nav-bg: rgba(255, 255, 255, 0.95);

    /* legacy aliases so existing rules keep working */
    --light: var(--bg);
    --dark: var(--text);
    --gray: var(--text-muted);
    --gray-light: var(--border);
    --white: var(--surface);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.25rem;
    --radius: 0.375rem;
    --radius-lg: 0.5rem;

    --container-max: 1200px;
}

/* ---------------- Themes ---------------- */
body.theme-light {
    --bg: #f9fafb;
    --surface: #ffffff;
    --surface-alt: #f3f4f6;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --nav-bg: rgba(255, 255, 255, 0.95);
}

body.theme-dark {
    --bg: #111827;
    --surface: #1f2937;
    --surface-alt: #374151;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --border: #374151;
    --nav-bg: rgba(31, 41, 55, 0.95);
    --primary: #60a5fa;
    --primary-rgb: 96, 165, 250;
    --toast-bg: #374151;
    --toast-text: #f9fafb;
}

body.theme-high-contrast {
    --bg: #000000;
    --surface: #000000;
    --surface-alt: #000000;
    --text: #ffffff;
    --text-muted: #ffffff;
    --border: #ffffff;
    --nav-bg: #000000;
    --primary: #ffff00;
    --primary-rgb: 255, 255, 0;
    --toast-bg: #ffff00;
    --toast-text: #000000;
}

@media (prefers-color-scheme: dark) {
    body.theme-auto {
        --bg: #111827;
        --surface: #1f2937;
        --surface-alt: #374151;
        --text: #f3f4f6;
        --text-muted: #9ca3af;
        --border: #374151;
        --nav-bg: rgba(31, 41, 55, 0.95);
        --primary: #60a5fa;
        --primary-rgb: 96, 165, 250;
        --toast-bg: #374151;
        --toast-text: #f9fafb;
    }
}

body {
    background: var(--bg);
    color: var(--text);
}

.visually-hidden {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

.hmo-app-root {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--light);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 2rem;
    position: relative;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--primary);
    color: white;
}

.header-left {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.header-left h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.4rem;
    margin: 0;
    color: white;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.header-sub {
    display: flex;
    align-items: center;
}

.header-sub select {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
}

.header-sub select:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.settings-dropdown {
    position: relative;
}

.header-icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.settings-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 0.75rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 220px;
    margin-top: 0.5rem;
}

.settings-dropdown.active .settings-menu {
    display: block;
}

.settings-group {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-light);
}

.settings-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.settings-group .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
    text-align: left;
}

.settings-group .btn:last-child {
    margin-bottom: 0;
}

.settings-group label.btn {
    cursor: pointer;
    display: block;
}

.settings-group label.btn input {
    display: none;
}

.import-label {
    cursor: pointer;
}

.hmo-app-root .main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.phrase-bar {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--light);
    border-bottom: 1px solid var(--gray-light);
    align-items: center;
}

.phrase-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.4rem;
    flex: 1;
    min-height: 48px;
    padding: 0.5rem 0.65rem;
    background: var(--surface);
    border-radius: var(--radius);
    align-items: center;
    border: 1px solid var(--gray-light);
    transition: all 0.2s ease;
}

.phrase-display.drag-active {
    background: var(--light);
    border: 2px dashed var(--gray-light);
    min-height: 60px;
}

.phrase-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
    border: none;
    min-height: 32px;
    box-shadow: none;
    touch-action: none;
}

.phrase-item:hover {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--text);
}

.phrase-item:active {
    cursor: grabbing;
}

.phrase-item.dragging {
    opacity: 0.55;
    transform: scale(0.95);
    cursor: grabbing;
}

.phrase-item.drag-over {
    background: rgba(var(--primary-rgb), 0.25);
}

.phrase-item img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    pointer-events: none;
}

.phrase-item:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.phrase-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.board-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    padding: 4.5rem 64px 1.5rem;
    touch-action: pan-x pan-y;
}

.board-scroll-wrapper {
    overflow: auto;
    height: 100%;
    touch-action: pan-y;
}

.board-nav-group {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    top: 30%;
    transform: translateY(-50%);
}

.board-nav-prev-group {
    left: 5px;
}

.board-nav-next-group {
    right: 5px;
}

.board-nav {
    background: var(--nav-bg);
    color: var(--text);
    border: 2px solid var(--gray-light);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
    -webkit-tap-highlight-color: transparent;
}

.board-nav:hover {
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.board-nav:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary);
}

.swipe-hint {
    display: flex;
    gap: 0.1rem;
    font-size: 0.9rem;
    line-height: 1;
    user-select: none;
}

.swipe-hint .arrow {
    display: inline-block;
    font-family: monospace;
}

.swipe-hint-left .arrow-1 {
    color: #000;
}

.swipe-hint-left .arrow-2 {
    color: #888;
}

.swipe-hint-left .arrow-3 {
    color: #ccc;
}

.swipe-hint-right .arrow-1 {
    color: #ccc;
}

.swipe-hint-right .arrow-2 {
    color: #888;
}

.swipe-hint-right .arrow-3 {
    color: #000;
}

/* hide swipe hints on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .swipe-hint {
        display: none;
    }
}

.category-indicator {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    color: var(--text);
    padding: 0.4rem 1.2rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
    z-index: 5;
    white-space: nowrap;
    border: 2px solid var(--primary);
    cursor: pointer;
    user-select: none;
}

.category-indicator:hover {
    background: var(--surface-alt);
}

.category-dropdown {
    position: absolute;
    top: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    min-width: 200px;
    display: none;
}

.category-dropdown-header {
    padding: 0.5rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--gray-light);
    background: var(--light);
    font-size: 0.95rem;
}

.category-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
}

.category-list li {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.95rem;
    white-space: nowrap;
}

.category-list li:hover {
    background: var(--light);
}

.category-list li.active {
    font-weight: 700;
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.category-list li:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

button:active {
    transform: scale(1) !important;
}

.board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    transition: opacity 0.15s ease;

    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--surface);
}

.board.fixed-grid {
    gap: 0.75rem;
    padding: 0.75rem;
}

.board.grid-3x4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.board.grid-4x6 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.board.grid-6x8 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.symbol {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--radius);
    background: #e8f0fe;
    color: #111827;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    min-height: 100px;
    border: 2px solid var(--gray-light);
    box-shadow: var(--shadow-sm);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.symbol-number {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 0.65rem;
    font-weight: bold;
    line-height: 1;
    color: rgba(0, 0, 0, 0.7);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    min-width: 1.5em;
    height: 1.5em;
    padding: 0 0.35em;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.symbol img {
    pointer-events: none;
    -webkit-user-drag: none;
    max-width: 80%;
    max-height: 70px;
    object-fit: contain;
    margin-bottom: 0.25rem;
    flex-shrink: 1;
}

.symbol-emoji {
    font-size: clamp(1.5rem, 8vw, 2.5rem);
    line-height: 1;
    display: block;
    white-space: nowrap;
    text-align: center;
}

.symbol span:last-child {
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
    word-break: break-word;
    flex-shrink: 0;
    font-weight: 700;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    letter-spacing: 0.01em;
}

.board.fixed-grid .symbol {
    display: grid;
    grid-template-rows: 1fr auto;
    align-items: center;
    justify-items: center;
    padding: 0.25rem;
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
    min-height: 0;
}

.board.fixed-grid .symbol img,
.board.fixed-grid .symbol-emoji {
    max-width: 90%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin-bottom: 0;
    align-self: center;
}

.board.fixed-grid .symbol-emoji {
    font-size: clamp(1.2rem, 6vw, 2rem);
    white-space: nowrap;
}

.board.fixed-grid .symbol span:last-child {
    font-size: clamp(0.6rem, 2vw, 0.8rem);
    -webkit-line-clamp: 2;
    align-self: end;
    width: 100%;
    padding: 0 0.1rem;
    font-weight: 700;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    letter-spacing: 0.01em;
}

.symbol.editing::after {
    content: "✏️";
    position: absolute;
    right: 0.25rem;
    top: 0.25rem;
    font-size: 0.9rem;
    z-index: 2;
}

.symbol:focus {
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
    transform: translateY(-2px);
}

.symbol:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.edit-mode .board-container {
    filter: brightness(0.92) saturate(0.98);
}

.floating-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-content {
    background: var(--surface);
    color: var(--text);
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-alt);
    color: var(--text);
}

.modal-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.3rem;
}

.modal-body {
    padding: 1.5rem;
}

.close {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray);
    transition: color 0.2s ease;
    background: none;
    border: none;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: var(--text);
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text);
}

.form-group input[type="text"],
.form-group select,
.form-group input[type="color"] {
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.form-group small {
    font-size: 0.85rem;
    color: var(--text);
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-light);
}

.modal-buttons {
    display: flex;
    gap: 8px;
}

.categories-list {
    margin: 1.5rem 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
}

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

.category-name-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}

.category-actions {
    display: flex;
    gap: 0.25rem;
}

.category-actions button {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.settings-panel {
    margin-bottom: 1.5rem;
}

.settings-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 1.1rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.25rem;
}

.settings-section .form-group {
    margin-bottom: 1rem;
}

.settings-section .form-group:last-child {
    margin-bottom: 0;
}

.info-content ul {
    padding-left: 1.5rem;
    margin: 0.75rem 0;
}

.info-content li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.info-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--text);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.25rem;
}

.info-content kbd {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1em 0.4em;
    font-size: 0.9em;
    font-family: monospace;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 6rem;
    min-width: 200px;
    max-width: 320px;
    z-index: 2000;
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.empty-message {
    color: var(--gray);
    font-style: italic;
    padding: 0.5rem;
}

body.clicked-outside .settings-dropdown.active .settings-menu {
    display: none;
}

@media (max-width: 768px) {
    .app-header {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 0.5rem;
        padding: 1rem;
    }

    .header-left {
        display: contents;
    }

    .header-left h2 {
        grid-column: 1;
        grid-row: 1;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-sub {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
        width: 100%;
        margin-top: 0.25rem;
    }

    .header-sub select {
        width: 100%;
    }

    .header-controls {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .settings-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin-top: 0;
        max-height: 70vh;
        overflow-y: auto;
    }

    .phrase-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .phrase-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .board {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }

    .board.fixed-grid {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .board.grid-6x8 {
        grid-template-columns: repeat(6, minmax(70px, 1fr));
    }

    .board.grid-6x8.fixed-grid .symbol {
        padding: 0.15rem;
    }

    .board.grid-6x8.fixed-grid .symbol-emoji {
        font-size: clamp(1rem, 5vw, 1.5rem);
    }

    .board.grid-6x8.fixed-grid .symbol span:last-child {
        font-size: clamp(0.5rem, 1.8vw, 0.7rem);
    }

    .category-item {
        flex-direction: column;
        align-items: stretch;
    }

    .category-actions {
        justify-content: space-between;
    }

    .floating-btn {
        bottom: 1rem;
        right: 1rem;
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .settings-section {
        padding: 0.75rem;
    }

    .settings-section h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .board {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .board.grid-6x8 {
        grid-template-columns: repeat(6, minmax(60px, 1fr));
    }

    .board.grid-6x8.fixed-grid .symbol-emoji {
        font-size: clamp(0.9rem, 4vw, 1.3rem);
    }

    .board.grid-6x8.fixed-grid .symbol span:last-child {
        font-size: clamp(0.45rem, 1.5vw, 0.6rem);
    }

    .symbol {
        min-height: 90px;
    }

    .symbol span:last-child,
    .board.fixed-grid .symbol span:last-child {
        font-weight: 800;
        letter-spacing: 0.02em;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 1rem;
    }

    .form-actions>div {
        width: 100%;
        justify-content: space-between;
    }

    .settings-panel {
        margin-bottom: 1rem;
    }

    .settings-section {
        margin-bottom: 1rem;
        padding: 0.75rem;
    }

    .info-content {
        font-size: 0.95rem;
    }
}

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

.symbol:focus,
.phrase-item:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media print {

    .app-header,
    .phrase-bar,
    .floating-btn,
    .settings-dropdown,
    .board-toolbar {
        display: none !important;
    }

    .app-container {
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    .board {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }
}