* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
    scroll-padding-bottom: 220px;
}

/* Branding & Header */
.branding {
    position: fixed;
    top: 0;
    width: 100%;
    background: #1a1a1a;
    border-bottom: 3px solid var(--primary-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 1rem 0;
}
.branding .icon-btn {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.branding .nav-link, .branding .logo-text, .branding .icon-btn {
    color: #ffffff !important;
}
.branding .nav-link:hover {
    color: var(--primary-color) !important;
    text-decoration-color: var(--primary-color) !important;
}

.nav-container {
    max-width: calc(22 * var(--cell-size));
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left {
    display: flex !important;
    align-items: center;
    gap: 32px;
    flex: 1;
}

.nav-links-desktop {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    flex: 0 0 auto;
}

.nav-menu-link {
    color: #ffffff;
    text-decoration: none;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: opacity 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
}

.nav-menu-link:hover {
    opacity: 0.8;
}

@media (max-width: 900px) {
    .nav-links-desktop {
        display: none;
    }
    .desktop-only {
        display: none !important;
    }
}

/* Mobile Drawer */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background: #1a1a1a;
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    border-left: 1px solid rgba(255,255,255,0.1);
}

.mobile-drawer.open {
    transform: translateX(-300px);
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1900;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease;
}

.drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

.drawer-header {
    padding: 1.5rem;
    display: flex;
    justify-content: flex-end;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.drawer-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.drawer-nav-link {
    color: #ffffff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

.drawer-nav-link:hover {
    color: var(--primary-color);
}

.hamburger-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 8px;
    display: none;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .hamburger-btn {
        display: flex;
    }
}

/* Landing Page Hero */
.hero-container {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4rem;
    max-width: calc(22 * var(--cell-size));
    margin: 140px auto 40px;
    padding: 0 1rem;
    min-height: calc(100vh - 350px);
}

.hero-content {
    flex: 1;
    text-align: left;
    padding-top: 0;
}

.hero-content h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
    font-weight: 800;
}

.hero-description {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--clue-text);
    margin-bottom: 2rem;
    max-width: 600px;
}

.hero-features {
    list-style: none;
    padding: 0;
    margin-bottom: 2.5rem;
}

.hero-features li {
    font-size: 1.15rem;
    min-height: 2.5rem;
    /* Reduced from 3.5rem for compactness */
    display: grid;
    grid-template-columns: 14rem 1fr;
    /* Slightly reduced width since emojis are gone */
    align-items: center;
    gap: 1rem;
    /* Reduced gap from 1.5rem */
}

.hero-features li strong {
    white-space: nowrap;
}

.hero-feature-desc {
    opacity: 0.7;
    margin-top: 1px;
}

.feature-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hero-visual {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 0;
}

.preview-stack {
    position: relative;
    width: 100%;
    max-width: 380px;
    /* Reduced further to 380px */
    padding-bottom: 60px;
    /* Space for the absolute image offset */
    z-index: 10;
}

.preview-img {
    width: 100%;
    border-radius: 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    border: 1px solid var(--panel-border);
}

.preview-img.light { position: relative; z-index: 2; transform: none; opacity: 1; border-radius: 0; }

.preview-img.dark { display: none; }

[data-theme="dark"] .preview-img.dark {
    position: relative;
    top: 0;
    left: 0;
    z-index: 2;
    transform: rotate(-3deg);
    opacity: 1;
}

[data-theme="dark"] .preview-img.light {
    position: absolute;
    top: 40px;
    left: 40px;
    z-index: 1;
    transform: rotate(3deg);
    opacity: 0.8;
}

.preview-stack:hover .preview-img.light,
.preview-stack:hover .preview-img.dark {
    transform: rotate(0deg) scale(1.02);
}

[data-theme="dark"] .preview-stack:hover .preview-img.dark {
    transform: rotate(-1deg) scale(1.02);
}

[data-theme="dark"] .preview-stack:hover .preview-img.light {
    transform: rotate(1deg) translate(20px, 10px);
}

/* Global Footer Area */
.main-footer {
    width: 100%;
    margin-top: auto;
    padding: 4rem 1rem 2rem;
    background: #1a1a1a;
    color: #ffffff;
    border-top: 5px solid var(--primary-color);
}

.footer-container {
    max-width: calc(22 * var(--cell-size));
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
}

.footer-info h4 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
}

