/* NorskKryss Web Game Stylesheet */

/* CSS Custom Properties */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #60a5fa;
    --secondary: #f97316;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;

    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --cell-size: 36px;
    --grid-gap: 2px;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;

        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;

        --border-color: #475569;
    }
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem;
    text-align: center;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.android-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 50px;
    color: #1e3a5f;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

.android-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.app-cta-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
}

.app-benefits-small {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: white;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: white;
    color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.tagline {
    margin-top: 0.25rem;
    opacity: 0.9;
    font-size: 0.875rem;
    text-align: left;
}

/* Ad Containers */
.ad-container {
    max-width: 800px;
    margin: 1rem auto;
    padding: 0 1rem;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide ads when disabled */
.ads-disabled .ad-container,
.ads-disabled .ad-overlay,
.ads-disabled #hintBtn {
    display: none !important;
}

.ad-top {
    margin-top: 0.5rem;
}

.ad-bottom {
    margin-bottom: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
}

/* Section Titles */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Difficulty Section */
.difficulty-section {
    margin-bottom: 1.5rem;
}

.difficulty-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.difficulty-btn {
    flex: 1;
    min-width: 100px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
}

.difficulty-btn:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.difficulty-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.05) 100%);
}

.difficulty-icon {
    font-size: 1.5rem;
}

.difficulty-label {
    font-weight: 600;
    color: var(--text-primary);
}

.difficulty-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Game Section */
.game-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
    margin-bottom: 1.5rem;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
    border-radius: var(--border-radius-lg);
}

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

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

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

/* Crossword Grid */
.grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding: 0.5rem;
}

.crossword-grid {
    display: grid;
    grid-template-columns: repeat(10, var(--cell-size));
    grid-template-rows: repeat(10, var(--cell-size));
    gap: var(--grid-gap);
    background: var(--text-primary);
    padding: var(--grid-gap);
    border-radius: 4px;
}

.grid-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--bg-primary);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.grid-cell.blocked {
    background: var(--text-primary);
    cursor: default;
}

.grid-cell.selected {
    background: var(--primary);
    color: white;
}

.grid-cell.current-word {
    background: var(--primary-light);
    color: white;
}

.grid-cell.correct {
    background: var(--success);
    color: white;
}

.grid-cell.incorrect {
    background: var(--error);
    color: white;
}

.grid-cell.revealed {
    animation: revealPulse 1s ease;
}

@keyframes revealPulse {
    0% { background: var(--warning); transform: scale(1.1); }
    50% { background: var(--success); }
    100% { background: var(--bg-primary); transform: scale(1); }
}

.grid-cell .cell-number {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 0.5rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1;
}

.grid-cell.selected .cell-number,
.grid-cell.current-word .cell-number {
    color: rgba(255, 255, 255, 0.8);
}

.grid-cell input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

/* Clue Display */
.clue-display {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.clue-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.clue-number {
    background: var(--primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
}

.clue-direction {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.clue-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    min-width: 100px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.action-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.action-btn.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.action-btn.disabled:hover {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

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

.btn-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
}

.btn-subtext {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1f2937;
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

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

.btn-icon {
    font-size: 1.5rem;
}

/* Instructions Section */
.instructions-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.instructions-list {
    list-style: none;
    display: grid;
    gap: 0.5rem;
}

.instructions-list li {
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

.instructions-list li::before {
    content: "\2022";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

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

/* About Section */
.about-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.about-section p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.about-section p:last-of-type {
    margin-bottom: 1rem;
}

.app-link {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.app-link:hover {
    text-decoration: underline;
}

/* Footer */
.footer {
    background: var(--bg-tertiary);
    padding: 1.5rem 1rem;
    text-align: center;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
}

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

.copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    max-width: 450px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

.modal-body {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-body .result-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.modal-body .result-text {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.modal-body .result-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
}

.modal-body .stat {
    text-align: center;
}

.modal-body .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-body .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Grids Container in Modal */
.grids-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

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

.grid-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Mini Grid in Modal */
.mini-grid {
    display: grid;
    grid-template-columns: repeat(10, 18px);
    grid-template-rows: repeat(10, 18px);
    gap: 1px;
    background: var(--text-primary);
    padding: 1px;
    border-radius: 4px;
}

.mini-cell {
    width: 18px;
    height: 18px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
}

.mini-cell.blocked {
    background: var(--text-primary);
}

.mini-cell.correct {
    background: var(--success);
    color: white;
}

.mini-cell.incorrect {
    background: var(--error);
    color: white;
}

/* Modal App Promo */
.modal-app-promo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.modal-app-promo .promo-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.modal-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    border-radius: 50px;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s, transform 0.2s;
}

.modal-play-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-actions .action-btn {
    flex: 1;
}

/* Responsive Design */
@media (max-width: 600px) {
    :root {
        --cell-size: 32px;
    }

    .header {
        padding: 0.75rem;
    }

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

    .main-content {
        padding: 0.75rem;
    }

    .game-section {
        padding: 1rem;
    }

    .difficulty-buttons {
        flex-direction: column;
    }

    .difficulty-btn {
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
        gap: 0.75rem;
    }

    .difficulty-icon {
        font-size: 1.25rem;
    }

    .action-buttons {
        flex-direction: column;
    }

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

@media (max-width: 400px) {
    :root {
        --cell-size: 28px;
    }
}

/* Rewarded Ad Overlay */
.ad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.ad-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ad-overlay-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    max-width: 350px;
    width: 100%;
    text-align: center;
}

.ad-overlay-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.ad-overlay-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    min-height: 250px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.ad-countdown {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.ad-close-btn {
    width: 100%;
}

.ad-close-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Print Styles */
@media print {
    .ad-container,
    .header,
    .footer,
    .action-buttons,
    .difficulty-section,
    .ad-overlay {
        display: none;
    }

    .game-section {
        box-shadow: none;
        padding: 0;
    }
}
