/* Global Reset and Base Styles */

.modal-content ul {
    padding-left: 2.5rem; /* Increased indentation for bullet points */
    margin-bottom: 1.5rem;
}

.modal-content li {
    margin-bottom: 0.5rem;
    position: relative;
}

.modal-content li::before {
    content: "🔹";
    position: absolute;
    left: -1.5rem;
}
/* Add self-hosted OpenDyslexic font-face declarations */
@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic-Regular.woff") format("woff");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic-Italic.woff") format("woff");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic-Bold-Italic.woff") format("woff");
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #5a96e3;
    --primary-hover: #4a88d3;
    --secondary: #88a0a8;
    --secondary-hover: #708890;
    --success: #63b179;
    --warning: #e3a04d;
    --error: #d96666;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #334155;
    --text-muted: #64748b;
    --border: #dde4e8;
    --border-hover: #c0c0c0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --font-family: "Open Sans", Arial, sans-serif;

    /* Theme color slots for dynamic theming */
    --theme-color-1: var(--primary);
    --theme-color-2: var(--primary-hover);
    --theme-color-3: var(--secondary);
    --theme-color-4: var(--secondary-hover);
    --theme-color-5: var(--success);
    --theme-color-6: var(--warning);
    --primary-dark: var(
        --text-muted
    ); /* This seems like a potential misname if it's supposed to be dark primary */

    /* Cell state colors */
    --cell-prefilled-bg: #e0e7ff;
    --cell-error-bg: #fff7ed;
    --cell-hint-bg: #dcfce7;
    --cell-hinted-bg: #f3f4f6;
    --cell-placed-bg: #dcfce7;
    --cell-conflict-bg: #fecaca;
    --cell-wrong-fg: var(--bg-card);
}

body {
    font-family: var(
        --font-family,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif
    );
    background-color: var(--bg, #f0f2f5);
    color: var(--text, #333);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header & Footer Common Styles */
.app-header {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky; /* Only .app-header has sticky, copyright is absolute/static */
    z-index: 10;
    min-height: 32px;
    gap: 0.5rem;
    flex-wrap: nowrap;
    white-space: nowrap;
    box-shadow: var(--shadow); /* Overridden for app-header in mobile styles */
}

.app-header {
    justify-content: space-between;
    top: 0;
    font-size: 1.2rem; /* Overridden by clamp in media queries */
    padding: 0.4rem 1rem; /* Overridden in mobile styles */
}

/* removed unused #copyright id styles */

/* Footer specific (from mobile styles) */
footer {
    position: static;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: transparent;
    flex-shrink: 0;
}

.app-header h1 {
    font-size: clamp(
        1rem,
        3vw,
        1.3rem
    ); /* Overridden by clamp in media queries */
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
}

.modal-content h1 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-content h1::before {
    content: "✨";
}

.modal-content h1::after {
    content: "🎨";
}

.app-header img.header-logo {
    height: 2rem;
    width: auto;
    vertical-align: middle;
}

/* Card Styles */
.game-header,
.menu-card,
.share-card,
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow); /* Overridden by specific cards */
    padding: 1.5rem 2rem; /* Increased padding */
    text-align: left; /* Ensure left alignment */
    line-height: 1.6; /* Comfortable reading in modals */
}

.game-header {
    margin-bottom: 0.5rem;
    box-shadow: none; /* Resetting default shadow, will be overridden in mobile */
    border: none; /* Resetting default border, will be overridden in mobile */
}
#wrapper {
    height: 100vh;
}
.menu-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); /* Specific shadow */
    border: none;
    width: 100%;
    transition: transform 0.2s ease;
}

.menu-card:hover {
    transform: translateY(-5px);
}

/* Button Styles */
button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    outline: none;
    border-radius: var(--radius);
    padding: 0.6rem 1.2rem;
}

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

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary,
.secondary {
    color: var(--bg-card);
    padding: 0.75rem 1.5rem; /* Overrides generic button padding */
    min-height: 44px;
}

.primary {
    background: var(--primary);
    font-weight: 600;
}

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

.secondary {
    background: var(--secondary);
    font-weight: 500;
}

.secondary:hover {
    background: var(--secondary-hover);
}

.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    transition:
        background 0.2s,
        border-color 0.2s,
        color 0.2s,
        transform 0.2s ease;
    aspect-ratio: 1;
}

.icon-button:hover {
    border-color: var(--border-hover);
}

.app-header .icon-button {
    width: 2rem; /* Overridden by mobile styles */
    height: 2rem; /* Overridden by mobile styles */
    font-size: 1.5rem; /* Overridden by mobile styles */
}