.footer-info p {
    max-width: 400px;
    opacity: 0.7;
    font-size: 0.9rem;
    line-height: 1.5;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-links a {
    color: #ffffff;
    text-decoration: none;
    opacity: 0.8;
    font-size: 0.95rem;
}

.footer-links a:hover {
    opacity: 1;
    color: var(--primary-color);
}

.bottom-line {
    max-width: calc(22 * var(--cell-size));
    margin: 2rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    opacity: 0.5;
}

.section-divider {
    max-width: calc(22 * var(--cell-size));
    margin: 0 auto;
    height: 3px;
    background: white;
    border: none;
    opacity: 0.6;
}

/* Grid Section (Shared for OM and FAQ) */
.grid-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 4rem;
    max-width: calc(22 * var(--cell-size));
    margin: 40px auto 40px;
    padding: 0 1rem;
    align-items: flex-start;
    width: 100%;
}

.static-info-card {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0;
    padding: 2.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    line-height: 1.6;
    color: #111111;
}
[data-theme="dark"] .static-info-card {
    background: var(--letter-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
}

.article-preview-card {
    list-style: none;
    margin-bottom: 2rem;
    padding: 2.5rem;
    background: var(--letter-bg);
    border: 1px solid var(--panel-border);
    border-radius: 0;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    cursor: pointer;
}

[data-theme="light"] .article-preview-card {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.1);
}

.article-preview-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px var(--shadow-color);
}

.article-preview-card h3 a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-preview-card:hover h3 a {
    color: var(--primary-color);
}

/* Invisible overlay link to make the whole card clickable */
.article-preview-card .main-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.article-date {
    display: block;
    font-size: 0.85rem;
    color: var(--clue-text);
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    font-weight: 700;
}

.article-meta {
    font-size: 1rem;
    color: var(--clue-text);
    opacity: 0.85;
    margin-bottom: 2.5rem;
    font-weight: 500;
    display: block;
}

.static-info-card h3 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
}

.static-info-card a,
.faq-content a {
    color: var(--text-color);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: var(--primary-color);
    transition: opacity 0.2s ease;
}

.static-info-card a:hover,
.faq-content a:hover {
    opacity: 0.7;
}

.static-info-card p {
    margin-bottom: 1.5rem;
    opacity: 1;
}

.static-info-card ul {
    margin-bottom: 1.5rem;
    padding-left: 1.25rem;
    opacity: 1;
}

.static-info-card li {
    margin-bottom: 0.5rem;
}

.article-header-side {
    position: sticky;
    top: 140px;
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-color);
    line-height: 1.1;
}

.article-header-side .article-meta {
    margin: 0;
    opacity: 0.6;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.faq-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.faq-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
[data-theme="dark"] .faq-item {
    background: var(--letter-bg);
    border-color: var(--panel-border);
}

.faq-item summary {
    padding: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    user-select: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 400;
    transition: transform 0.3s ease;
}

.faq-item[open] {
    border-color: var(--primary-color);
}

.faq-item[open]:not(.closing) summary::after {
    transform: rotate(45deg);
    color: var(--primary-color);
}

.faq-answer {
    padding: 0;
}

.faq-content {
    padding: 0 1.5rem 1.5rem;
    line-height: 1.6;
    color: var(--clue-text);
}

:root {
    --primary-color: #dc2626;
    --light-color: #fccfcf;
    --hover-color: #b91c1c;
    /* Action Red */
    --selection-blue: #3b82f6;
    --success-green: #16a34a;

    /* Theme Colors (Light) */
    --bg-color: #fdf8f3;
    --border-color: #000000;
    --letter-bg: #ffffff;
    --text-color: #111111;
    --clue-bg: #f8fafc;
    --clue-text: #1e293b;
    --active-cell: #c5d8ff;
    /* Solid color to prevent black bleed-through */
    --active-word: #e0ebff;
    --checked-correct-bg: transparent;
    --checked-wrong-bg: transparent;
    --modal-overlay: rgba(0, 0, 0, 0.4);
    --modal-bg: #ffffff;
    --share-btn-bg: #f1f5f9;
    --share-btn-text: #1e293b;
    --panel-bg: rgba(255, 255, 255, 0.95);
    --panel-border: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.1);

    /* Responsive Cell Size */
    --cell-size: clamp(17px, 4.15vw, 52px);
    --grid-gap: 1px;
    /* Keep cell-size as it's used later */
    --btn-tool: #0f172a;
    /* Keep button styles as they are used later */
    --btn-tool-hover: #334155;
    --btn-primary: var(--primary-color);
    --btn-primary-hover: var(--hover-color);
    --btn-reveal: var(--primary-color);
    --btn-reveal-hover: var(--hover-color);
}

