:root {
    --paper: #fbf4e8;
    --paper-soft: #fffaf1;
    --ink: #20160f;
    --muted: #73695f;
    --line: #ded5c7;
    --orange: #e87841;
    --green: #48a654;
    --gold: #e6aa2c;
    --charcoal: #4d4742;
    --shadow: 0 18px 42px rgba(68, 50, 31, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 77% 20%, rgba(239, 176, 134, 0.24), transparent 34rem),
        radial-gradient(circle at 20% 10%, rgba(255, 248, 230, 0.85), transparent 26rem),
        linear-gradient(180deg, #fff6e9 0%, #fbf1e3 48%, #fcf7ed 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
    font: inherit;
}

.lexicon-header {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px 0 10px;
    border-top: 1px solid rgba(32, 22, 15, 0.85);
    border-bottom: 1px solid rgba(91, 74, 56, 0.13);
    background: rgba(255, 247, 235, 0.82);
    backdrop-filter: blur(18px);
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
    margin-left: 26px; /* Adjust this value */
}

.brand-logo {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 13px;
    object-fit: cover;
}

.brand-name {
    display: block;
    margin-bottom: 2px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
             Oxygen, Ubuntu, Cantarell, 'Open Sans',
             'Helvetica Neue', sans-serif;
    font-size: 23px;
    font-weight: bold;
    line-height: 0.95;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #675d54;
    cursor: pointer;
    font-size: 25px;
    font-weight: 800;
}

.icon-btn:hover,
.pill-btn:hover,
.primary-btn:hover,
.close-btn:hover {
    transform: translateY(-1px);
}

.game-shell {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 28px 18px 42px;
}

.game-content {
    width: min(100%, 760px);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.loading {
    margin-top: 22vh;
    color: var(--muted);
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.clue-card {
    position: relative;
    width: min(100%, 675px);
    min-height: 160px;
    margin-bottom: 28px;
    padding: 27px 30px 23px;
    border: 1px solid rgba(89, 74, 57, 0.22);
    border-radius: 22px;
    background: rgba(255, 252, 245, 0.88);
    box-shadow: var(--shadow);
}

.clue-tab {
    position: absolute;
    top: -12px;
    left: 28px;
    padding: 5px 14px 6px;
    border-radius: 999px;
    background: var(--orange);
    color: white;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.25em;
}

.clue-text {
    margin: 0 0 17px;
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(24px, 4.6vw, 30px);
    font-weight: 800;
    line-height: 1.32;
}

.clue-part {
    margin: 0;
    color: #74695f;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.game-meta {
    min-height: 22px;
    margin-bottom: 17px;
    color: #756a61;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.34em;
    text-align: center;
}

.dot {
    margin: 0 10px;
}

.message {
    min-height: 24px;
    margin-bottom: 7px;
    color: #7a6d61;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
}

.message.success {
    color: var(--green);
}

.message.error {
    color: #b94a34;
}

.board-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}

.board {
    display: grid;
    gap: 8px;
    justify-content: center;
}

.row {
    display: grid;
    gap: 8px;
    justify-content: center;
}

.tile {
    width: var(--tile-size, 75px);
    height: var(--tile-size, 75px);
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 9px;
    background: rgba(255, 252, 245, 0.74);
    color: #fff;
    font-family: "Playfair Display", Georgia, serif;
    font-size: calc(var(--tile-size, 75px) * 0.52);
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tile.filled {
    border-color: #bcb2a6;
    color: var(--ink);
    transform: scale(1.025);
}

.tile.correct,
.tile.present,
.tile.absent {
    color: #fff;
    border-color: transparent;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.tile.correct {
    background: var(--green);
}

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

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

.tile.flip {
    animation: flip 560ms ease both;
}

.tile.shake {
    animation: shake 380ms ease;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 9px;
    margin-bottom: 27px;
}

.pill-btn,
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 45px;
    border: 1px solid #dfd5c8;
    border-radius: 999px;
    background: rgba(255, 252, 245, 0.78);
    color: #241a13;
    cursor: pointer;
    font-size: 16px;
    font-weight: 850;
    box-shadow: 0 8px 18px rgba(59, 43, 27, 0.07);
    transition: transform 160ms ease, background 160ms ease;
}

.pill-btn {
    padding: 0 20px;
}

.pill-btn:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    transform: none;
}

.btn-icon {
    font-size: 22px;
    line-height: 1;
}

.hint-count {
    color: #756a61;
    font-size: 12px;
    letter-spacing: 0.05em;
}

.keyboard {
    width: min(100%, 548px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    touch-action: manipulation;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 7px;
}

.key {
    width: 47px;
    height: 66px;
    display: grid;
    place-items: center;
    border: 1px solid #e4d9ca;
    border-radius: 10px;
    background: rgba(255, 252, 245, 0.88);
    color: #1f1711;
    cursor: pointer;
    font-size: 17px;
    font-weight: 900;
    text-transform: uppercase;
    box-shadow: 0 3px 8px rgba(56, 42, 27, 0.12);
}

.key.wide {
    width: 85px;
    font-size: 13px;
}

.key.correct,
.key.present,
.key.absent {
    color: #fff;
    border-color: transparent;
}

.key.correct {
    background: var(--green);
}

.key.present {
    background: var(--gold);
}

.key.absent {
    background: var(--charcoal);
}

.result-dialog,
.help-dialog {
    width: min(92vw, 520px);
    padding: 0;
    border: 0;
    border-radius: 24px;
    background: transparent;
}

.result-dialog::backdrop,
.help-dialog::backdrop {
    background: rgba(36, 25, 16, 0.28);
    backdrop-filter: blur(7px);
}

.result-card,
.help-card {
    position: relative;
    padding: 30px;
    border: 1px solid rgba(89, 74, 57, 0.22);
    border-radius: 24px;
    background: #fffaf1;
    box-shadow: 0 30px 80px rgba(36, 25, 16, 0.24);
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 18px;
    width: 32px;
    height: 32px;
    border: 1px solid #dfd5c8;
    border-radius: 50%;
    background: transparent;
    color: #6f6257;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.result-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin: 0 44px 20px 0;
    color: #21170f;
    font-size: 20px;
    font-weight: 900;
}

.result-brand img {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    object-fit: cover;
}

.result-eyebrow {
    margin: 0 0 7px;
    color: var(--orange);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.24em;
}

.result-card h2,
.help-card h2 {
    margin: 0 38px 7px 0;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 38px;
    line-height: 1.05;
}

.result-part {
    margin: 0 0 20px;
    color: #74695f;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.word-details {
    display: grid;
    gap: 16px;
    margin: 0 0 23px;
}

.word-details div {
    padding-top: 15px;
    border-top: 1px solid #eadfce;
}

.word-details dt {
    margin-bottom: 6px;
    color: #756a61;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.17em;
    text-transform: uppercase;
}

.word-details dd {
    margin: 0;
    color: #231912;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.55;
}

.primary-btn {
    width: 100%;
    min-height: 50px;
    background: #20140d;
    color: #fff9eb;
}

.help-card p {
    margin: 12px 0 0;
    color: #4e443b;
    font-weight: 650;
    line-height: 1.6;
}

@keyframes flip {
    0% { transform: rotateX(0deg); }
    45% { transform: rotateX(88deg); }
    100% { transform: rotateX(0deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@media (max-width: 700px) {
    .lexicon-header {
        height: 76px;
        padding-right: 15px;
    }

    .game-shell {
        padding: 24px 12px 28px;
    }

    .clue-card {
        min-height: 145px;
        padding: 25px 22px 20px;
        border-radius: 20px;
    }

    .game-meta {
        font-size: 12px;
        letter-spacing: 0.18em;
    }

    .tile {
        border-radius: 8px;
    }

    .keyboard {
        gap: 7px;
    }

    .kb-row {
        gap: 5px;
    }

    .key {
        width: 9vw;
        max-width: 43px;
        height: 58px;
        border-radius: 9px;
    }

    .key.wide {
        width: 16vw;
        max-width: 76px;
        font-size: 11px;
    }
}

@media (max-width: 440px) {
    .brand-name {
        font-size: 20px;
    }

    .header-actions {
        gap: 8px;
    }

    .controls {
        width: 100%;
    }

    .pill-btn {
        flex: 1;
        padding: 0 12px;
        font-size: 14px;
    }

    .result-card,
    .help-card {
        padding: 26px 21px;
    }
}