.bottom-nav .icon img {
    width: 1.5rem;
    height: 1.5rem;
    margin-top: 5px;
}
#mode-display {
    display: flex;
    align-content: center;
    gap: 5px;
}
/* Overlay Styles */
.menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    transition:
        opacity 0.4s ease,
        visibility 0.4s ease;
}

#start-button {
    width: 100%;
}
.menu {
    background: rgba(10, 20, 40, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20; /* Specific z-index */
    justify-content: flex-start;
    overflow-y: auto;
}

/* Menu visibility when not hidden */
.menu:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.menu.hidden {
    opacity: 0;
    visibility: hidden;
}

.menu-card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.mode-buttons {
    display: flex;
    gap: 0.75rem;
    flex-direction: column;
}

.mode-buttons button {
    text-align: left;
    justify-content: flex-start;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Difficulty and Theme Button Styles */
.difficulty-btn,
.mode-btn,
.theme-btn {
    padding: 0.7rem 0.5rem;
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text);
    font-weight: 600;
    text-align: center;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.difficulty-btn:hover,
.theme-btn:hover,
.mode-btn:hover {
    border-color: var(--border-hover);
}

.primary.active,
.secondary.active,
.mode-btn.active,
.difficulty-btn.active,
.theme-btn.active,
.theme-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--bg-card);
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.theme-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
}

.theme-btn {
    font-size: 1rem;
    box-shadow: var(--shadow);
}

.theme-btn:hover,
.theme-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    outline: none;
}

.theme-btn.active,
.theme-btn.selected {
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 0.75rem;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 24px;
    background-color: var(--secondary);
    border-radius: 24px;
    transition: background-color 0.3s ease;
    border: 2px solid var(--border);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: var(--text);
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(26px);
    background-color: white;
}

.toggle-text {
    font-size: 1rem;
    color: var(--text);
    font-weight: 500;
}

/* Music Setting Styles */
.music-setting {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

/* Sound Effects Setting Styles */
.sound-effects-setting {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.privacy-setting {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.privacy-settings-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    text-align: left;
    transition: color 0.15s;
    border-radius: 0;
    font-family: inherit;
    font-weight: 400;
}

.privacy-settings-btn:hover {
    color: var(--primary);
}

.privacy-settings-icon {
    font-size: 1.1rem;
}

.privacy-settings-text {
    flex: 1;
}

.privacy-settings-chevron {
    font-size: 1.3rem;
    line-height: 1;
    color: var(--border);
}

.help p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Game Screen Elements */
.game {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem; /* Overridden by mobile styles */
    gap: 1rem; /* Overridden by mobile styles */
    overflow: hidden;
    flex-wrap: nowrap;
    min-height: 0; /* Added from mobile styles */
    align-items: stretch; /* Added from mobile styles */
}

.top-bar {
    display: flex;
    flex-direction: row; /* Explicitly row, also defined as flex-wrap: nowrap below */
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem; /* Overridden in mobile styles */
    flex-wrap: nowrap; /* Added from mobile styles */
    width: 100%; /* Added from mobile styles */
    overflow-x: auto; /* Added from mobile styles */
    -ms-overflow-style: none; /* IE and Edge - Added from mobile styles */
    scrollbar-width: none; /* Firefox - Added from mobile styles */
}

.top-bar::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera - Added from mobile styles */
}

.break {
    flex-basis: 100%;
    height: 0;
}

.status {
    display: flex;
    flex-wrap: wrap; /* Overridden by mobile styles to nowrap */
    gap: 0.5rem; /* Overridden by mobile styles */
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
}

.status span {
    padding: 5px 10px;
}

/* Badges (Timer, Score, etc.) */
.badge,
.timer {
    height: auto;
    font-size: 0.9rem;
    border-radius: var(--radius);
    padding: 0.4rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    box-shadow: none;
    flex: 0 0 auto;
    white-space: nowrap;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.timer {
    font-weight: 700;
    color: var(--text);
    border-color: var(--primary);
    min-width: 5rem; /* always MM:SS + icon, never shrinks */
    justify-content: center;
}

.badge.score {
    min-width: 4rem; /* accommodates up to 4 digits */
    justify-content: center;
}

.badge.error {
    border-color: var(--error);
}

.badge.score {
    border-color: var(--success);
}

.badge.hint {
    border-color: #fee65f;
}

#board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    min-height: 0;
    overflow: hidden; /* Added from mobile styles */
}

#game-board {
    display: grid;
    gap: 4px; /* Overridden by mobile styles */
    background: var(--border); /* Overridden by mobile styles */
    border-radius: var(--radius);
    padding: 4px; /* Removed, gap is enough unless there's a specific reason for padding */
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); /* Overridden by mobile styles */
    margin: 0 auto; /* Added from mobile styles */
}

