.html5-crossword {
    --cw-bg: var(--surface, #ffffff);
    --cw-text: var(--text, #17202a);
    --cw-muted: #667085;
    --cw-border: #d8e0e8;
    --cw-panel: #f7fafc;
    --cw-accent: var(--accent, #15616d);
    --cw-accent-alt: var(--accent-alt, #e76f51);
    --cw-danger: #b42318;
    --cw-success: #067647;
    --board-size: 440px;
    display: block;
    width: 100%;
    color: var(--cw-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.html5-crossword,
.html5-crossword * {
    box-sizing: border-box;
}

.html5-crossword button {
    font: inherit;
}

.html5-crossword-game {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(280px, 360px);
    gap: 18px;
    align-items: stretch;
    width: 100%;
}

.html5-crossword-stage,
.html5-crossword-side {
    border: 1px solid rgba(15, 23, 42, .10);
    border-radius: 8px;
    background: var(--cw-bg);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

.html5-crossword-stage {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    overflow: hidden;
}

.html5-crossword-topbar {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    min-height: 88px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--cw-border);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.html5-crossword-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--cw-accent);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.html5-crossword-clue {
    max-width: 760px;
    margin: 0;
    color: #1f2937;
    font-size: 17px;
    line-height: 1.35;
}

.html5-crossword-clue b {
    font-weight: 800;
}

.html5-crossword-timer {
    min-width: 92px;
    padding: 8px 10px;
    border: 1px solid var(--cw-border);
    border-radius: 8px;
    background: #fff;
    color: #111827;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 18px;
    font-weight: 900;
    text-align: center;
}

.html5-crossword-board-shell {
    display: grid;
    place-items: center;
    min-height: min(72vh, 660px);
    padding: 18px;
    background:
        linear-gradient(90deg, rgba(21, 97, 109, .06) 1px, transparent 1px),
        linear-gradient(180deg, rgba(21, 97, 109, .06) 1px, transparent 1px),
        #eef5f8;
    background-size: 30px 30px;
}

.html5-crossword-board {
    position: relative;
    display: grid;
    place-items: center;
    width: var(--board-size);
    height: var(--board-size);
    max-width: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #e7eef5;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08), 0 20px 50px rgba(15, 23, 42, .14);
}

.html5-crossword canvas {
    position: absolute;
    inset: 0;
    z-index: 4;
    border-radius: 8px;
    background: transparent;
    transition: transform .18s ease, filter .18s ease;
}

.html5-crossword-board:focus-within canvas,
.html5-crossword-board:hover canvas {
    filter: saturate(1.04);
}

.html5-crossword-clue2 {
    position: absolute;
    z-index: 20;
    top: 12px;
    right: 12px;
    left: 12px;
    padding: 11px 12px;
    border-radius: 8px;
    background: rgba(17, 24, 39, .88);
    color: #fff;
    font-size: 14px;
    line-height: 1.35;
    transform: translateY(0);
    transition: transform .2s ease, opacity .2s ease;
}

.html5-crossword-clue2.hide {
    opacity: 0;
    transform: translateY(-16px);
    pointer-events: none;
}

.html5-crossword-overlay {
    position: absolute;
    inset: 0;
    z-index: 650;
    background: rgba(15, 23, 42, .52);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}

.html5-crossword-options {
    position: absolute;
    z-index: 700;
    top: 50%;
    left: 50%;
    width: min(360px, calc(100% - 32px));
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, .36);
    border-radius: 8px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
    opacity: 0;
    transform: translate(-50%, -46%) scale(.98);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

.html5-crossword.confirm .html5-crossword-overlay,
.html5-crossword.show-modal .html5-crossword-overlay {
    opacity: 1;
    pointer-events: auto;
}

.html5-crossword.confirm .html5-crossword-options,
.html5-crossword.show-modal .html5-crossword-options {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.html5-crossword-confirm,
.html5-crossword-modal {
    display: none;
}

.html5-crossword.confirm .html5-crossword-confirm,
.html5-crossword.show-modal .html5-crossword-modal {
    display: block;
}

.html5-crossword-options h3 {
    margin: 0 0 8px;
    font-size: 22px;
    letter-spacing: 0;
}

.html5-crossword-options p {
    margin: 0 0 16px;
    color: var(--cw-muted);
}

.html5-crossword-confirm-actions,
.html5-crossword-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.html5-crossword-confirm-actions button,
.html5-crossword-modal button,
.html5-crossword-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 14px;
    border: 1px solid var(--cw-border);
    border-radius: 8px;
    background: #fff;
    color: var(--cw-text);
    font-weight: 900;
    cursor: pointer;
    transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.html5-crossword-confirm-actions button:hover,
.html5-crossword-modal button:hover,
.html5-crossword-btn:hover {
    border-color: var(--cw-accent);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, .08);
}

.html5-crossword-btn.primary {
    border-color: var(--cw-accent);
    background: var(--cw-accent);
    color: #fff;
}

.html5-crossword-btn.danger,
.html5-crossword-yes {
    border-color: var(--cw-danger);
    background: var(--cw-danger);
    color: #fff;
}

.html5-crossword-no {
    border-color: var(--cw-border);
    background: #fff;
    color: var(--cw-text);
}

.html5-crossword-side {
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 16px;
    min-width: 0;
}

.html5-crossword-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.html5-crossword-stats div,
.html5-crossword-progress-card,
.html5-crossword-clue-bank {
    border: 1px solid var(--cw-border);
    border-radius: 8px;
    background: var(--cw-panel);
}

.html5-crossword-stats div {
    padding: 12px;
}

.html5-crossword-stats strong {
    display: block;
    font-size: 24px;
    line-height: 1;
}

.html5-crossword-stats span {
    display: block;
    margin-top: 5px;
    color: var(--cw-muted);
    font-size: 12px;
    font-weight: 800;
}

.html5-crossword-progress-card {
    padding: 14px;
}

.html5-crossword-progress-head,
.html5-crossword-clue-bank-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.html5-crossword-progress-head span,
.html5-crossword-clue-bank-head span {
    color: var(--cw-accent);
    font-weight: 900;
}

.html5-crossword-progress {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.html5-crossword-progress i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cw-accent), var(--cw-accent-alt));
    transition: width .22s ease;
}

.html5-crossword-clue-bank {
    min-height: 0;
    padding: 14px;
}

.html5-crossword-clue-bank ol {
    display: grid;
    gap: 9px;
    max-height: 300px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: auto;
}

.html5-crossword-clue-bank li {
    color: #334155;
    font-size: 14px;
    line-height: 1.35;
}

.html5-crossword-clue-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
    padding: 8px;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 8px;
    background: #fff;
}

.html5-crossword-clue-number {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    min-height: 28px;
    border-radius: 8px;
    background: var(--cw-accent);
    color: #fff;
    font-weight: 900;
}

.html5-crossword-clue-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.html5-crossword-clue-text small {
    color: var(--cw-muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.html5-crossword textarea {
    caret-color: transparent;
}

@media (max-width: 1120px) {
    .html5-crossword-game {
        grid-template-columns: 1fr;
    }

    .html5-crossword-side {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .html5-crossword-clue-bank {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .html5-crossword-game {
        gap: 12px;
    }

    .html5-crossword-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .html5-crossword-board-shell {
        min-height: auto;
        padding: 10px;
    }

    .html5-crossword-side {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .html5-crossword-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .html5-crossword-stats strong {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .html5-crossword-clue {
        font-size: 15px;
    }

    .html5-crossword-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .html5-crossword-btn {
        width: 100%;
    }
}
