@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
    --bg-1: #070b14;
    --bg-2: #0c1321;
    --bg-3: #141c2b;
    --bg-4: #101828;

    --surface: rgba(16, 25, 40, 0.84);
    --surface-2: rgba(20, 32, 52, 0.9);
    --surface-soft: rgba(25, 40, 62, 0.62);
    --stroke: #273954;
    --stroke-strong: #345071;
    --shadow: 0 24px 48px rgba(0, 0, 0, 0.35);

    --text: #edf4ff;
    --text-muted: #9eb2cb;
    --text-subtle: #7f94ae;

    --accent: #5ab0ff;
    --accent-soft: #2f72ae;
    --accent-warm: #f0c674;

    --hint-bg: rgba(46, 82, 120, 0.38);
    --hint-stroke: #4b7aac;
    --loading-bg: rgba(62, 104, 96, 0.4);
    --loading-stroke: #57a698;
    --error-bg: rgba(135, 42, 63, 0.38);
    --error-stroke: #d15476;
    --success-bg: rgba(47, 112, 77, 0.38);
    --success-stroke: #55bb85;
    --failure-bg: rgba(132, 87, 35, 0.38);
    --failure-stroke: #dfad67;

    --cell-bg: #1a283f;
    --cell-stroke: #345070;
    --cell-focus: #4da7f3;
    --cell-locked: #22344f;

    --correct: #d84f62;
    --present: #f0c257;
    --absent: #3e7bab;

    --key-bg: #1a2942;
    --key-stroke: #304a6a;
    --key-text: #e8f1ff;
    --key-hover: #223654;
    --key-absent-bg: #152235;
    --key-absent-stroke: #243a57;
    --key-absent-text: #4f647f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 6%, rgba(83, 164, 255, 0.22) 0%, transparent 38%),
        radial-gradient(circle at 86% 8%, rgba(102, 182, 157, 0.2) 0%, transparent 34%),
        radial-gradient(circle at 15% 92%, rgba(180, 118, 255, 0.08) 0%, transparent 40%),
        linear-gradient(145deg, var(--bg-1), var(--bg-2) 36%, var(--bg-3) 70%, var(--bg-4));
    overflow-x: hidden;
    position: relative;
}

body::before,
body::after {
    content: '';
    position: fixed;
    pointer-events: none;
    z-index: 0;
    border-radius: 999px;
    filter: blur(2px);
}

body::before {
    width: 280px;
    height: 280px;
    right: -110px;
    top: 24%;
    background: rgba(93, 151, 221, 0.2);
}

body::after {
    width: 220px;
    height: 220px;
    left: -70px;
    bottom: 6%;
    background: rgba(59, 124, 159, 0.2);
}

.app-shell {
    width: min(1060px, 100%);
    margin: 0 auto;
    padding: 32px 16px 34px;
    position: relative;
    z-index: 1;
    animation: app-enter 420ms ease;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 22px;
}

.title-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kicker {
    margin: 0;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--text-subtle);
}

h1 {
    margin: 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2.45rem, 4vw, 3.35rem);
    line-height: 0.96;
    color: #f1f7ff;
    letter-spacing: 0.02em;
    text-shadow: 0 8px 30px rgba(0, 0, 0, 0.32);
}

.menu-dropdown {
    position: relative;
}

.menu-dropdown summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    min-height: 48px;
    padding: 10px 46px 10px 18px;
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text);
    border-radius: 999px;
    border: 1px solid var(--stroke-strong);
    background: linear-gradient(140deg, rgba(29, 45, 70, 0.95), rgba(20, 34, 54, 0.95));
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
    transition: transform 0.12s ease, border-color 0.16s ease, background 0.16s ease;
    position: relative;
}

.menu-dropdown summary:hover {
    border-color: #4f76a3;
    background: linear-gradient(140deg, rgba(33, 52, 80, 0.98), rgba(24, 39, 61, 0.98));
}

.menu-dropdown summary::after {
    content: '';
    position: absolute;
    right: 18px;
    top: 16px;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease, top 0.15s ease;
}

.menu-dropdown[open] summary::after {
    transform: rotate(225deg);
    top: 20px;
}

.menu-dropdown summary::-webkit-details-marker {
    display: none;
}

.menu-dropdown__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: min(360px, calc(100vw - 32px));
    border-radius: 16px;
    border: 1px solid var(--stroke-strong);
    background: linear-gradient(162deg, rgba(18, 30, 47, 0.98), rgba(14, 24, 38, 0.96));
    box-shadow: var(--shadow);
    padding: 14px;
    z-index: 25;
    animation: menu-drop 190ms ease;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.config-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.config-row {
    display: flex;
    gap: 10px;
}

select,
button {
    font: inherit;
}

select {
    flex: 0 0 100px;
    border-radius: 10px;
    border: 1px solid #3f5b7f;
    background: #14253b;
    color: var(--text);
    padding: 8px 10px;
    font-weight: 700;
}

button {
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}

.config-row button {
    flex: 1;
    color: #05111f;
    font-weight: 700;
    border-color: transparent;
    background: linear-gradient(130deg, #72c1ff, #5da3e0);
    padding: 8px 12px;
    transition: transform 0.12s ease, filter 0.15s ease;
}

.config-row button:hover {
    filter: brightness(1.06);
}

.config-row button:active {
    transform: translateY(1px);
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 2px;
}

.sound-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.sound-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.menu-legend {
    border-top: 1px dashed rgba(118, 153, 196, 0.4);
    margin-top: 8px;
    padding-top: 12px;
}

.menu-legend h2 {
    margin: 0 0 8px;
    color: #d6e7fb;
    font-size: 14px;
    font-weight: 600;
}

.menu-legend p {
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    display: inline-block;
}

.legend-dot--correct {
    background: var(--correct);
}

.legend-dot--present {
    background: var(--present);
}

.legend-dot--absent {
    background: var(--absent);
}

.status-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 20px;
}

