:root {
    --bg: #0b0b0d;

    /* NYT-ish base grays */
    --tile-empty: #3a3a3c;
    --key: #818384;
    --key-text: #ffffff;

    /* Locked palette */
    --correct: #538D4E;
    /* green */
    --present: #2F7F8A;
    /* teal */
    --absent: #3A3A3C;
    /* charcoal */

    --text: #ffffff;
    --muted: #bdbdbf;

    --font: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

    /* Core sizing */
    --gap: 6px;

    /* Keyboard width clamp */
    --kb-max: 520px;
    --kb-w: min(var(--kb-max), 92vw);

    /* Key height clamp */
    --key-h: clamp(44px, 6.2vw, 58px);

    /* Key corner radius */
    --key-r: 6px;

    /* Wide key multiplier */
    --wide-mult: 1.5;

    /* Letter-key width derived from kb width (10 keys + 9 gaps) */
    --key-w: calc((var(--kb-w) - (9 * var(--gap))) / 10);

    /* Board tiles tied to the same scale */
    --tile: clamp(44px, calc(var(--key-w) * 1.10), 64px);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;

    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* App skeleton */
.app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header */
.topbar {
    width: 100%;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid #2a2a2c;
}

.title {
    font-weight: 900;
    letter-spacing: .5px;
    text-transform: uppercase;
    font-size: 26px;
    line-height: 1;
    margin: 0;
}

.date {
    margin: 2px 0 0 0;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .6px;
    text-transform: uppercase;
}

/* Frame */
.frame {
    width: var(--kb-w);
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Share / mode buttons */

.icon-btn {
    width: 64px;
    height: 64px;
    border: 0;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    cursor: pointer;
    touch-action: manipulation;
}

.icon-btn:active {
    opacity: .65;
}

/* Share button disabled (keeps layout, still clickable to show message) */
.icon-btn.disabled {
    opacity: .35;
}

.icon-btn.disabled:active {
    opacity: .35;
}

.share-ic {
    width: 40px;
    height: 40px;
    fill: currentColor;
    opacity: .95;
}

.stats-ic {
    width: 34px;
    height: 34px;
    fill: currentColor;
    opacity: .95;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-ic {
    font-size: 28px;
    line-height: 1;
}

/* Centered play area */
.playwrap {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

.playarea {
    width: var(--kb-w);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Board */
.board {
    width: calc((var(--tile) * 5) + (var(--gap) * 4));
    display: grid;
    grid-template-rows: repeat(6, var(--tile));
    gap: var(--gap);
}

.row {
    display: grid;
    grid-template-columns: repeat(5, var(--tile));
    gap: var(--gap);
}

.tile {
    width: var(--tile);
    height: var(--tile);
    background: var(--tile-empty);
    opacity: .35;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    /* sharp tiles */
    font-weight: 900;
    text-transform: uppercase;
    font-size: calc(var(--tile) * 0.55);
    line-height: 1;
    color: var(--text);
    touch-action: manipulation;
}

.tile.pinned {
    outline: 2px solid rgba(255, 255, 255, 0.55);
    outline-offset: -2px;
}

.tile.filled {
    opacity: 1;
}

/* Selected tile highlight */
.tile.cursor {
    outline: none;
    background: #4a4a4c;
    opacity: 1;
}

/* Result colors */
.tile.correct {
    background: var(--correct);
    opacity: 1;
}

.tile.present {
    background: var(--present);
    opacity: 1;
}

.tile.absent {
    background: var(--absent);
    opacity: 1;
}

.tile.hidden {
    opacity: 0;
    background: transparent;
}

/* Message */
.msg {
    min-height: 18px;
    width: 100%;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .2px;
    white-space: pre-line;
    line-height: 1.25;
}

/* Keyboard */
.kb {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

/* Top ENTER bar */
.enterbar {
    height: calc(var(--key-h) * 1);
    border-radius: var(--key-r);
    background: #6f7072;
    color: var(--key-text);
    border: 0;
    font-weight: 900;
    letter-spacing: .8px;
    text-transform: uppercase;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    touch-action: manipulation;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.enterbar:active {
    filter: brightness(.92);
}

/* Rows */
.kb-row {
    display: flex;
    justify-content: center;
    gap: var(--gap);
    width: fit-content;
    margin: 0 auto;
}

/* Keys */
.key {
    width: var(--key-w);
    height: var(--key-h);
    border-radius: var(--key-r);
    background: var(--key);
    color: var(--key-text);
    border: 0;
    font-weight: 900;
    text-transform: uppercase;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-width: 0;
    touch-action: manipulation;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.key:active {
    filter: brightness(.92);
}

/* Remove browser focus ring for game buttons */
.key:focus,
.key:focus-visible,
.enterbar:focus,
.enterbar:focus-visible,
.icon-btn:focus,
.icon-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Wide keys (CLEAR, ⌫) */
.key.wide {
    width: calc(var(--key-w) * var(--wide-mult));
    padding: 0 8px;
    font-size: clamp(9px, 2.6vw, 13px);
    letter-spacing: .5px;
}

/* Used key coloring */
.k-correct {
    background: var(--correct);
}

.k-present {
    background: var(--present);
}

.k-absent {
    background: var(--absent);
}

.key.used {
    opacity: .95;
}



/* Mobile: fill more of the screen */
@media (max-width: 899px) {
    :root {
        --kb-w: min(var(--kb-max), 98vw);
        --tile: clamp(52px, calc(var(--key-w) * 1.45), 78px);
    }
}

/* Desktop */
@media (min-width: 900px) {
    :root {
        --tile: clamp(44px, calc(var(--key-w) * 1.3), 76px);
    }

    .topbar {
        padding: 18px 18px 10px;
    }

    .playwrap {
        padding: 18px;
    }

    .playarea {
        gap: 14px;
    }

    .msg {
        font-size: 13px;
    }
}