/* Daily Pinyin Wordle — board, keyboard and stats styling.
   Light theme first; dark overrides under [data-bs-theme="dark"] like wordrain.css. */

.pw-hero {
    background: linear-gradient(135deg, #16a34a 0%, #0d9488 60%, #0284c7 100%);
}

/* ── Board ─────────────────────────────────────────────────────────────── */
.pw-board-wrap {
    display: flex;
    justify-content: center;
    padding: .5rem 0 1rem;
}

.pw-board {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pw-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pw-cell {
    width: 3.1rem;
    height: 3.1rem;
    border: 2px solid #d3d6da;
    border-radius: .35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    text-transform: lowercase;
    color: #212529;
    background: #fff;
    user-select: none;
}

.pw-cell-tone {
    border-style: dashed;
}

.pw-sep {
    color: #9ca3af;
    font-weight: 700;
    width: 1rem;
    text-align: center;
    user-select: none;
}

.pw-cell.pw-filled {
    border-color: #878a8c;
    animation: pwPop .1s ease-in-out;
}

.pw-cell[data-state] {
    border-color: transparent;
    color: #fff;
}

.pw-cell[data-state="c"] { background: #6aaa64; }
.pw-cell[data-state="p"] { background: #c9b458; }
.pw-cell[data-state="a"] { background: #787c7e; }

.pw-flip {
    animation: pwFlip .5s ease both;
}

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

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

.pw-shake {
    animation: pwShake .4s ease;
}

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

/* ── Keyboard ──────────────────────────────────────────────────────────── */
.pw-keyboard {
    max-width: 520px;
    margin: 0 auto;
}

.pw-krow {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 6px;
}

.pw-key {
    border: 0;
    border-radius: .3rem;
    background: #d3d6da;
    color: #212529;
    font-weight: 700;
    min-width: 2.15rem;
    height: 3.4rem;
    padding: 0 .35rem;
    font-size: .95rem;
    text-transform: lowercase;
    flex: 1 1 0;
    max-width: 2.9rem;
    cursor: pointer;
    touch-action: manipulation;
}

.pw-key:active { filter: brightness(.9); }

.pw-key-wide {
    max-width: 4.6rem;
    flex-grow: 1.6;
    font-size: .7rem;
    text-transform: uppercase;
}

.pw-key[data-state="c"] { background: #6aaa64; color: #fff; }
.pw-key[data-state="p"] { background: #c9b458; color: #fff; }
.pw-key[data-state="a"] { background: #787c7e; color: #fff; }

.pw-tone-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: .5rem;
}

.pw-key-tone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    max-width: 4rem;
    height: 3.6rem;
}

.pw-tone-mark { font-size: 1.2rem; }
.pw-tone-num { font-size: .7rem; opacity: .75; }

/* ── Result / toast / stats ────────────────────────────────────────────── */
.pw-result-answer {
    font-size: 2.4rem;
    font-weight: 700;
    color: #16a34a;
}

.pw-toast {
    position: fixed;
    left: 50%;
    top: 12%;
    transform: translateX(-50%);
    background: #212529;
    color: #fff;
    padding: .55rem 1.1rem;
    border-radius: .4rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 1080;
}

.pw-toast-show { opacity: 1; }

.pw-dist-line {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .25rem;
}

.pw-dist-label {
    width: .9rem;
    font-weight: 700;
    font-size: .8rem;
    text-align: right;
}

.pw-dist-bar {
    background: #6aaa64;
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    text-align: right;
    padding: .1rem .35rem;
    border-radius: .2rem;
    min-width: 1.2rem;
}

.pw-dist-bar.pw-dist-zero {
    background: #9ca3af;
}

.pw-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 420px) {
    .pw-cell { width: 2.6rem; height: 2.6rem; font-size: 1.3rem; }
    .pw-key { height: 3rem; }
}

/* ── Dark theme ────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .pw-cell {
    background: #1f2937;
    border-color: #3a3a3c;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .pw-cell.pw-filled { border-color: #565758; }
[data-bs-theme="dark"] .pw-cell[data-state] { border-color: transparent; color: #fff; }
[data-bs-theme="dark"] .pw-cell[data-state="c"] { background: #538d4e; }
[data-bs-theme="dark"] .pw-cell[data-state="p"] { background: #b59f3b; }
[data-bs-theme="dark"] .pw-cell[data-state="a"] { background: #3a3a3c; }

[data-bs-theme="dark"] .pw-key {
    background: #565758;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .pw-key[data-state="c"] { background: #538d4e; color: #fff; }
[data-bs-theme="dark"] .pw-key[data-state="p"] { background: #b59f3b; color: #fff; }
[data-bs-theme="dark"] .pw-key[data-state="a"] { background: #2d2d2f; color: #9ca3af; }

[data-bs-theme="dark"] .pw-toast {
    background: #e5e7eb;
    color: #111827;
}

[data-bs-theme="dark"] .pw-result-answer { color: #4ade80; }
