/* Sizes are rem-based so the account "Larger text" control (html[data-a11y-text])
   scales the whole game, and tiles use a min(rem, vw) cap so a long word still
   reflows without horizontal scroll down to a 320px viewport. */
.wgGameContainer {
    --wg-tile: min(2.875rem, calc((100vw - 3rem) / 9));
    --wg-gap: 0.375rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.5rem 0.5rem;
    max-width: 33rem;
    margin: 0 auto;
}

/* Top bar: How to play (top-left). Bottom bar: Hint (bottom-right). */
.wgTopBar {
    width: 100%;
    max-width: 30rem;
    display: flex;
    justify-content: flex-start;
}
.wgBottomBar {
    width: 100%;
    max-width: 30rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.25rem;
}

.wgHowToBtn {
    background: transparent;
    border: none;
    color: #3a2f9c;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.4rem 0.25rem;
    min-height: 2.25rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.wgHowToBtn:hover {
    color: #2a1f8c;
}

.wgHintText {
    flex: 1 1 auto;
    font-size: 0.85rem;
    color: #444;
    text-align: left;
    min-height: 1.1rem;
}
.wgHintBtn {
    flex: 0 0 auto;
    background: #ffffff;
    border: 2px solid #878a8c;
    color: #1b1b1b;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    min-height: 2.25rem;
    border-radius: 1.25rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.wgHintBtn:hover:not(:disabled) {
    background: #f2f2f2;
}
.wgHintBtn:disabled {
    opacity: 0.5;
    cursor: default;
}

.wgPrompt {
    font-size: 0.9rem;
    color: #444;
    text-align: center;
    min-height: 1.25rem;
    padding: 0 0.75rem;
    max-width: 28rem;
    transition: color 0.25s ease;
}
.wgPrompt:focus {
    outline: none;
}
.wgPromptWin {
    color: #1c6a3a;
    font-weight: 600;
}
.wgPromptError {
    color: #b3261e;
    font-weight: 600;
}

/* Board */
.wgBoard {
    display: flex;
    flex-direction: column;
    gap: var(--wg-gap);
}
.wgRow {
    display: flex;
    gap: var(--wg-gap);
    justify-content: center;
    perspective: 800px;
}
.wgTile {
    width: var(--wg-tile);
    height: var(--wg-tile);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--wg-tile) * 0.52);
    font-weight: 700;
    color: #1b1b1b;
    background: #ffffff;
    border: 2px solid #d3d6da;
    border-radius: 6px;
    text-transform: none;
    position: relative;
    transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.wgTile.wg-typed {
    border-color: #878a8c;
    transform: scale(1.05);
}
.wgTile.wg-correct {
    background: #6aaa64;
    border-color: #6aaa64;
    color: #1b1b1b;
}
.wgTile.wg-present {
    background: #c9b458;
    border-color: #c9b458;
    color: #1b1b1b;
}
.wgTile.wg-absent {
    background: #6b6b6b;
    border-color: #6b6b6b;
    color: #ffffff;
}

/* Flip reveal: rotate to edge-on and back; the colour is applied at the midpoint
   in JS so it appears as the tile turns. Gated by reduced-motion below. */
.wgTile.wgFlip {
    animation: wgFlip 0.5s ease forwards;
}
@keyframes wgFlip {
    0%   { transform: rotateX(0deg); }
    50%  { transform: rotateX(-90deg); }
    100% { transform: rotateX(0deg); }
}
/* Winning row celebration bounce */
.wgTile.wgWin {
    animation: wgBounce 0.6s ease;
}
@keyframes wgBounce {
    0%, 100% { transform: translateY(0); }
    30%      { transform: translateY(-14px); }
    50%      { transform: translateY(3px); }
    70%      { transform: translateY(-6px); }
}

.wgShake {
    animation: wgShake 0.45s ease;
}
@keyframes wgShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* On-screen keyboard. Keys are white with a neutral border (clearly distinct from
   the purple page); a used-absent key turns dark grey, like real Wordle. Keys
   flex-shrink so 10 across still fit a 320px row and each stays >= 24px (WCAG 2.5.8). */
.wgKeyboard {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    width: 100%;
    max-width: 30rem;
    margin-top: 0.25rem;
}
.wgKeyRow {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
}
.wgKey {
    flex: 1 1 auto;
    min-width: 1.7rem;
    max-width: 2.75rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: #1b1b1b;
    background: #ffffff;
    border: 2px solid #d3d6da;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.wgKey:hover {
    background: #f2f2f2;
}
.wgKey:active {
    transform: scale(0.94);
}
.wgKeyWide {
    flex: 1.5 1 auto;
    max-width: 4.5rem;
    font-size: 0.8rem;
}
.wgKey.wg-correct {
    background: #6aaa64;
    border-color: #6aaa64;
    color: #1b1b1b;
}
.wgKey.wg-present {
    background: #c9b458;
    border-color: #c9b458;
    color: #1b1b1b;
}
.wgKey.wg-absent {
    background: #6b6b6b;
    border-color: #6b6b6b;
    color: #ffffff;
}

/* Done / Finish button */
.wgContinueBtn {
    margin-top: 0.375rem;
    padding: 0.625rem 2rem;
    min-height: 2.75rem;
    background: #2e7d47;
    color: #fff;
    border: none;
    border-radius: 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(46,125,71,0.3);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}
.wgContinueBtn.wgVisible {
    opacity: 1;
    transform: translateY(0);
}
.wgContinueBtn:hover {
    background: #256439;
}
.wgContinueBtn:active {
    transform: scale(0.97);
}

.wgError {
    color: #b3261e;
    text-align: center;
    padding: 1.5rem;
}

/* How-to-play dialog contents (the overlay box comes from the shared .overlay
   / .alertOverlay classes). */
.wgHowToContent {
    text-align: left;
    max-width: 22rem;
}
.wgHowToHeading {
    margin-top: 0;
}
.wgLegend {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1rem;
}
.wgLegend li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.5rem 0;
    font-size: 0.95rem;
    color: #1b1b1b;
}
.wgSwatch {
    flex: 0 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-radius: 5px;
    border: 2px solid transparent;
}
.wgSwatch.wg-correct {
    background: #6aaa64;
    border-color: #6aaa64;
    color: #1b1b1b;
}
.wgSwatch.wg-present {
    background: #c9b458;
    border-color: #c9b458;
    color: #1b1b1b;
}
.wgSwatch.wg-absent {
    background: #6b6b6b;
    border-color: #6b6b6b;
    color: #ffffff;
}

