@font-face
{
    font-family: "Bricolage Grotesque";
    src: url("./fonts/bricolage-600.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face
{
    font-family: "Inter";
    src: url("./fonts/inter.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root
{
    --cream: #FBF3E4;
    --panel: #FFFBF0;
    --card: #FFFFFF;
    --line: #E5D9C0;
    --ink: #241F16;
    --softink: #6E6552;
    --marigold: #E8A33C;
    --marigold-deep: #C4842A;
    --marigold-mist: #F8E8CB;
    --hit: #E8A33C;
    --near: #F3D9A4;
    --miss: #D8CFBC;
    --slateink: #241F16;
    --good: #5E8C4A;
    --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
    --tile: 62px;
    font-family: "Inter", system-ui, sans-serif;
    color: var(--ink);
    background: var(--cream);
    font-synthesis: none;
}

*
{
    box-sizing: border-box;
}

body
{
    margin: 0;
    padding: 8px 24px 12px;
    font-size: 14.5px;
    line-height: 1.6;
}

button, a, summary, textarea
{
    -webkit-tap-highlight-color: transparent;
}

button, textarea
{
    font: inherit;
}

button
{
    cursor: pointer;
    color: inherit;
}

button:disabled
{
    cursor: default;
}

button:focus-visible, a:focus-visible, summary:focus-visible, textarea:focus-visible, section:focus-visible, .board:focus-visible
{
    outline: 2px solid var(--marigold);
    outline-offset: 3px;
}

[hidden]
{
    display: none !important;
}

.shell
{
    max-width: 560px;
    margin: 0 auto;
}

.topbar
{
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--cream);
    z-index: 3;
}

.wordmark
{
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    font: 600 26px / 1 "Bricolage Grotesque", system-ui, sans-serif;
    letter-spacing: -1.1px;
    color: var(--ink);
    text-decoration: none;
}

.brand-dot
{
    width: 7px;
    height: 7px;
    background: var(--marigold);
    border-radius: 50%;
}

.top-actions
{
    display: flex;
    gap: 4px;
}

.icon-button
{
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
}

.icon-button:hover
{
    background: var(--marigold-mist);
}

svg
{
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

.intro
{
    text-align: center;
    padding: 18px 0 20px;
}

.eyebrow
{
    margin: 0 0 7px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.55px;
    text-transform: uppercase;
    color: var(--softink);
}

h1, h2, .answer
{
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: -0.8px;
}

h1
{
    font-size: 29px;
    line-height: 1.2;
    margin: 0 0 16px;
}

.round-meta
{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--softink);
    font-size: 11px;
}

.puzzle-pill
{
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
}

.board
{
    display: grid;
    width: max-content;
    margin: auto;
    gap: 8px;
}

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

.tile
{
    display: grid;
    place-items: center;
    width: var(--tile);
    height: var(--tile);
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    font-size: 26px;
    line-height: 1;
    font-weight: 700;
    position: relative;
    transform-style: preserve-3d;
}

.tile[data-state="typed"]
{
    border-color: #A99B80;
}

[data-state="hit"]
{
    background: var(--hit);
    border-color: var(--hit);
    color: var(--slateink);
}

[data-state="near"]
{
    background: var(--near);
    border-color: #6E5536;
}

.tile[data-state="near"]::after, .example-tile[data-state="near"]::after
{
    content: "";
    width: 4px;
    height: 4px;
    background: #6E5536;
    border-radius: 50%;
    position: absolute;
    bottom: 5px;
    left: calc(50% - 2px);
}

[data-state="miss"]
{
    background: var(--miss);
    border-color: var(--miss);
}

.tile.typed
{
    animation: pop 90ms ease-out;
}

.flipping .tile
{
    animation: flip 520ms var(--ease-io) calc(var(--i) * 110ms) both;
}

.shake
{
    animation: shake 300ms linear;
}

.bounce .tile
{
    animation: bounce 180ms ease-out calc(var(--i) * 80ms);
}

.board-status
{
    text-align: center;
    color: var(--softink);
    font-size: 12px;
    margin: 12px 0 20px;
    min-height: 20px;
}

.keyboard
{
    display: grid;
    gap: 6px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

.key-row:nth-child(2)
{
    padding: 0 24px;
}

.key
{
    display: grid;
    place-items: center;
    min-width: 0;
    height: 44px;
    flex: 1;
    padding: 0;
    border: 2px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    font-size: 14px;
    font-weight: 600;
    transition: transform 100ms, background 100ms;
}

.key-row:last-child .key
{
    height: 52px;
}

.key.key-wide
{
    flex: 1.65;
    font-size: 11px;
}

.key[data-key="Enter"]
{
    background: var(--marigold-mist);
    border-color: var(--line);
}

.key[data-state="hit"]
{
    background: var(--hit);
    border-color: var(--hit);
}

.key[data-state="near"]
{
    border-color: #6E5536;
    background: var(--card);
    position: relative;
}

.key[data-state="near"]::after
{
    content: "";
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #6E5536;
    position: absolute;
    bottom: 4px;
}

.key[data-state="miss"]
{
    background: var(--miss);
    border-color: var(--miss);
    color: rgba(36, 31, 22, 0.45);
}

.key:hover:not(:disabled)
{
    transform: translateY(-1px);
    border-color: var(--marigold-deep);
}

.key:active:not(:disabled)
{
    transform: translateY(1px);
}

.legend
{
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0 0;
    color: var(--softink);
    font-size: 10px;
}

.legend > span
{
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend i
{
    width: 9px;
    height: 9px;
    border: 1px solid transparent;
    border-radius: 3px;
}

.legend i[data-state="near"]
{
    border-color: #6E5536;
}

footer
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid var(--line);
    margin-top: 20px;
    padding: 13px 0 0;
    font-size: 9px;
    color: var(--softink);
}

footer a
{
    color: inherit;
    text-underline-offset: 3px;
    text-decoration-color: var(--line);
}

.result-panel
{
    max-width: 420px;
    margin: 0 auto;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
    animation: rise 420ms cubic-bezier(0.16, 1.2, 0.3, 1);
}

h2
{
    margin: 0 0 4px;
    font-size: 26px;
    line-height: 1.25;
}

.answer
{
    margin: 7px 0 20px;
    font-size: 30px;
    letter-spacing: 5px;
}

.loss-copy, .empty-stats, .history p
{
    color: var(--softink);
    font-size: 12px;
    line-height: 1.6;
}

.stats-grid
{
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 22px 0;
}

.stats-grid > div
{
    display: flex;
    flex-direction: column-reverse;
}

dt
{
    font-size: 11px;
    color: var(--softink);
}

dd
{
    font-size: 25px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin: 0;
    line-height: 1.3;
}

dd small
{
    font-size: 13px;
}

.distribution-title
{
    display: flex;
    align-items: center;
    justify-content: space-between;
}

h3
{
    font-size: 12px;
    font-weight: 600;
    margin: 0;
}

.text-button
{
    background: none;
    border: none;
    padding: 8px 0 8px 8px;
    font-size: 10px;
    color: var(--softink);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.distribution
{
    display: grid;
    gap: 5px;
    margin: 8px 0 20px;
}

.distribution-row
{
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.bar-track
{
    flex: 1;
    text-align: left;
}

.bar
{
    display: block;
    min-width: 22px;
    width: var(--width);
    background: var(--miss);
    border-radius: 3px;
    text-align: right;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    animation: grow 400ms ease-out var(--delay) both;
}

.bar.winning
{
    background: var(--marigold);
}

.result-actions
{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 20px;
}

.primary, .ghost
{
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    background: transparent;
}

.primary
{
    background: var(--marigold);
    border-color: var(--marigold);
}

.primary:hover
{
    background: var(--marigold-deep);
    border-color: var(--marigold-deep);
}

.ghost:hover
{
    background: var(--marigold-mist);
}

.rotation
{
    font-size: 10px;
    color: var(--softink);
    margin: 14px 0 0;
}

.back-button
{
    width: 100%;
    margin-top: 16px;
}

.history
{
    margin: 18px 0 0;
    border-top: 1px solid var(--line);
    text-align: left;
    font-size: 11px;
}

.history summary
{
    cursor: pointer;
    padding: 10px 0;
    color: var(--softink);
}

.history ol
{
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 160px;
    overflow: auto;
}

.history li
{
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.reset-confirm
{
    background: var(--marigold-mist);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    font-size: 12px;
}

.reset-confirm p
{
    margin: 0 0 12px;
}

.share-fallback
{
    width: 100%;
    min-height: 150px;
    margin-top: 16px;
    padding: 10px;
    font-size: 12px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
}

dialog
{
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100dvh - 40px);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    overflow: auto;
    animation: modal-in 200ms ease-out;
}

dialog::backdrop
{
    background: rgba(36, 31, 22, 0.35);
    backdrop-filter: blur(3px);
}

.modal-top
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: -10px;
}

.modal-top .eyebrow
{
    margin: 0;
}

dialog h2
{
    margin: 5px 0 20px;
    font-size: 32px;
}

#help-rules p
{
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.6;
}

.help-examples
{
    display: grid;
    gap: 18px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 20px 0;
    margin-top: 20px;
}

.example-word
{
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}

.example-tile
{
    width: 33px;
    height: 35px;
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 7px;
    font-size: 14px;
    font-weight: 700;
    position: relative;
}

.example-tile[data-state="hit"]
{
    border-color: var(--hit);
}

.example-tile[data-state="near"]
{
    border-color: #6E5536;
}

.example-tile[data-state="near"]::after
{
    width: 3px;
    height: 3px;
    bottom: 2px;
}

.example strong
{
    display: block;
    font-size: 12px;
    line-height: 1.4;
}

.example p
{
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--softink);
}

.dry-line
{
    font-size: 11px;
    color: var(--softink);
    line-height: 1.7;
    margin: 16px 0;
}

.help-start
{
    width: 100%;
}

.toast
{
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    width: max-content;
    z-index: 10;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 11px 20px;
    background: var(--marigold-mist);
    box-shadow: 0 4px 15px rgba(36, 31, 22, 0.08);
    font-size: 13px;
    text-align: center;
    animation: toast-in 160ms ease-out;
}

@keyframes pop
{
    from { transform: scale(0.9); }
    to { transform: scale(1); }
}

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

@keyframes shake
{
    0%, 100% { transform: translateX(0); }
    8%, 41%, 74% { transform: translateX(-6px); }
    24%, 57%, 90% { transform: translateX(6px); }
}

@keyframes bounce
{
    0%, 100% { transform: translateY(0); }
    45% { transform: translateY(-8px); }
}

@keyframes rise
{
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes grow
{
    from { width: 0; }
    to { width: var(--width); }
}

@keyframes modal-in
{
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes toast-in
{
    from { transform: translate(-50%, 6px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@media (max-width: 480px)
{
    :root
    {
        --tile: min(52px, calc((100vw - 64px) / 5));
    }
    body
    {
        padding: 8px 14px 12px;
    }
    .wordmark
    {
        font-size: 24px;
    }
    .intro
    {
        padding: 21px 0;
    }
    h1
    {
        font-size: 25px;
    }
    .eyebrow
    {
        font-size: 9px;
        letter-spacing: 1.1px;
    }
    .round-meta
    {
        font-size: 10px;
    }
    .key-row
    {
        gap: 4px;
    }
    .key-row:nth-child(2)
    {
        padding: 0 15px;
    }
    .key
    {
        font-size: 12px;
        border-radius: 8px;
    }
    .key.key-wide
    {
        font-size: 9px;
    }
    .board-status
    {
        margin-bottom: 20px;
        font-size: 11px;
    }
    .legend
    {
        gap: 16px;
        margin-top: 20px;
        font-size: 9px;
    }
    footer
    {
        font-size: 8px;
        margin-top: 20px;
    }
    .result-panel
    {
        padding: 20px;
    }
    dialog
    {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce)
{
    *, *::before, *::after
    {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
    .bar
    {
        width: var(--width);
    }
}
