/* ---------------------------------------------------------------------------
   Paroletta — classic Wordle palette on the platform's dark shell.
   Everything is namespaced under .wd-* so the other games are never touched.
   --------------------------------------------------------------------------- */

/* On :root, not .wd-root: the round panel's mini-grids live in the sidebar,
   outside the board subtree, and need the same palette. */
:root {
    --wd-green: #538d4e;
    --wd-yellow: #b59f3b;
    --wd-absent: #3a3a3c;
    --wd-border: #565758;
    --wd-border-idle: #3a3a3c;
    --wd-key: #818384;
    --wd-ink: #ffffff;
}

.wd-root {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    font-family: 'Rubik', sans-serif;
    user-select: none;
}

/* --- top line: timer + status ------------------------------------------------ */

.wd-topline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    min-height: 26px;
}

.wd-timer {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #cccccc;
}

.wd-timer-low {
    color: #ff7676;
    animation: wdPulse 1s ease infinite;
}

@keyframes wdPulse {
    50% { opacity: 0.4; }
}

.wd-msg { color: #aaaaaa; }
.wd-msg-solved { color: #7ede9a; font-weight: 600; }
.wd-msg-failed { color: #ff9d76; }

/* --- the grid ---------------------------------------------------------------- */

.wd-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.wd-cell {
    width: clamp(38px, 11vw, 58px);
    height: clamp(38px, 11vw, 58px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(20px, 5vw, 30px);
    font-weight: 700;
    color: var(--wd-ink);
    text-transform: uppercase;
    border: 2px solid var(--wd-border-idle);
    border-radius: 4px;
    box-sizing: border-box;
    background: transparent;
}

.wd-typed {
    border-color: var(--wd-border);
    animation: wdPop 0.1s ease;
}

@keyframes wdPop {
    50% { transform: scale(1.12); }
}

.wd-scored {
    border-color: transparent;
    animation: wdFlip 0.45s ease both;
    animation-delay: calc(var(--wd-i, 0) * 0.12s);
}

@keyframes wdFlip {
    0% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.wd-g { background: var(--wd-green); }
.wd-y { background: var(--wd-yellow); }
.wd-x { background: var(--wd-absent); }

.wd-row-shake {
    animation: wdShake 0.5s ease;
}

@keyframes wdShake {
    10%, 50%, 90% { transform: translateX(-5px); }
    30%, 70% { transform: translateX(5px); }
}

/* --- notice ------------------------------------------------------------------ */

.wd-notice {
    min-height: 20px;
    font-size: 14px;
    color: #ffb4a2;
    opacity: 0;
    transition: opacity 0.2s;
}

.wd-notice-on { opacity: 1; }

/* --- keyboard ---------------------------------------------------------------- */

.wd-keyboard {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 100%;
    max-width: 600px;
    --wd-gap: 6px;
}

.wd-key-row {
    display: flex;
    gap: var(--wd-gap);
    justify-content: center;
}

/* Every row derives its key width from the longest row (--wd-cols, set inline
   by the plugin), so keys line up evenly instead of stretching per row. The
   margin/padding resets matter: styles.css gives every <button> margin: 10px. */
.wd-key {
    flex: 0 1 calc((100% - (var(--wd-cols, 10) - 1) * var(--wd-gap)) / var(--wd-cols, 10));
    max-width: 54px;
    height: 56px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 5px;
    background: var(--wd-key, #818384);
    color: white;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    touch-action: manipulation;
}

.wd-key:disabled {
    opacity: 0.4;
    cursor: default;
}

/* INVIO and ⌫ absorb the slack left by the shorter bottom row. */
.wd-key-wide {
    flex: 1 1 auto;
    max-width: 96px;
    font-size: 12px;
}

.wd-key-g { background: var(--wd-green, #538d4e); }
.wd-key-y { background: var(--wd-yellow, #b59f3b); }
.wd-key-x { background: #232324; color: #777; }

/* The Russian layout holds up to 12 keys per row — tighter gaps, smaller type. */
.wd-kb-dense { --wd-gap: 3px; }
.wd-kb-dense .wd-key { font-size: 13px; }

/* --- round panel (opponents' colour grids) ----------------------------------- */

.wd-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wd-panel-player {
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.wd-panel-me {
    outline: 1px solid rgba(126, 222, 154, 0.4);
}

.wd-panel-offline { opacity: 0.45; }

.wd-panel-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.wd-panel-name {
    font-weight: 600;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wd-status-solved { color: #7ede9a; font-weight: 600; font-size: 13px; }
.wd-status-failed { color: #ff7676; font-weight: 600; font-size: 13px; }
.wd-status-playing { color: #999; font-size: 13px; }

.wd-panel-score {
    margin-left: auto;
    font-weight: 700;
    color: #e8b04b;
}

.wd-mini {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.wd-mini-row {
    display: flex;
    gap: 3px;
}

.wd-mini-cell {
    width: 13px;
    height: 13px;
    border-radius: 2px;
}

/* A touch lighter than the board's absent tint, or it sinks into the card. */
.wd-mini-cell.wd-x { background: #52525a; }

.wd-mini-empty {
    color: #666;
    font-size: 13px;
}

/* --- end-of-round reveal ------------------------------------------------------ */

.wd-reveal-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.wd-reveal-label {
    color: #aaaaaa;
    font-size: 14px;
}

.wd-reveal-collective .wd-reveal-label::after {
    content: ' — indovinata da tutti! 🎉';
    color: #7ede9a;
}

.wd-reveal-boards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
    width: 100%;
}

.wd-reveal-player {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.wd-reveal-name {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 2px;
}

.wd-reveal-name .wd-panel-score { margin-left: 4px; }

.wd-row-small { gap: 3px; }

.wd-cell-small {
    width: 26px;
    height: 26px;
    font-size: 14px;
    border: none;
    border-radius: 3px;
}

/* --- lobby badges ------------------------------------------------------------- */

.tipo-badge.tipo-wordle { background: #274e2b; color: #9fe0a5; }
.tipo-badge.tipo-wordle-time { background: #4a4423; color: #e5d68a; }
.game-badge-wordle { background: #3f7a44; }

/* --- phones -------------------------------------------------------------------- */

@media (max-width: 700px) {
    .wd-cell {
        width: clamp(30px, 9.5vw, 44px);
        height: clamp(30px, 9.5vw, 44px);
        font-size: clamp(16px, 4.5vw, 22px);
    }

    /* Fill the whole width: drop the caps so the keys use every pixel. */
    .wd-keyboard { max-width: none; --wd-gap: 4px; }
    .wd-kb-dense { --wd-gap: 2px; }
    .wd-key { max-width: none; height: 52px; font-size: 14px; }
    .wd-key-wide { max-width: none; font-size: 11px; }
}