[data-theme="dark"] {
    --primary-color: #3b82f6;
    --light-color: #1e2f5e;
    --hover-color: #2563eb;
    --bg-color: #0f172a;
    --border-color: #334155;
    --letter-bg: #1e293b;
    --text-color: #f1f5f9;
    --clue-bg: #1e293b;
    --clue-text: #94a3b8;
    --active-cell: #3159b3;
    --active-word: #253e7a;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --bg-gradient: linear-gradient(135deg, #1e1e1e 0%, #121212 100%);
    /* Keep original dark gradient */
    --btn-tool: #334155;
    /* Keep button styles as they are used later */
    --btn-tool-hover: #475569;
    --btn-primary: #3b82f6;
    --btn-primary-hover: var(--hover-color);
    --btn-reveal: #3b82f6;
    --btn-reveal-hover: var(--hover-color);
    --modal-bg: #1e293b;
    --modal-overlay: rgba(0, 0, 0, 0.75);
    --share-btn-bg: #334155;
    --share-btn-text: #f1f5f9;
    --panel-bg: rgba(30, 41, 59, 0.95);
    --panel-border: rgba(255, 255, 255, 0.15);
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-color);
    background-attachment: fixed;
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

body.no-scroll {
    overflow: hidden !important;
}

/* Responsive Theme Support */

.nav-link {
    color: var(--text-color);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: var(--primary-color);
    font-weight: 600;
    font-size: 14px;
    opacity: 1;
    position: relative;
    transition: opacity 0.2s ease;
}

.nav-link:hover {
    opacity: 0.7;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.logo-icon {
    width: clamp(24px, 4vw, 32px);
    height: clamp(24px, 4vw, 32px);
    color: var(--primary-color);
}

.logo-text {
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-color);
    line-height: 1;
    display: flex;
    align-items: center;
}

.copyright-footer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 12px;
    color: #94a3b8;
    opacity: 0.7;
    z-index: 10;
    pointer-events: none;
}

[data-theme="dark"] .copyright-footer {
    color: #64748b;
}

.hidden {
    display: none !important;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center between header and island */
    padding-top: 100px;
    padding-bottom: 250px;
    /* Provides space for scrolls but centers when small */
    width: 100%;
    box-sizing: border-box;
    min-height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Spinner Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(220, 38, 38, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.loader {
    border: 4px solid rgba(128, 128, 128, 0.2);
    border-left-color: var(--btn-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center the single button */
    gap: 12px;
    margin-top: 24px;
}

.crossword-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.clue-display-box {
    flex: 0 0 100%;
    width: 100%;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-bg);
    padding: 12px 28px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--panel-border);
    z-index: 21;
}
.clue-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.8;
}

.logo-icon.small {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

.logo-text.small {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-color);
}

[data-theme="dark"] .clue-display-box {
    background: var(--letter-bg);
}

.clue-display-box.hidden {
    display: none;
}

/* Grid & Celler */

/* Grid & Celler */
.grid-header {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    margin-bottom: 8px;
    height: 20px;
}

.solved-status {
    color: #16a34a;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.solve-message {
    color: #16a34a;
    font-weight: 800;
}