/* Grid is likely redundant with #game-board but was in mobile-specific styles. Keeping it for now. */
.grid {
    width: 100%;
    height: 100%;
    display: grid;
    gap: clamp(2px, 1vw, 6px);
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 2px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cell {
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(60vw / var(--grid-size));
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    border-radius: 3px;
    position: relative;
    line-height: 1;
}

.cell:hover {
    background: var(--border);
    transform: scale(1.05);
}

.cell.selected {
    border: 2px solid var(--primary);
    box-shadow: 0 0 5px var(--secondary-hover);
}

.cell.wrong .symbol {
    animation: shake 0.5s;
}

.cell.pre-filled {
    background: var(--cell-prefilled-bg);
    color: var(--primary);
    cursor: default;
}

.cell.error {
    background: var(--cell-error-bg);
    color: var(--warning);
}

.cell.hint {
    background: var(--cell-hint-bg) !important;
    color: var(--success);
}

.cell.hinted {
    background: var(--cell-hinted-bg) !important;
}

/* Locked cells (e.g., from hints): not editable */
.cell.locked {
    cursor: default;
}
.cell.placed {
    background: var(--cell-placed-bg);
    color: var(--success);
    border: 2px solid var(--success);
}

.cell.conflict {
    background: var(--cell-conflict-bg);
    color: var(--error);
    border: 2px solid var(--error);
}

.cell.wrong {
    animation: shake 0.5s;
    background: var(--error);
    color: var(--cell-wrong-fg);
    border: 2px solid var(--error);
}

/* Cell symbol span - inherits all font styles from .cell */
.cell-symbol {
    pointer-events: none;
    display: contents;
}

/* Remove button - red × badge, inside top-right corner */
.cell-remove-btn {
    display: none;
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    min-width: 0;
    padding: 0;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.8);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 3;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition:
        transform 0.1s,
        background 0.1s;
}

.cell-remove-btn:hover {
    background: #dc2626;
    transform: scale(1.15);
    text-decoration: none;
}

/* Desktop: show on hover over a filled, editable cell */
.cell.has-value:not(.pre-filled):not(.hinted):not(.locked):hover
    .cell-remove-btn {
    display: flex;
}

/* Touch/any: show when the filled cell is selected */
.cell.has-value:not(.pre-filled):not(.hinted):not(.locked).selected
    .cell-remove-btn {
    display: flex;
}

/* Symbol & Action Bars */
#symbol-bar {
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.symbol-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(52.5px, 10.5vw, 75px);
    height: clamp(52.5px, 10.5vw, 75px);
    font-size: clamp(1.1rem, 5.5vw, 2rem);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: calc(var(--radius) * 0.75);
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    line-height: 0;
    align-content: center;
    flex-wrap: nowrap;
    flex-direction: column;
}

.symbol-option:hover,
.symbol-option.selected {
    background: var(--primary);
    color: var(--bg-card);
    border-color: var(--primary);
    transform: scale(1.05);
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.action-buttons button {
    min-width: 140px;
    font-size: 1.05rem;
    padding: 0.7rem 1.2rem;
    box-shadow: 0 2px 8px -2px rgb(0 0 0 / 0.08);
}

.copyright {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

.menu-footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0;
    margin: 1.25rem 0 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.menu-footer-nav a {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    transition: color 0.15s;
    white-space: nowrap;
}

.menu-footer-nav a:hover {
    color: var(--primary);
}

.menu-footer-nav a:not(:last-child) {
    border-right: 1px solid var(--border);
}

/* Share Card */
.share-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg) 100%);
    margin: 1rem 0;
    text-align: center;
    transition: transform 0.2s ease;
    border: 1px solid var(--border);
}

.share-card:hover {
    transform: translateY(-2px);
}

#share-message {
    white-space: pre;
    font-family: monospace;
    font-size: 1.2rem;
    margin: 0.5rem 0;
    text-align: left;
}

#share-score {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
}

.share-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.share-buttons button {
    min-width: 120px;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: var(--bg-card);
    border: none;
    max-height: 50px;
}

.share-buttons button:hover {
    background: var(--primary-hover);
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.5s ease-in-out;
}

#loading-screen .spinner {
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

