/* View: crossword ─────────────────────────────────────────────────────── */

.cw-page {
    font-family: 'Roboto Mono', 'Courier New', monospace;
    color: #33ff33;
    min-height: 100vh;
    padding: 1.5rem 1rem 5rem;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.cw-header {
    text-align: center;
    margin-bottom: 1.25rem;
}

.cw-header h1 {
    font-size: clamp(1.1rem, 4vw, 1.6rem);
    color: #33ff33;
    text-shadow: 0 0 12px rgba(51, 255, 51, 0.45);
    letter-spacing: 0.1em;
    margin: 0;
}

.cw-subtitle {
    color: rgba(51, 255, 51, 0.45);
    font-size: 0.75rem;
    margin-top: 0.3rem;
    letter-spacing: 0.05em;
}

/* ── Loader panel ───────────────────────────────────────────────────────── */

.cw-loader {
    max-width: 680px;
    margin: 0 auto 1.5rem;
    border: 1px solid rgba(51, 255, 51, 0.28);
    border-radius: 6px;
    background: rgba(51, 255, 51, 0.025);
    overflow: hidden;
}

.cw-tabs {
    display: flex;
    border-bottom: 1px solid rgba(51, 255, 51, 0.28);
}

.cw-tab {
    flex: 1;
    padding: 0.55rem 0.4rem;
    background: transparent;
    border: none;
    border-right: 1px solid rgba(51, 255, 51, 0.15);
    color: rgba(51, 255, 51, 0.45);
    font-family: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.15s;
}

.cw-tab:last-child { border-right: none; }

.cw-tab:hover {
    color: #33ff33;
    background: rgba(51, 255, 51, 0.06);
}

.cw-tab--active {
    color: #33ff33;
    background: rgba(51, 255, 51, 0.08);
    border-bottom: 2px solid #33ff33;
    margin-bottom: -1px;
}

.cw-tab-panel { display: none; padding: 0.9rem 1rem; }
.cw-tab-panel--active { display: block; }

.cw-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.cw-input {
    flex: 1;
    min-width: 140px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(51, 255, 51, 0.35);
    color: #33ff33;
    font-family: inherit;
    font-size: 0.82rem;
    padding: 0.42rem 0.65rem;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.15s;
}

.cw-input:focus {
    border-color: #33ff33;
    box-shadow: 0 0 6px rgba(51, 255, 51, 0.18);
}

input[type="date"].cw-input::-webkit-calendar-picker-indicator {
    filter: invert(0.7) sepia(1) hue-rotate(90deg) saturate(3);
    cursor: pointer;
}

.cw-textarea {
    display: block;
    width: 100%;
    min-height: 90px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(51, 255, 51, 0.35);
    color: #33ff33;
    font-family: inherit;
    font-size: 0.75rem;
    padding: 0.55rem 0.7rem;
    border-radius: 4px;
    resize: vertical;
    margin-bottom: 0.6rem;
    outline: none;
    scrollbar-color: rgba(51, 255, 51, 0.4) transparent;
    scrollbar-width: thin;
}

.cw-textarea:focus { border-color: #33ff33; }

.cw-btn {
    background: transparent;
    border: 1px solid rgba(51, 255, 51, 0.4);
    color: rgba(51, 255, 51, 0.8);
    font-family: inherit;
    font-size: 0.75rem;
    padding: 0.42rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: 0.04em;
    transition: all 0.15s;
}

.cw-btn:hover {
    border-color: #33ff33;
    color: #33ff33;
    background: rgba(51, 255, 51, 0.07);
}

.cw-btn--primary {
    border-color: #33ff33;
    color: #33ff33;
}

.cw-btn--primary:hover {
    background: rgba(51, 255, 51, 0.12);
    box-shadow: 0 0 8px rgba(51, 255, 51, 0.22);
}

.cw-btn--reveal {
    border-color: rgba(230, 34, 197, 0.45);
    color: rgba(230, 34, 197, 0.8);
}

.cw-btn--reveal:hover {
    border-color: #e622c5;
    color: #e622c5;
    background: rgba(230, 34, 197, 0.07);
}

.cw-btn--active {
    background: rgba(51, 255, 51, 0.1);
    border-color: #33ff33;
    color: #33ff33;
    box-shadow: 0 0 6px rgba(51, 255, 51, 0.18);
}

.cw-note {
    margin-top: 0.55rem;
    font-size: 0.66rem;
    color: rgba(51, 255, 51, 0.38);
    line-height: 1.55;
}

.cw-file-label {
    display: inline-block;
    padding: 0.42rem 0.8rem;
    border: 1px solid rgba(51, 255, 51, 0.4);
    color: rgba(51, 255, 51, 0.8);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s;
}

.cw-file-label:hover {
    border-color: #33ff33;
    color: #33ff33;
    background: rgba(51, 255, 51, 0.07);
}

.cw-file-input { display: none; }

.cw-file-name {
    font-size: 0.72rem;
    color: rgba(51, 255, 51, 0.55);
    margin-left: 0.6rem;
}

.cw-loader-status {
    padding: 0.3rem 1rem 0.5rem;
    font-size: 0.75rem;
    color: rgba(51, 255, 51, 0.65);
    min-height: 1.4rem;
    letter-spacing: 0.03em;
}

.cw-loader-status--err { color: #ff4444; }

/* ── Active clue bar ────────────────────────────────────────────────────── */

.cw-active-clue {
    max-width: 1060px;
    margin: 0 auto 0.85rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid rgba(230, 34, 197, 0.3);
    border-radius: 5px;
    background: rgba(230, 34, 197, 0.04);
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    flex-wrap: wrap;
    font-size: 0.88rem;
    line-height: 1.4;
    min-height: 2.4rem;
}

.cw-active-clue-dir {
    font-size: 0.6rem;
    color: #e622c5;
    border: 1px solid rgba(230, 34, 197, 0.5);
    padding: 0.1rem 0.38rem;
    border-radius: 3px;
    letter-spacing: 0.1em;
    white-space: nowrap;
    flex-shrink: 0;
}

.cw-active-clue-num {
    color: #e622c5;
    font-weight: 700;
    white-space: nowrap;
}

.cw-active-clue-text { color: #33ff33; }

/* ── Puzzle area ────────────────────────────────────────────────────────── */

.cw-puzzle {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    max-width: 1060px;
    margin: 0 auto;
}

.cw-puzzle-info {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.78rem;
    color: rgba(51, 255, 51, 0.6);
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid rgba(51, 255, 51, 0.12);
    margin-bottom: 0.25rem;
    line-height: 1.6;
}

.cw-info-title {
    color: #33ff33;
    font-weight: 700;
}

.cw-info-sep {
    color: rgba(51, 255, 51, 0.28);
    margin: 0 0.45rem;
}

/* ── Grid column ────────────────────────────────────────────────────────── */

.cw-grid-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Grid ───────────────────────────────────────────────────────────────── */

.cw-grid {
    display: grid;
    gap: 2px;
    background: rgba(51, 255, 51, 0.55);
    padding: 3px;
    border: 2px solid #33ff33;
    box-shadow: 0 0 18px rgba(51, 255, 51, 0.12), inset 0 0 8px rgba(0, 0, 0, 0.5);
    margin-bottom: 1rem;
    max-width: 95vw;
    overflow: auto;
}

.cw-cell {
    position: relative;
    background: #040c04;
    border: 1px solid rgba(51, 255, 51, 0.1);
}

.cw-cell--black  { background: #33ff33; }
.cw-cell--highlight { background: #081808; }
.cw-cell--cursor    { background: #0e3010; box-shadow: inset 0 0 6px rgba(51, 255, 51, 0.35); }

.cw-cell--incorrect {
    background: #200606;
    animation: cw-flash 0.4s ease;
}

.cw-cell--correct { background: #050f05; }

.cw-cell--revealed { background: #0d0520; }

@keyframes cw-flash {
    0%, 100% { background: #200606; }
    50%       { background: #400a0a; }
}

.cw-cell-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: #33ff33;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    padding: 0;
    caret-color: transparent;
    cursor: pointer;
    z-index: 1;
}

.cw-cell-input--pencil {
    color: rgba(51, 255, 51, 0.4);
    font-style: italic;
    font-weight: 400;
}

.cw-cell--revealed .cw-cell-input {
    color: #e622c5;
    text-shadow: 0 0 4px rgba(230, 34, 197, 0.4);
}

.cw-cell--incorrect .cw-cell-input { color: #ff5555; }

.cw-cell-num {
    position: absolute;
    top: 1px;
    left: 2px;
    color: rgba(51, 255, 51, 0.65);
    line-height: 1;
    pointer-events: none;
    z-index: 2;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 400;
}

/* ── Controls ───────────────────────────────────────────────────────────── */

.cw-controls {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    width: 100%;
    max-width: 580px;
}

.cw-controls-row {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── Timer + status ─────────────────────────────────────────────────────── */

.cw-status-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    max-width: 580px;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(51, 255, 51, 0.12);
    border-radius: 4px;
    background: rgba(51, 255, 51, 0.02);
}

.cw-timer {
    font-size: 1.05rem;
    font-weight: 700;
    color: #e622c5;
    text-shadow: 0 0 8px rgba(230, 34, 197, 0.4);
    letter-spacing: 0.12em;
    min-width: 4.5ch;
}

.cw-status {
    font-size: 0.74rem;
    color: rgba(51, 255, 51, 0.6);
    letter-spacing: 0.05em;
}

/* ── Clues column ───────────────────────────────────────────────────────── */

.cw-clues-col {
    overflow: hidden;
}

.cw-clues-section {
    margin-bottom: 1.1rem;
}

.cw-clues-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: #e622c5;
    text-shadow: 0 0 6px rgba(230, 34, 197, 0.3);
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(230, 34, 197, 0.28);
    margin-bottom: 0.4rem;
}

.cw-clues-list {
    max-height: 38vh;
    overflow-y: auto;
    scrollbar-color: rgba(51, 255, 51, 0.35) transparent;
    scrollbar-width: thin;
}

.cw-clues-list::-webkit-scrollbar         { width: 4px; }
.cw-clues-list::-webkit-scrollbar-thumb   { background: rgba(51, 255, 51, 0.32); border-radius: 2px; }

.cw-clue {
    padding: 0.35rem 0.6rem 0.35rem 0.8rem;
    border-left: 2px solid rgba(51, 255, 51, 0.1);
    font-size: 0.78rem;
    line-height: 1.45;
    cursor: pointer;
    color: rgba(51, 255, 51, 0.62);
    transition: all 0.12s;
    margin-bottom: 1px;
    border-radius: 0 3px 3px 0;
}

.cw-clue:hover {
    background: rgba(51, 255, 51, 0.05);
    border-left-color: rgba(51, 255, 51, 0.5);
    color: #33ff33;
}

.cw-clue--active {
    background: rgba(51, 255, 51, 0.08);
    border-left-color: #33ff33;
    color: #33ff33;
}

.cw-clue-num {
    font-weight: 700;
    color: #33ff33;
    margin-right: 0.15rem;
}

/* ── Desktop: side-by-side layout ───────────────────────────────────────── */

@media (min-width: 820px) {
    .cw-puzzle {
        grid-template-columns: auto minmax(280px, 360px);
        align-items: start;
    }

    .cw-puzzle-info {
        grid-column: 1 / -1;
    }

    .cw-clues-col {
        position: sticky;
        top: 70px;
    }

    .cw-clues-list {
        max-height: calc(100vh - 240px);
    }
}

@media (min-width: 1060px) {
    .cw-puzzle {
        grid-template-columns: auto 380px;
    }
}

/* ── Mobile tweaks ──────────────────────────────────────────────────────── */

@media (max-width: 500px) {
    .cw-page { padding: 1rem 0.5rem 4rem; }

    .cw-btn {
        font-size: 0.68rem;
        padding: 0.38rem 0.55rem;
    }

    .cw-clues-list { max-height: 30vh; }
}