.grid {
    display: grid;
    gap: 1px;
    background-color: #000000;
    /* Back to black as requested */
    border: 1px solid #000000;
    width: fit-content;
    margin: 0 auto;
    position: relative;
    border-radius: 0;
    /* Force pixel-perfect snapping */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

[data-theme="dark"] .grid {
    background-color: var(--border-color);
    border-color: var(--border-color);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: var(--letter-bg);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    overflow: hidden;
}

.cell:not(.empty):not(.image-overlay) {
    z-index: 2;
}

/* Tomma celler helt osynliga */
.cell.empty {
    visibility: hidden;
    pointer-events: none;
}

/* Spelbara Celler - Borders hanteras nu av JavaScript! */
.cell.clue-box {
    background-color: var(--clue-bg);
    color: var(--clue-text);
    flex-direction: column;
    cursor: default;
    z-index: 2;
    font-family: 'Outfit', sans-serif;
}

.clue-top,
.clue-bottom {
    width: 100%;
    height: 50% !important;
    /* Enforce 50% height */
    flex: none;
    /* Disable flex growth */
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.clue-top {
    border-bottom: 1px solid var(--border-color);
}

.clue-single {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    /* Slightly less padding to fit more text */
    box-sizing: border-box;
    overflow: hidden;
}

.clue-text {
    font-size: calc(var(--cell-size) * 0.18);
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: pre-line;
    pointer-events: none;

    /* Ellipsis truncation */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    max-height: 100%;
}

.clue-top .clue-text,
.clue-bottom .clue-text {
    -webkit-line-clamp: 2;
    /* Truncate after 2 lines in half cells */
    line-clamp: 2;
}

.clue-single .clue-text {
    -webkit-line-clamp: 4;
    /* Truncate after 4 lines in full cells */
    line-clamp: 4;
}

.cell.letter {
    background-color: var(--letter-bg);
    z-index: 2;
}

.cell.letter input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: calc(var(--cell-size) * 0.55);
    font-weight: bold;
    font-family: 'Kalam', cursive;
    background: transparent;
    color: var(--text-color);
    text-transform: uppercase;
    outline: none;
    cursor: default;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    caret-color: transparent;
}

.cell.letter input.correct {
    color: #22c55e;
}

.cell.letter input.wrong {
    color: #ef4444;
}

.cell.image-word {
    background-color: var(--light-color);
}

[data-theme="dark"] .cell.image-word {
    background-color: #111d33;
    /* Darker navy, distinct from the active color */
}

.cell.image-word input {
    background-color: transparent !important;
}

.active-word {
    background-color: var(--active-word) !important;
}

.active-cell {
    background-color: var(--active-cell) !important;
}

/* Custom colors for image-word when active */
.cell.image-word.active-word {
    background-color: #fecaca !important;
    /* Softer pink than #fca5a5 */
}

.cell.image-word.active-cell {
    background-color: #f87171 !important;
    /* Softer red than #dc2626 */
}

[data-theme="dark"] .cell.image-word.active-word {
    background-color: #334a8a !important;
    /* Slightly lighter navy */
}

[data-theme="dark"] .cell.image-word.active-cell {
    background-color: var(--primary-color) !important;
    /* Use dark-mode blue #3b82f6 */
}

/* Arrow Cells */
.cell.arrow,
.cell.arrow.active-word,
.cell.arrow.active-cell,
[data-theme="dark"] .cell.arrow,
[data-theme="dark"] .cell.arrow.active-word,
[data-theme="dark"] .cell.arrow.active-cell {
    background-color: var(--letter-bg) !important;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell-arrow-icon-container {
    width: 65%;
    height: 65%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.cell-arrow-icon {
    font-size: calc(var(--cell-size) * 0.6);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell-arrow-svg {
    width: 100%;
    height: 100%;
}

.cell.arrow .arrow-rotated {
    transform: rotate(90deg);
}


.danger-btn {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.danger-btn:hover {
    background-color: var(--hover-color) !important;
}

/* Markers (Triangles in top-right corner) */
.cell.checked-correct:not(.revealed)::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-top: calc(var(--cell-size) * 0.33) solid #22c55e;
    /* Green */
    border-left: calc(var(--cell-size) * 0.33) solid transparent;
    pointer-events: none;
    z-index: 5;
}

.cell.checked-wrong::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-top: calc(var(--cell-size) * 0.33) solid #ef4444;
    /* Red */
    border-left: calc(var(--cell-size) * 0.33) solid transparent;
    pointer-events: none;
    z-index: 5;
}

/* Revealed Marker (Yellow triangle) takes precedence over checkmark */
.cell.revealed::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-top: calc(var(--cell-size) * 0.33) solid #facc15;
    /* Yellow */
    border-left: calc(var(--cell-size) * 0.33) solid transparent;
    pointer-events: none;
    z-index: 6;
}

/* Bilder och Osynliga Border-overlays */
.image-box {
    background-size: cover;
    background-position: center;
    z-index: 50;
    /* Base layering for image */
    position: relative;
    outline: 1px solid var(--border-color);
    /* Matches other cells */
}

.cell.image-overlay {
    background: transparent;
    pointer-events: none;
    z-index: 101;
}

.image-arrow {
    position: absolute;
    background: var(--primary-color);
    color: white;
    font-weight: bold;
    font-size: 16px;
    width: 20px;
    height: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 1px;
    /* Nudge to the right for better visual centering */
    border-radius: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 200;
    pointer-events: none;
    user-select: none;
    /* Always on top of everything */
}

.arrow-across {
    bottom: 4px;
    right: -10px;
    z-index: 11;
}

.arrow-down {
    bottom: -10px;
    right: 4px;
    z-index: 11;
}

.arrow-rotated {
    display: inline-block;
    transform: rotate(90deg);
}

/* Flytande Kontrollpanel (Sleek Island) */
.controls-container {
    position: fixed;
    bottom: calc(25px + var(--keyboard-offset, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 0;
    padding: 0;
    /* No padding here so header can touch edges */
    box-shadow: 0 10px 40px var(--shadow-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2000;
    overflow: hidden;
    /* Clips the clue header to radius */
    width: fit-content;
    max-width: 95vw;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

/* Visibility Utilities */
.mobile-only {
    display: none; /* Hidden on desktop */
}

@media (max-width: 900px) {
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: flex; /* Show on mobile */
    }
    .mobile-only.hidden {
        display: none !important;
    }
}

.controls-content {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.controls-container.hidden-by-footer {
    pointer-events: none;
    transform: translateX(-50%) translateY(200px);
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: auto;
    padding: 16px 14px;
    box-sizing: border-box;
    flex-wrap: wrap;
    /* Allow grouping to wrap on small mobile */
}

.controls-row:first-of-type {
    padding-top: 16px;
}

.controls-row.bottom-bar {
    padding-bottom: 16px;
    padding-top: 0;
}

.btn-group { background: transparent; border: 1px solid var(--panel-border); border-radius: 0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .btn-group {
    background: rgba(30, 41, 59, 0.4);
}

.group-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--clue-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 4px;
    opacity: 0.6;
}

.bottom-bar {
    justify-content: space-between;
    padding: 8px 16px;
    margin-top: 12px;
    width: 100%;
    box-sizing: border-box;
}

.main-action-btn { border-radius: 0;
    font-weight: 700 !important;
    padding: 10px 20px;
    font-size: 14px;
    white-space: nowrap;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--panel-border);
    margin: 0 5px;
}

button { padding: 8px 16px; font-size: 13px; font-family: inherit; cursor: pointer; border: none; border-radius: 0;
    font-weight: bold;
    transition: all 0.2s;
}

.tool-btn {
    background: var(--btn-tool);
    color: white;
    min-width: 100px; /* Equal width for Bokstav, Ord, Hela */
    justify-content: center;
}

.tool-btn:hover {
    background: var(--btn-tool-hover);
}

.reveal-btn {
    background: var(--btn-reveal);
    color: white;
    min-width: 100px; /* Match tool-btn width */
    justify-content: center;
}

.reveal-btn:hover {
    background: var(--btn-reveal-hover);
}

.primary-btn { background: var(--btn-primary); color: white; padding: 12px 28px; font-size: 18px; border-radius: 0;
}

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

.share-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.share-btn {
    background: var(--share-btn-bg);
    color: var(--share-btn-text);
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 0;
    transition: filter 0.2s;
}

.share-btn:hover {
    filter: brightness(0.9);
}

.icon-btn {
    background: transparent;
    font-size: 20px;
    padding: 4px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

#themeToggle {
    background-color: var(--letter-bg) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--panel-border);
    border-radius: 0;
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.2s ease, filter 0.2s ease;
}

#themeToggle svg {
    display: block;
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

#themeToggle:hover {
    background-color: var(--letter-bg) !important;
    filter: brightness(0.9);
}

[data-theme="dark"] #themeToggle {
    background-color: var(--letter-bg) !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] #themeToggle:hover {
    filter: brightness(1.2);
}

.icon-btn:hover {
    background: rgba(128, 128, 128, 0.2);
}

#statusMessage {
    font-weight: bold;
    font-size: 15px;
    opacity: 0.9;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
    width: 100%;
}

