/* Quintaria - clone italiano di Wordle, vanilla CSS, mobile-first. */

.q-game {
    max-width: 560px;
    margin: 1rem auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
}

.q-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--c-line, #e2e8f0);
    padding-bottom: 0.6rem;
}

.q-puzzle-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.85rem;
    color: var(--c-ink-soft, #334155);
}

.q-puzzle-number {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--c-ink, #0f172a);
}

.q-puzzle-mode {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.75rem;
    color: var(--c-ink-mute, #64748b);
}

.q-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.q-icon-btn {
    background: transparent;
    border: 1px solid var(--c-line, #e2e8f0);
    border-radius: 999px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--c-ink-soft, #334155);
    transition: all 120ms;
    padding: 0;
}

.q-icon-btn:hover {
    background: var(--c-bg, #f8fafc);
    color: var(--c-blue, #0065c0);
    border-color: var(--c-blue, #0065c0);
}

/* ===== Board ===== */

.q-board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    padding: 10px;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 5 / 6;
    margin: 0 auto;
    box-sizing: border-box;
}

.q-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.q-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
    color: var(--c-ink, #0f172a);
    border: 2px solid #d3d6da;
    background: transparent;
    aspect-ratio: 1;
    user-select: none;
    transition: transform 120ms;
}

.q-tile.is-filled {
    border-color: #878a8c;
    animation: q-pop 100ms ease-in-out;
}

.q-tile.is-correct {
    background: #6aaa64;
    border-color: #6aaa64;
    color: #fff;
}

.q-tile.is-present {
    background: #c9b458;
    border-color: #c9b458;
    color: #fff;
}

.q-tile.is-absent {
    background: #787c7e;
    border-color: #787c7e;
    color: #fff;
}

.q-row.is-shake {
    animation: q-shake 600ms;
}

@keyframes q-pop {
    0% { transform: scale(0.85); }
    100% { transform: scale(1); }
}

@keyframes q-shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

/* ===== Keyboard ===== */

.q-keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 540px;
    margin: 0.5rem auto 0;
    width: 100%;
}

.q-keyboard-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.q-key {
    flex: 1;
    min-width: 0;
    height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    background: #d3d6da;
    color: #1a1a1b;
    font-weight: 700;
    font-size: 1.15rem;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    transition: background 120ms;
    padding: 0;
    font-family: inherit;
}

.q-key:hover { background: #bbbfc1; }

.q-key.is-wide {
    flex: 1.5;
    font-size: 0.78rem;
    padding: 0 4px;
}

.q-key.is-correct { background: #6aaa64; color: #fff; }
.q-key.is-present { background: #c9b458; color: #fff; }
.q-key.is-absent  { background: #787c7e; color: #fff; }

/* ===== Toast / message ===== */

.q-message-bar {
    text-align: center;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--c-ink, #0f172a);
    background: var(--c-bg, #f8fafc);
    border-radius: 6px;
    padding: 0.5rem;
    transition: opacity 200ms;
}

.q-message-bar.is-hidden {
    opacity: 0;
    visibility: hidden;
}

/* ===== Modals ===== */

.q-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.q-modal.is-open { display: flex; }

.q-modal-box {
    background: var(--c-bg-card, #fff);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
}

.q-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.q-modal-title {
    margin: 0;
    font-size: 1.25rem;
}

.q-modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--c-ink-mute, #64748b);
    line-height: 1;
    padding: 0.2rem 0.5rem;
}

/* Stats modal */

.q-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.q-stats-cell {
    text-align: center;
}

.q-stats-num {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--c-ink, #0f172a);
}

.q-stats-label {
    font-size: 0.7rem;
    color: var(--c-ink-mute, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.1;
}

.q-stats-distrib {
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.q-distrib-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
}

.q-distrib-label {
    width: 1rem;
    text-align: right;
    font-family: var(--font-mono, ui-monospace, monospace);
}

.q-distrib-bar {
    flex: 1;
    background: #d3d6da;
    color: #fff;
    text-align: right;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 1.5rem;
    box-sizing: border-box;
}

.q-distrib-bar.is-current { background: #6aaa64; }

.q-next-word {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--c-line, #e2e8f0);
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.9rem;
    color: var(--c-ink-soft, #334155);
}

.q-next-word-time {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--c-ink, #0f172a);
}

.q-share-btn {
    display: block;
    width: 100%;
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background: #6aaa64;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 120ms;
}

.q-share-btn:hover { background: #5a9954; }

.q-hard-mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--c-line, #e2e8f0);
}

.q-hard-mode-row:last-child { border-bottom: none; }

.q-hard-mode-text {
    flex: 1;
}

.q-hard-mode-title {
    font-weight: 600;
}

.q-hard-mode-desc {
    font-size: 0.85rem;
    color: var(--c-ink-mute, #64748b);
}

/* ===== Print ===== */

@media print {
    .q-keyboard, .q-toolbar-actions, .tools-cta, [data-tools-ad], .tools-ad-slot { display: none !important; }
}

/* Mode actions row (Allenamento / Torna al puzzle / Statistiche) */
.q-mode-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s-2, 0.5rem);
    margin-top: var(--s-3, 0.75rem);
}

/* Help modal styling */
.q-help-list {
    padding-left: 1.2rem;
    line-height: 1.7;
    margin: 0.5rem 0;
}
.q-help-green  { color: #6aaa64; }
.q-help-yellow { color: #c9b458; }
.q-help-gray   { color: #787c7e; }
.q-help-note { margin-top: 1rem; }

/* Hard mode toggle visual size */
.q-hard-mode-toggle {
    width: 20px;
    height: 20px;
    cursor: pointer;
}