/* Completion summary (level 2 reinit) */
.wgCompleteBox {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    padding: 2.5rem 1rem;
    animation: wgFadeIn 0.4s ease;
}
.wgCompleteText {
    font-size: 1.15rem;
    color: #1c6a3a;
    font-weight: 600;
    margin: 0;
}
@keyframes wgFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Corner marks: a non-colour cue for correct vs present, shown only in the
   account's High Contrast mode (kept off the default Wordle-clean look). */
html[data-a11y-contrast="high"] .wgTile[data-mark="correct"]::after,
html[data-a11y-contrast="high"] .wgTile[data-mark="present"]::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    box-sizing: border-box;
}
html[data-a11y-contrast="high"] .wgTile[data-mark="correct"]::after {
    background: #ffffff;
}
html[data-a11y-contrast="high"] .wgTile[data-mark="present"]::after {
    background: transparent;
    border: 2px solid #ffffff;
}

/* High-contrast mode: deepen every state colour to >= 7:1 with white text and
   thicken tile borders so the grid stays legible. */
html[data-a11y-contrast="high"] .wgTile {
    border-width: 3px;
    color: #111317;
}
html[data-a11y-contrast="high"] .wgTile.wg-correct,
html[data-a11y-contrast="high"] .wgKey.wg-correct,
html[data-a11y-contrast="high"] .wgSwatch.wg-correct {
    background: #0b5c2e;
    border-color: #0b5c2e;
    color: #ffffff;
}
html[data-a11y-contrast="high"] .wgTile.wg-present,
html[data-a11y-contrast="high"] .wgKey.wg-present,
html[data-a11y-contrast="high"] .wgSwatch.wg-present {
    background: #5a4600;
    border-color: #5a4600;
    color: #ffffff;
}
html[data-a11y-contrast="high"] .wgTile.wg-absent,
html[data-a11y-contrast="high"] .wgKey.wg-absent,
html[data-a11y-contrast="high"] .wgSwatch.wg-absent {
    background: #2f2f2f;
    border-color: #2f2f2f;
    color: #ffffff;
}
html[data-a11y-contrast="high"] .wgKey {
    border: 2px solid #444444;
    color: #111317;
}
html[data-a11y-contrast="high"] .wgTile.wg-typed {
    border-color: #2a1f8c;
}
html[data-a11y-contrast="high"] .wgHowToBtn {
    color: #2a1f8c;
}

@media only screen and (max-width: 480px) {
    .wgKey { height: 2.75rem; }
    .wgKeyWide { font-size: 0.7rem; }
}

/* Respect reduced-motion (OS preference; the account toggle also neutralises
   motion globally via html[data-a11y-motion]): keep state changes instant. */
@media (prefers-reduced-motion: reduce) {
    .wgTile, .wgKey, .wgContinueBtn, .wgHintBtn {
        transition: none;
    }
    .wgShake, .wgTile.wgFlip, .wgTile.wgWin { animation: none; }
    .wgCompleteBox { animation: none; }
    .wgTile.wg-typed { transform: none; }
}