#loading-screen p {
    margin-top: 1rem;
    font-size: 1.2rem;
    font-weight: 500;
}

.loading-logo {
    margin-bottom: 1.5rem;
    animation: pulse 1.5s infinite ease-in-out;
}

.game-title {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0rem 0 1rem;
    letter-spacing: -1px;
    text-align: center;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    padding: 1rem;
    overflow-y: auto;
}

/* Ensure modals are visible when toggled with .show (overrides .hidden) */
.modal.show {
    display: block;
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg) 100%);
    border-radius: calc(var(--radius) * 1.5);
    padding: 2.5rem 1.5rem 2rem 1.5rem;
    margin: 8% auto;
    position: relative;
    box-shadow:
        0 25px 50px -12px rgba(0 0 0 / 0.25),
        0 0 15px rgba(90, 150, 227, 0.1);
    text-align: center;
    border: none;
    animation: fadeIn 0.5s ease-in-out;
    max-width: 400px;
}

/* PWA Install Prompt */
.pwa-prompt {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-card);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);

    padding: 10px 0;
    text-align: center;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    z-index: 9999;
}

.pwa-prompt.show {
    display: block;
}

.pwa-prompt-content {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 15px;
}

.pwa-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    margin-right: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pwa-text {
    font-size: 1.1em;
    color: var(--text);
    margin-right: 20px;
    flex-grow: 1;
    text-align: left;
}

.pwa-prompt .button {
    padding: 8px 15px;
    font-size: 0.9em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pwa-prompt .button:hover {
    opacity: 0.9;
}

.pwa-dismiss-button {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5em;
    margin-left: 10px;
    cursor: pointer;
    padding: 5px;
}

.pwa-dismiss-button:hover {
    color: var(--primary);
}

.close-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius); /* Consistent radius */
}

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

/* Bottom Navigation Bar (Mobile specific) */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 9998;

    padding: 0.5rem 0.5rem;
}

.bottom-nav button {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.8rem, 2vw, 1rem);
    flex-grow: 1;
    padding: 0.5rem 0;
    padding-top: 5px;
}

.bottom-nav .svg-icon {
    width: clamp(1.25rem, 5vw, 1.75rem);
    height: clamp(1.25rem, 5vw, 1.75rem);
}

.bottom-nav button:hover,
.bottom-nav button:focus {
    color: var(--primary);
}

.hidden {
    display: none;
}
/* Animations */
@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-2px);
    }

    40%,
    80% {
        transform: translateX(2px);
    }
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* --- Responsive Fine-Tuning (Media Queries) --- */

/* For mobile and tablet-specific styles - generally max-width: 768px for tablets */
@media (max-width: 768px) {
    /* Most body styles were consolidated into the main body tag. */

    .app-header {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Overrides general var(--shadow) */
        padding: 0.75rem 1rem; /* Overrides general padding */
        flex-shrink: 0;
    }

    .app-header h1 {
        font-size: clamp(1rem, 4vw, 1.25rem); /* Overrides general clamp */
    }

    .app-header .icon-button {
        width: 2.25rem; /* Overrides general width */
        height: 2.25rem; /* Overrides general height */
        font-size: 1.25rem; /* Overrides general font-size */
    }

    .game {
        padding: 1rem 1rem 70px 1rem; /* Space for bottom nav */
        gap: 0.5rem; /* Overrides general gap */
    }

    .game-header {
        background: var(--bg-card);
        border-radius: var(--radius);
        padding: 5px; /* Overrides general padding */
        margin: 0.5rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* Overrides general shadow */
        border: 1px solid var(--border); /* Overrides general border */
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .top-bar {
        gap: 6px; /* Overrides general gap */
    }

    .status {
        flex-wrap: nowrap; /* Overrides general flex-wrap */
        gap: 6px; /* Explicitly matching top-bar gap */
    }

    .badge,
    .timer {
        border-radius: calc(var(--radius) * 0.75);
        padding: 0.4rem 0.7rem;
        font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    }

    #game-board {
        gap: clamp(2px, 1vw, 6px); /* Responsive gap */
        background: var(--border); /* Already set, but explicit */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); /* Specific shadow for mobile */
    }
}

/* For short screens */
@media screen and (max-height: 700px) {
    .game-header,
    #symbol-bar {
        padding: 0.5rem;
        margin: 0.25rem;
    }

    .badge {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }

    .symbol-option {
        min-width: 40px;
        min-height: 40px;
    }
}