.message,
.attempt {
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: var(--surface);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.message {
    min-height: 58px;
    padding: 13px 16px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

.attempt {
    min-width: 136px;
    min-height: 58px;
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 14px;
    color: var(--text-muted);
    font-size: 14px;
}

.attempt strong {
    color: var(--text);
    font-weight: 700;
}

.message--hint {
    background: var(--hint-bg);
    border-color: var(--hint-stroke);
}

.message--loading {
    background: var(--loading-bg);
    border-color: var(--loading-stroke);
}

.message--error {
    background: var(--error-bg);
    border-color: var(--error-stroke);
}

.message--success {
    background: var(--success-bg);
    border-color: var(--success-stroke);
}

.message--failure {
    background: var(--failure-bg);
    border-color: var(--failure-stroke);
}

.game-layout {
    display: grid;
    gap: 14px;
}

.board-panel,
.keyboard-panel {
    border-radius: 20px;
    border: 1px solid var(--stroke);
    background: linear-gradient(170deg, var(--surface), var(--surface-2));
    box-shadow: var(--shadow);
}

.board-panel {
    padding: 20px 14px;
    overflow: hidden;
    position: relative;
}

.board-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0 49.25%,
        rgba(105, 145, 189, 0.14) 49.25% 50.75%,
        transparent 50.75%
    );
    pointer-events: none;
}

.keyboard-panel {
    padding: 14px 14px 16px;
}

#game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s ease;
    position: relative;
    z-index: 1;
}

#game.is-pending {
    opacity: 0.82;
}

.row {
    display: flex;
    gap: 8px;
    padding: 2px;
    border-radius: 13px;
    transition: box-shadow 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.row.active {
    box-shadow: 0 0 0 2px rgba(87, 157, 224, 0.46);
}

.row.revealing {
    box-shadow: 0 0 0 2px rgba(102, 178, 134, 0.4);
}

.row.completed {
    opacity: 0.95;
}

.cell {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    border: 2px solid var(--cell-stroke);
    background: var(--cell-bg);
    color: #f0f6ff;
    font-size: 1.74rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    user-select: none;
    transition: transform 0.14s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.cell.current {
    box-shadow: 0 0 0 2px rgba(8, 20, 33, 0.98), 0 0 0 4px rgba(77, 167, 243, 0.7);
}

.cell.locked {
    background: var(--cell-locked);
}

.cell.prefilled {
    box-shadow: inset 0 0 0 1px rgba(145, 181, 218, 0.24);
}

.cell.typing {
    transform: translateY(-1px) scale(1.03);
}

.cell.reveal {
    animation: tile-reveal 190ms ease;
}

.cell.correct {
    background: var(--correct);
    border-color: #e78190;
    color: #fff;
}

.cell.present {
    background: var(--present);
    border-color: #f1d383;
    color: #2f2507;
}

.cell.absent {
    background: var(--absent);
    border-color: #7aa6cb;
    color: #e7f4ff;
}

.keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s ease;
}

.keyboard.is-locked {
    opacity: 0.72;
}

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

.key {
    min-width: 42px;
    height: 48px;
    padding: 0 12px;
    border-radius: 11px;
    border: 1px solid var(--key-stroke);
    background: var(--key-bg);
    color: var(--key-text);
    font-size: 0.95rem;
    font-weight: 700;
    transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.key:hover {
    background: var(--key-hover);
    border-color: #4a6f98;
}

.key:active {
    transform: scale(0.98);
}

.key.wide {
    min-width: 96px;
}

.key.correct {
    background: var(--correct);
    border-color: #e07283;
    color: #fff;
}

.key.present {
    background: var(--present);
    border-color: #ebce7f;
    color: #332708;
}

.key.absent {
    background: var(--key-absent-bg);
    border-color: var(--key-absent-stroke);
    color: var(--key-absent-text);
    opacity: 0.24;
}

.key.disabled {
    opacity: 0.2;
    pointer-events: none;
    cursor: not-allowed;
}

.shake {
    animation: shake 0.22s linear 2;
}

@keyframes app-enter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes menu-drop {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    50% {
        transform: translateX(4px);
    }
    75% {
        transform: translateX(-4px);
    }
    100% {
        transform: translateX(0);
    }
}

@keyframes tile-reveal {
    0% {
        transform: rotateX(0deg) scale(1);
    }
    50% {
        transform: rotateX(90deg) scale(1.03);
    }
    100% {
        transform: rotateX(0deg) scale(1.04);
    }
}

@media (max-width: 760px) {
    .app-shell {
        padding: 16px 10px 22px;
    }

    .app-header {
        align-items: center;
        margin-bottom: 16px;
    }

    h1 {
        font-size: clamp(2rem, 11vw, 2.6rem);
    }

    .menu-dropdown__panel {
        width: min(340px, calc(100vw - 20px));
        right: -6px;
    }

    .status-strip {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 14px;
    }

    .attempt {
        min-width: 0;
    }

    .board-panel {
        padding: 14px 8px;
    }

    .keyboard-panel {
        padding: 12px 8px 14px;
    }

    .cell {
        width: 42px;
        height: 42px;
        font-size: 1.26rem;
        border-radius: 10px;
    }

    .key {
        min-width: 34px;
        height: 42px;
        padding: 0 8px;
        font-size: 0.84rem;
        border-radius: 9px;
    }

    .key.wide {
        min-width: 72px;
    }
}
