/* Word game (/word-game) */
.wg-page {
    --wg-border: var(--vr-gray-200, #e5e7eb);
    --wg-surface: var(--vr-gray-50, #f9fafb);
    --wg-muted: var(--vr-gray-500, #6b7280);
    --wg-tile: #fff7e6;
    --wg-tile-text: #3b2a10;
    --wg-accent: var(--vr-color-main, #2563eb);
    --wg-good: #16a34a;
    --wg-bad: #dc2626;
    max-width: 760px;
    margin: 24px auto 48px;
}

[data-bs-theme="dark"] .wg-page {
    --wg-border: var(--vr-gray-700, #374151);
    --wg-surface: var(--vr-gray-800, #1f2937);
    --wg-muted: var(--vr-gray-400, #9ca3af);
    --wg-tile: #3a2f1c;
    --wg-tile-text: #fdecc8;
}

.wg-head { text-align: center; margin-bottom: 20px; }
.wg-title { font-size: 2rem; font-weight: 800; margin: 0 0 8px; }
.wg-lead { color: var(--wg-muted); margin: 0 auto; max-width: 560px; }

.wg-notice, .wg-card {
    border: 1px solid var(--wg-border);
    background: var(--wg-surface);
    border-radius: 14px;
    padding: 20px;
}
.wg-notice { text-align: center; }

.wg-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.wg-stat { border: 1px solid var(--wg-border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.wg-stat span, .wg-stat small { color: var(--wg-muted); font-size: 12px; }
.wg-stat strong { font-size: 1.25rem; }

.wg-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.wg-level { cursor: pointer; margin: 0; }
.wg-level input { position: absolute; opacity: 0; pointer-events: none; }
.wg-level span { display: flex; flex-direction: column; align-items: center; padding: 12px 6px; border: 2px solid var(--wg-border); border-radius: 12px; }
.wg-level small { color: var(--wg-muted); }
.wg-level input:checked + span { border-color: var(--wg-accent); }
.wg-level input:focus-visible + span { outline: 2px solid var(--wg-accent); outline-offset: 2px; }
.wg-start { width: 100%; padding: 12px; font-weight: 700; }
.wg-rules { margin: 16px 0 0; padding-left: 18px; color: var(--wg-muted); font-size: 14px; }

.wg-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.wg-timer { position: relative; width: 76px; height: 76px; }
.wg-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.wg-timer circle { fill: none; stroke-width: 8; }
.wg-timer-bg { stroke: var(--wg-border); }
.wg-timer-fg { stroke: var(--wg-accent); stroke-linecap: round; transition: stroke .3s; }
.wg-timer span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 800; }
.wg-game.is-low .wg-timer-fg { stroke: var(--wg-bad); }
.wg-game.is-low .wg-timer span { color: var(--wg-bad); }
.wg-score { text-align: right; }
.wg-score span { display: block; color: var(--wg-muted); font-size: 12px; text-transform: uppercase; }
.wg-score strong { font-size: 2rem; font-weight: 800; }

.wg-grid {
    --wg-size: 4;
    display: grid;
    grid-template-columns: repeat(var(--wg-size), 1fr);
    gap: 8px;
    max-width: 440px;
    margin: 0 auto;
}
.wg-tile {
    aspect-ratio: 1;
    border: 0;
    border-radius: 10px;
    background: var(--wg-tile);
    color: var(--wg-tile-text);
    font-size: clamp(1.1rem, 5vw, 1.8rem);
    font-weight: 800;
    box-shadow: 0 3px 0 rgba(0, 0, 0, .15);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: transform .08s, background .15s;
}
.wg-tile:active { transform: translateY(2px); box-shadow: none; }
.wg-tile.is-selected { background: var(--wg-accent); color: #fff; }
.wg-tile.is-last { box-shadow: 0 0 0 3px rgba(0, 0, 0, .25) inset; }
.wg-tile.is-next { box-shadow: 0 0 0 2px var(--wg-accent); }
.wg-tile:disabled { cursor: default; opacity: .6; }
.wg-grid.wg-shake { animation: wg-shake .35s; }
.wg-grid.wg-shake .wg-tile { box-shadow: 0 0 0 2px var(--wg-bad); }
@keyframes wg-shake {
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.wg-current { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 40px; margin: 16px 0 4px; }
.wg-chip { display: inline-flex; align-items: center; gap: 2px; padding: 4px 4px 4px 10px; border-radius: 999px; background: var(--wg-accent); color: #fff; font-weight: 700; }
.wg-chip-x { border: 0; background: rgba(255, 255, 255, .25); color: inherit; width: 22px; height: 22px; border-radius: 50%; line-height: 1; padding: 0; cursor: pointer; }
.wg-flash { min-height: 22px; text-align: center; font-weight: 700; }
.wg-flash.is-good { color: var(--wg-good); }
.wg-flash.is-bad { color: var(--wg-bad); }

.wg-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.wg-actions .btn { min-width: 110px; }

.wg-found { margin-top: 18px; border-top: 1px solid var(--wg-border); padding-top: 12px; }
.wg-found-title { font-weight: 700; margin-bottom: 8px; }
.wg-found ul, .wg-res-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.wg-found li, .wg-res-list li { border: 1px solid var(--wg-border); border-radius: 8px; padding: 3px 8px; font-size: 14px; }
.wg-found li b { color: var(--wg-good); margin-left: 6px; }
.wg-found li.wg-empty { border: 0; color: var(--wg-muted); padding: 0; }

.wg-modal { position: fixed; inset: 0; z-index: 1060; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.wg-modal[hidden] { display: none; }
.wg-modal-box { background: var(--vr-body-bg, #fff); color: inherit; border-radius: 16px; padding: 24px; width: 100%; max-width: 420px; max-height: 90vh; overflow: auto; text-align: center; }
[data-bs-theme="dark"] .wg-modal-box { background: var(--vr-gray-900, #111827); }
.wg-modal-box h2 { font-size: 1.5rem; font-weight: 800; margin: 0 0 14px; }
.wg-result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.wg-result-grid div { border: 1px solid var(--wg-border, #e5e7eb); border-radius: 10px; padding: 8px 4px; }
.wg-result-grid span { display: block; font-size: 12px; color: var(--wg-muted, #6b7280); }
.wg-result-grid strong { font-size: 1.2rem; }
.wg-res-note { color: var(--wg-bad, #dc2626); font-size: 14px; }
.wg-res-list { justify-content: center; margin-bottom: 8px; }

.wg-missed { border-top: 1px solid var(--wg-border, #e5e7eb); margin-top: 12px; padding-top: 12px; }
.wg-missed-title { font-weight: 700; margin-bottom: 8px; }
.wg-missed-title span { color: var(--wg-muted, #6b7280); font-weight: 400; }
.wg-missed-list { max-height: 180px; overflow: auto; }
.wg-missed-list li { color: var(--wg-muted, #6b7280); }
.wg-missed-list li b { margin-left: 6px; font-weight: 600; }
.wg-missed-more { color: var(--wg-muted, #6b7280); font-size: 13px; margin-top: 6px; }

@media (max-width: 575px) {
    .wg-stats { grid-template-columns: 1fr; }
    .wg-grid { gap: 6px; }
    .wg-card { padding: 14px; }
}