/* For very narrow screens */
@media screen and (max-width: 480px) {
    .app-header {
        padding: 0.5rem; /* Smaller padding for narrow screens */
    }

    .app-header h1 {
        font-size: 1rem; /* Even smaller font size */
    }

    .status {
        gap: 0.5rem; /* Smaller gap for status items */
    }

    .badge {
        padding: 0.25rem 0.5rem; /* Even smaller padding */
        font-size: 0.75rem; /* Even smaller font size */
    }

    .symbol-option {
        min-width: 38px;
        min-height: 38px;
    }

    .share-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .share-buttons button {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
    }
}
@media screen and (min-width: 500px) {
    #wrapper,
    #menu,
    #loading-screen,
    body,
    nav,
    .modal,
    #game-board {
        max-width: 500px !important;
        margin: 0 auto !important;
        left: calc(50% - 250px);
    }
    #wrapper {
        height: 100vh;
    }
    #pwa-install-prompt {
        display: none;
    }
    .cell {
        font-size: calc(15rem / var(--grid-size));
        line-height: 1px;
    }
    .symbol-option {
        max-width: 50px;
        max-height: 50px;
        line-height: 1px;
    }
}
.icon-button img,
.top-bar img,
#mode-display img,
.icon img,
button img {
    filter: var(--svg-color);
}
/* Modal text readability improvements */
.modal-content h2 {
    margin: 0 0 0.75rem;
    text-align: center; /* Keep headings centered */
}
.modal-content p {
    margin: 0 0 1rem; /* Space between paragraphs */
}
.modal-content li {
    line-height: 1.6; /* Match paragraph rhythm */
}
.modal-content .action-buttons {
    display: grid;
    gap: 0.75rem; /* Comfortable spacing between buttons */
    margin-top: 1rem;
}
@media (max-width: 480px) {
    .modal-content {
        margin: 12% 0.75rem; /* Reduce side gutters on small screens */
        padding: 1.5rem 1rem; /* Keep comfortable padding */
        font-size: 1.05rem; /* Maintain readability */
    }
    .modal-content .action-buttons {
        grid-template-columns: 1fr; /* Stack buttons vertically */
    }
}
.cell.marked-for-delete::after {
    content: "\00D7";
    position: absolute;
    top: 2px;
    right: 2px;
    color: red;
    font-weight: bold;
    font-size: 24px;
}
.cell.marked-for-delete {
    animation: wiggle 0.5s infinite;
}
@keyframes wiggle {
    0% {
        transform: rotate(1deg);
    }
    20% {
        transform: rotate(3deg);
    }
    40% {
        transform: rotate(1deg);
    }
    60% {
        transform: rotate(-1deg);
    }
    80% {
        transform: rotate(-3deg);
    }
    100% {
        transform: rotate(-1deg);
    }
}

/* ── Buy Me a Coffee ──────────────────────────────────────────────────────── */
.bmc-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: #ffdd00;
    color: #000000;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
    border-radius: 2rem;
    text-decoration: none;
    transition:
        background 0.2s ease,
        transform 0.15s ease;
    margin: 0.75rem auto 0.25rem;
    width: fit-content;
}

.bmc-button:hover {
    background: #ffd000;
    transform: translateY(-1px);
}

.bmc-button--subtle {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    margin: 0.75rem auto 0;
    width: fit-content;
}

.bmc-button--subtle:hover {
    background: #ffdd00;
    color: #000000;
    border-color: #ffdd00;
    transform: translateY(-1px);
}

/* ── Web Ad Containers ─────────────────────────────────────────────────────── */
.web-ad-container {
    width: 100%;
    min-height: 90px;
    margin: 0.5rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

.web-ad-container[hidden] {
    display: none;
}

/* ── Cookie / Ad Consent Banner ────────────────────────────────────────────── */
.consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    padding: 1rem;
    animation: slideUp 0.3s ease-out;
}

.consent-banner[hidden] {
    display: none;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.consent-banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 700px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.consent-text {
    flex: 1 1 200px;
    font-size: 0.875rem;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
}

.consent-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.consent-btn {
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    min-height: 40px;
}

.consent-btn-accept {
    background: var(--primary);
    color: var(--bg-card);
}

.consent-btn-accept:hover {
    background: var(--primary-hover);
}

.consent-btn-decline {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.consent-btn-decline:hover {
    border-color: var(--border-hover);
}

@media (max-width: 480px) {
    .consent-banner-content {
        flex-direction: column;
        align-items: stretch;
    }
    .consent-actions {
        justify-content: stretch;
    }
    .consent-btn {
        flex: 1;
    }
}
