/* Shared look of the self-hosted games. Each page sets --accent / --accent-2 on <body>. */
.wpg-page {
    --accent: #00ac4a;
    --accent-2: #bbf7d0;
    --accent-ink: #fff;
    --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
    --ok: #21a35b;
    --mid: #e2b018;
    --no: #8c95a3;
    --tile-line: #d6dbe3;
    --tile-bg: #fff;
    --surface: var(--wp-surface, #fff);
    --bg: var(--wp-bg, #f7f8fa);
    --ink: var(--wp-ink, #14181f);
    --ink-soft: var(--wp-ink-soft, #55606f);
    --line: var(--wp-line, rgba(15, 23, 42, .08));
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 22px;
    --shadow-1: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px rgba(15, 23, 42, .06);
    --shadow-2: 0 18px 50px rgba(15, 23, 42, .18);
    --ease: cubic-bezier(.22, 1, .36, 1);
    background-image: radial-gradient(1100px 520px at 50% -240px, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%) !important;
}
.wpg-page--spelling-bee, .wpg-page--wordle-spanish, .wpg-page--phrasle { --accent-ink: #1f1600; }
body.dark.wpg-page { --tile-line: #3a4150; --tile-bg: #1c2029; --no: #4b5361; }

.wpg-main { padding: 18px 12px 10px; }
.wpg-main *, .wpg-main *::before, .wpg-main *::after { box-sizing: border-box; }

/* ---------- Stage / shell ---------- */
.wpg-stage { display: flex; justify-content: center; }
.wpg-shell {
    width: 100%;
    max-width: 620px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.wpg-page--kilordle .wpg-shell, .wpg-page--tradle .wpg-shell, .wpg-page--suika .wpg-shell { max-width: 760px; }

.wpg-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, var(--surface)), var(--surface));
}
.wpg-brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1 1 auto; }
.wpg-brand__name { font-weight: 800; font-size: 17px; letter-spacing: .2px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wpg-modes { display: flex; flex: 0 0 auto; }
.wpg-modes:empty { display: none; }
.wpg-tools { display: flex; gap: 6px; flex: 0 0 auto; }

.wpg-seg { display: inline-flex; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 999px; padding: 3px; gap: 2px; }
.wpg-seg button {
    border: 0; background: transparent; color: var(--ink-soft); font: inherit; font-weight: 700; font-size: 13px;
    padding: 5px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.wpg-seg button.is-on { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }

.wpg-tool {
    width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); padding: 0;
    transition: transform .15s var(--ease), background .15s;
}
.wpg-tool:hover { transform: translateY(-1px); background: var(--accent-soft); }
.wpg-tool svg { width: 19px; height: 19px; }

@media (max-width: 520px) {
    .wpg-main { padding: 10px 6px; }
    .wpg-brand__name { font-size: 15px; }
    .wpg-bar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
    .wpg-modes { order: 3; width: 100%; justify-content: center; }
    .wpg-tool { width: 34px; height: 34px; }
}

.wpg-app { position: relative; padding: 14px 12px 16px; min-height: 420px; color: var(--ink); user-select: none; -webkit-user-select: none; }
.wpg-loading { display: flex; align-items: center; justify-content: center; min-height: 380px; }
.wpg-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-2); border-top-color: var(--accent); animation: wpg-spin .8s linear infinite; }
@keyframes wpg-spin { to { transform: rotate(360deg); } }
.wpg-error { text-align: center; padding: 40px 10px; color: var(--ink-soft); }

/* ---------- Icon ---------- */
.wpg-icon {
    --a: var(--accent); --a2: var(--accent-2);
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--a), color-mix(in srgb, var(--a) 62%, #000));
    color: #fff; font-weight: 900; font-size: 15px; line-height: 1; letter-spacing: -.3px;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .14), 0 2px 6px color-mix(in srgb, var(--a) 35%, transparent);
}
.wpg-icon--lg { width: 48px; height: 48px; border-radius: 14px; font-size: 21px; }
img.wpg-icon { display: block; background: none; border-radius: 23%; box-shadow: 0 1px 4px rgba(20, 24, 31, .1); }

/* ---------- Buttons ---------- */
.wpg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 0; border-radius: 999px; padding: 10px 20px; font: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
    background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 32%, transparent);
    transition: transform .15s var(--ease), filter .15s;
    text-decoration: none;
}
.wpg-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.wpg-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.wpg-flag { display: inline-block; width: 1.33em; height: 1em; border-radius: 2px; object-fit: cover; vertical-align: -.14em; box-shadow: 0 0 0 1px rgba(15, 23, 42, .12); }
.wpg-btn:disabled { background: color-mix(in srgb, var(--ink) 7%, var(--surface)) !important; color: color-mix(in srgb, var(--ink) 45%, var(--surface)) !important; border-color: transparent !important; box-shadow: none !important; cursor: default; transform: none; }
.wpg-wordle--2 .wpg-wordle__b, .wpg-wordle--3 .wpg-wordle__b, .wpg-wordle--4 .wpg-wordle__b { padding: 4px; border-radius: 9px; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.wpg-btn--ghost { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); box-shadow: none; }
.wpg-btn--sm { padding: 7px 14px; font-size: 13.5px; }
.wpg-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- Tiles / boards ---------- */
.wpg-board { display: grid; gap: 6px; justify-content: center; margin: 0 auto; }
.wpg-board__row { display: grid; gap: 6px; grid-auto-flow: column; grid-auto-columns: var(--tile, 56px); }
.wpg-tile-l {
    width: var(--tile, 56px); height: var(--tile, 56px);
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--tile-line); border-radius: 10px; background: var(--tile-bg);
    font-weight: 800; font-size: calc(var(--tile, 56px) * .5); text-transform: uppercase; color: var(--ink);
    transition: border-color .1s;
}
.wpg-tile-l.is-filled { border-color: color-mix(in srgb, var(--ink) 45%, var(--tile-line)); animation: wpg-pop .12s var(--ease); }
.wpg-tile-l.is-correct, .wpg-tile-l.is-present, .wpg-tile-l.is-absent { color: #fff; border-color: transparent; }
.wpg-tile-l.is-correct { background: var(--ok); }
.wpg-tile-l.is-present { background: var(--mid); }
.wpg-tile-l.is-absent { background: var(--no); }
.wpg-tile-l.is-flip { animation: wpg-flip .42s ease both; }
.wpg-board__row.is-shake { animation: wpg-shake .4s; }
.wpg-board__row.is-win .wpg-tile-l { animation: wpg-bounce .5s ease both; }
@keyframes wpg-pop { 50% { transform: scale(1.08); } }
@keyframes wpg-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes wpg-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes wpg-bounce { 30% { transform: translateY(-14px); } 60% { transform: translateY(2px); } }

/* ---------- Keyboard ---------- */
.wpg-kb { display: flex; flex-direction: column; gap: 6px; margin: 14px auto 0; max-width: 520px; touch-action: manipulation; }
.wpg-kb__row { display: flex; gap: 5px; justify-content: center; }
.wpg-key {
    flex: 1 1 0; min-width: 0; max-width: 46px; height: 52px; border: 0; border-radius: 9px;
    background: color-mix(in srgb, var(--ink) 9%, var(--surface)); color: var(--ink);
    font: inherit; font-weight: 800; font-size: 16px; text-transform: uppercase; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08);
    transition: transform .08s, background .15s;
}
.wpg-key:active { transform: scale(.94); }
.wpg-key--wide { flex: 1.6 1 0; max-width: 74px; font-size: 12px; }
.wpg-key svg { width: 22px; height: 22px; }
.wpg-key.is-correct { background: var(--ok); color: #fff; }
.wpg-key.is-present { background: var(--mid); color: #fff; }
.wpg-key.is-absent { background: var(--no); color: #fff; opacity: .75; }
.wpg-key__split { position: absolute; inset: 0; display: grid; }
.wpg-key__split i { display: block; }
.wpg-key__split i.is-correct { background: var(--ok); }
.wpg-key__split i.is-present { background: var(--mid); }
.wpg-key__split i.is-absent { background: var(--no); opacity: .55; }
.wpg-key__split i.is-none { background: transparent; }
.wpg-key span { position: relative; z-index: 1; }
.wpg-kb--dense .wpg-key { height: 46px; font-size: 14px; }
.wpg-key__ico { display: none; }
.wpg-key__txt + .wpg-key__ico { display: none; }
.wpg-key__ico:only-child { display: inline-flex; }
@media (max-width: 420px) {
    .wpg-key { height: 48px; font-size: 14px; } .wpg-kb__row { gap: 4px; }
    .wpg-key__txt { display: none; }
    .wpg-key__txt + .wpg-key__ico { display: inline-flex; }
}

/* ---------- Modal / toast ---------- */
.wpg-overlay {
    position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(10, 14, 22, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    animation: wpg-fade .18s ease;
}
.wpg-modal {
    position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow: auto;
    background: var(--surface); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
    padding: 22px 20px 20px; animation: wpg-rise .25s var(--ease);
}
.wpg-modal h3 { margin: 0 34px 12px 0; font-size: 20px; font-weight: 900; }
.wpg-modal p, .wpg-modal li { font-size: 15px; line-height: 1.5; color: var(--ink); }
.wpg-modal ul { padding-left: 20px; margin: 0 0 10px; }
.wpg-modal__x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wpg-modal__actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.wpg-modal__big { text-align: center; font-size: 15px; color: var(--ink-soft); margin: 2px 0 10px; }
.wpg-modal__answer { display: flex; justify-content: center; gap: 4px; margin: 6px 0 12px; flex-wrap: wrap; }
.wpg-modal__answer .wpg-tile-l { --tile: 40px; }
@keyframes wpg-fade { from { opacity: 0; } }
@keyframes wpg-rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.wpg-toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 10001; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.wpg-toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-weight: 800; font-size: 14px; box-shadow: var(--shadow-2); animation: wpg-rise .2s var(--ease); max-width: 90vw; text-align: center; }
body.dark .wpg-toast { background: #eef1f6; color: #12151c; }

/* ---------- Stats ---------- */
.wpg-stats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; text-align: center; margin: 4px 0 14px; }
.wpg-stats b { display: block; font-size: 26px; font-weight: 900; line-height: 1.1; }
.wpg-stats small { display: block; font-size: 11.5px; color: var(--ink-soft); line-height: 1.2; }
.wpg-dist { display: flex; flex-direction: column; gap: 4px; }
.wpg-dist__row { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; }
.wpg-dist__row span:first-child { width: 22px; text-align: right; }
.wpg-dist__bar { background: var(--no); color: #fff; padding: 2px 7px; border-radius: 5px; text-align: right; min-width: 24px; }
.wpg-dist__row.is-last .wpg-dist__bar { background: var(--accent); color: var(--accent-ink); }
.wpg-countdown { text-align: center; margin-top: 12px; font-size: 13px; color: var(--ink-soft); }
.wpg-countdown b { display: block; font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Generic game bits ---------- */
.wpg-status { text-align: center; font-weight: 800; font-size: 14px; color: var(--ink-soft); min-height: 20px; margin: 0 0 10px; }
.wpg-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-weight: 800; font-size: 13px; }
.wpg-input {
    width: 100%; border: 2px solid var(--tile-line); border-radius: 12px; padding: 11px 14px; font: inherit; font-size: 16px; font-weight: 700;
    background: var(--tile-bg); color: var(--ink); outline: none; user-select: text; -webkit-user-select: text;
}
.wpg-input:focus { border-color: var(--accent); }

/* ---------- Page sections ---------- */
.wpg-about, .wpg-more, .wpg-langs { max-width: 900px; margin: 22px auto 0; }
.wpg-page .wpg-about:not(.wpg-hub__head) { max-width: 620px; }
.wpg-page--kilordle .wpg-about, .wpg-page--tradle .wpg-about, .wpg-page--suika .wpg-about { max-width: 760px; }
.wpg-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 24px 26px; }
.wpg-about__tag { display: inline-block; margin-bottom: 8px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px; }
.wpg-main .wpg-about__h1 { font-size: 28px !important; font-weight: 900 !important; line-height: 1.2 !important; margin: 0 0 10px !important; color: var(--ink) !important; text-align: left !important; }
.wpg-main .wpg-about__h2 { font-size: 16.5px !important; font-weight: 500 !important; line-height: 1.65 !important; margin: 0 !important; color: var(--ink-soft) !important; text-align: left !important; letter-spacing: 0 !important; }
.wpg-main .wpg-more__title { font-size: 20px !important; font-weight: 900 !important; line-height: 1.3 !important; margin: 0 4px 12px !important; color: var(--ink) !important; }
.wpg-modal h3 { line-height: 1.25 !important; font-size: 20px !important; font-weight: 900 !important; color: var(--ink) !important; }
.wpg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.wpg-tile {
    display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: var(--r-md);
    background: var(--surface); border: 1px solid var(--line); text-decoration: none !important; color: var(--ink) !important;
    transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.wpg-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-1); border-color: color-mix(in srgb, var(--a) 40%, transparent); }
.wpg-tile__text { display: flex; flex-direction: column; min-width: 0; }
.wpg-tile__text b { font-size: 14.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wpg-tile__text small { font-size: 12.5px; line-height: 1.3; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wpg-more__all { text-align: center; margin-top: 12px; }
.wpg-more__all a { font-weight: 800; color: var(--accent); }
.wpg-langs { text-align: center; }
.wpg-langs__title { font-weight: 800; font-size: 14px; color: var(--ink-soft); margin-bottom: 8px; }
.wpg-langs__list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.wpg-chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink) !important; font-size: 13px; font-weight: 700; text-decoration: none !important; }
.wpg-chip.is-on, .wpg-chip:hover { background: var(--accent); color: var(--accent-ink) !important; border-color: transparent; }
.wpg-main a.wpg-chip { display: inline-block; padding: 5px 11px !important; border-radius: 999px; background: var(--surface); color: var(--ink) !important; font-size: 13px !important; font-weight: 700; box-shadow: none; transform: none; }
.wpg-main a.wpg-chip.is-on, .wpg-main a.wpg-chip:hover { background: var(--accent); color: var(--accent-ink) !important; }
.wpg-tile__img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; }

/* ---------- Hub (/wordle-games) ---------- */
.wpg-hub__head { text-align: center; }
.wpg-main .wpg-hub__h1 { font-size: 34px !important; text-align: center !important; margin-bottom: 4px !important; }
.wpg-main .wpg-hub__h2 { text-align: center !important; font-size: 16px !important; }
.wpg-grid--hub { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.wpg-tile--hub { padding: 14px; gap: 13px; background: linear-gradient(135deg, color-mix(in srgb, var(--a) 9%, var(--surface)), var(--surface) 70%); }
.wpg-tile--hub .wpg-tile__text b { font-size: 16px; }
.wpg-tile--hub .wpg-tile__text small { font-size: 13px; white-space: normal; }

@media (max-width: 520px) {
    .wpg-card { padding: 18px 16px; }
    .wpg-main .wpg-hub__h1 { font-size: 27px !important; }
    .wpg-grid.wpg-grid--hub { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wpg-tile--hub { padding: 10px; gap: 9px; flex-direction: column; align-items: flex-start; }
    .wpg-main .wpg-about__h1 { font-size: 23px !important; }
    .wpg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .wpg-tile { padding: 9px; gap: 8px; min-width: 0; }
    .wpg-tile .wpg-icon { width: 30px; height: 30px; font-size: 13px; }
}