.modal-actions button {
    width: 100% !important;
    padding: 14px 20px !important;
    font-size: 15px !important;
}

.highlight-count {
    font-weight: bold;
    color: var(--primary);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    pointer-events: none;
    opacity: 0;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--modal-bg);
    padding: 40px;
    border-radius: 0;
    box-shadow: 0 20px 50px var(--shadow-color);
    max-width: 450px;
    width: 90%;
    text-align: center;
    z-index: 2001;
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-x {
    position: absolute;
    top: 20px;
    right: 24px;
    font-size: 28px;
    color: var(--clue-text);
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

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

.modal h2 {
    margin-top: 0;
    font-size: 28px;
    color: var(--primary-color);
}

.modal p {
    font-size: 16px;
    margin-bottom: 30px;
    color: var(--clue-text);
}

.modal-buttons {
    display: flex;
    margin-top: 24px;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 0;
    font-size: 15px;
    font-weight: 600;
    z-index: 5000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive Refinement: Docked Sticky Footer (Tiered) */
@media (max-width: 1400px) {
    .controls-container {
        position: fixed;
        bottom: var(--keyboard-offset, 0px);
        left: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        background: var(--panel-bg);
        backdrop-filter: blur(20px);
        box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.15);
        padding: 0;
        z-index: 3000;
        display: block;
    }

    .controls-container.hidden-by-footer {
        transform: translateY(200px);
    }

    .controls-content {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
        margin: 0 auto;
        padding: 0;
        min-height: auto;
    }

    .clue-display-box {
        flex: 0 0 100%;
        width: 100%;
        height: auto;
        min-height: 40px; /* Reduced for mobile */
        background: rgba(0, 0, 0, 0.03);
        border-bottom: 1px solid var(--panel-border);
        border-right: none;
        padding: 8px 16px; /* Reduced for mobile */
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    [data-theme="dark"] .clue-display-box {
        background: rgba(255, 255, 255, 0.05);
    }

    .clue-display-box .clue-text {
        font-size: 14px; /* Slightly smaller */
        text-align: center;
        width: 100%;
    }

    .controls-row {
        width: auto;
        display: flex;
        flex-direction: row;
        justify-content: center;
        padding: 10px 12px;
        gap: 8px;
        box-sizing: border-box;
    }

    .controls-row.bottom-bar {
        padding-top: 0;
        padding-bottom: 14px;
    }

    .btn-group {
        padding: 8px 16px;
        border-radius: 0;
        gap: 12px;
        flex-direction: row;
        align-items: center;
    }

    .main-wrapper {
        padding-bottom: 150px;
    }
}

/* Small Mobile: Compact Hierarchical Menu */
@media (max-width: 900px) {
    .controls-container {
        display: flex;
        flex-direction: column !important;
        align-items: stretch;
    }

    .controls-content {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 0;
    }

    /* Hierarchical buttons layout - Increased specificity */
    .controls-container .controls-main, 
    .controls-container .controls-sub {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        width: 100%;
        min-height: 60px;
    }

    .controls-container .main-nav-btn {
        flex: 1 1 0;
        padding: 0 12px;
        height: 44px !important; /* More compact height */
        font-size: 15px;
        font-weight: 700;
        border-radius: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .controls-container .sub-check-btn, 
    .controls-container .sub-reveal-btn {
        flex: 2; /* Take more space relative to back arrow */
        height: 44px !important; /* Match main buttons precisely */
        padding: 0 4px;
        font-size: 15px; /* Same font size as main buttons */
        border-radius: 0;
        color: white;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .controls-container .sub-check-btn {
        background: var(--btn-tool);
    }

    .controls-container .sub-reveal-btn {
        background: var(--btn-reveal);
    }

    .controls-container .controls-sub {
        justify-content: flex-start;
        gap: 12px;
    }

    .controls-container .sub-btn-group {
        display: flex;
        flex: 1;
        gap: 6px;
        justify-content: center;
    }

    .clue-display-box {
        width: 100%;
        min-height: 40px; 
        padding: 8px 16px;
        border-bottom: 1px solid var(--panel-border);
    }

    .clue-display-box .clue-text {
        font-size: 14px;
        line-height: 1.3;
        text-align: center;
        width: 100%;
    }

    .back-btn {
        width: 44px;
        height: 44px;
        padding: 10px;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 50%;
        flex-shrink: 0;
    }

    [data-theme="dark"] .back-btn {
        background: rgba(255, 255, 255, 0.1);
        color: white !important;
    }

    .main-wrapper {
        padding-bottom: 150px;
    }
}

/* Landing Page Responsive Overrides */
@media (max-width: 900px) {
    .nav-container {
        padding: 0 1.5rem;
    }

    .hero-container {
        flex-direction: column;
        text-align: center;
        margin-top: 80px;
        margin-bottom: 40px;
        min-height: auto;
        gap: 2rem;
        width: 100%;
        overflow: hidden;
    }

    .hero-content {
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .hero-description {
        margin-left: auto;
        margin-right: auto;
        font-size: 1.1rem;
        max-width: 90%;
    }

    .hero-features {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin: 0 auto 2.5rem;
        padding: 0;
        width: 100%;
        max-width: 400px;
        gap: 1.5rem;
    }

    .hero-features li {
        min-height: auto;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        text-align: center;
    }

    .feature-label {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
    }

    .hero-features li span:first-child {
        flex-shrink: 0;
        width: auto;
    }

    .hero-features li strong {
        display: inline;
        font-size: 1.1rem;
        margin: 0;
    }

    .hero-feature-desc {
        display: block;
        opacity: 0.8;
        font-size: 1rem;
        white-space: normal;
        margin: 0;
    }

    #generateBtn {
        width: auto;
        max-width: 90%;
    }

    .hero-visual {
        display: none;
        /* Hide preview images on small screens */
    }

    /* Grid Section (OM and FAQ) Responsive */
    .grid-section {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        margin: 60px auto;
    }

    .section-title {
        font-size: 2rem;
        text-align: center;
        position: static !important;
        margin-bottom: 1.5rem;
    }

    .footer-container {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2rem;
    }

    .footer-info p {
        margin-left: auto;
        margin-right: auto;
    }

    .footer-links {
        align-items: center;
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .bottom-line {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .branding {
        padding: 0.75rem 0;
    }

    .nav-left {
        gap: 12px;
    }

    .logo-text {
        font-size: 1.2rem;
    }

    .main-action-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .static-info-card {
        padding: 1.5rem;
    }
}

/* Responsive Zoom: Start zoomed-in on very small screens */
@media (max-width: 600px) {
    :root {
        --cell-size: clamp(30px, 8vw, 50px);
        /* Zoomed in by default */
    }

    .main-wrapper {
        padding-top: 80px;
        padding-bottom: 220px;
        align-items: flex-start;
        /* Align to top-left for better scrolling start */
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .grid {
        margin: 0;
        /* Don't center when zoomed in to avoid weird scroll start */
    }
}








