:root {
    --background: #071426;
    --panel: #0c2039;
    --panel-light: #112b49;
    --border: rgba(255, 255, 255, 0.12);
    --text: #f4f7fb;
    --muted: #91a4ba;
    --gold: #f4b942;
    --green: #20c997;
    --danger: #ff7878;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 24px;
    background:
        radial-gradient(circle at top, #17375c 0, transparent 42%),
        var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.game-shell {
    width: min(1440px, 100%);
    min-width: 0;
    margin: 0 auto;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-symbol {
    display: grid;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    place-items: center;
    border: 2px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
    font-size: 34px;
    font-weight: bold;
}

.brand h1 {
    margin: 0;
    font-size: clamp(25px, 3vw, 38px);
}

.brand p {
    margin: 4px 0 0;
    color: var(--muted);
}

.game-status {
    padding: 9px 16px;
    border: 1px solid rgba(244, 185, 66, 0.45);
    border-radius: 999px;
    background: rgba(244, 185, 66, 0.12);
    color: var(--gold);
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

button.game-status {
    cursor: pointer;
}

button.game-status:hover {
    border-color: var(--gold);
    background: rgba(244, 185, 66, 0.2);
}

button.game-status:focus-visible {
    outline: 3px solid rgba(244, 185, 66, 0.35);
    outline-offset: 3px;
}

button.game-status:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.game-layout {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1.05fr) minmax(430px, 0.95fr);
    gap: 22px;
}

.panel {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(12, 32, 57, 0.92);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.wheel-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}

.panel-heading {
    width: 100%;
    margin-bottom: 18px;
}

.panel-heading h2 {
    margin: 0;
    font-size: 22px;
}

.panel-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.wheel-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 16px;
}

.wheel-heading > div {
    min-width: 0;
}

.selected-letters-panel {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    margin: -2px 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(7, 20, 38, 0.58);
}

.selected-letters-panel[hidden] {
    display: none;
}

.selected-letters-label {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.selected-letters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.selected-letter-badge {
    display: grid;
    width: 29px;
    height: 29px;
    place-items: center;
    border: 1px solid rgba(32, 201, 151, 0.52);
    border-radius: 50%;
    background: rgba(32, 201, 151, 0.13);
    color: #66e6bf;
    font-size: 13px;
    font-weight: 800;
}

.selected-letter-badge.is-pending {
    visibility: hidden;
    opacity: 0;
}

.selected-letter-badge.is-arriving {
    animation: selected-letter-arrive 320ms cubic-bezier(0.2, 0.85, 0.24, 1.3);
}

.flying-selected-letter {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 2px solid rgba(102, 230, 191, 0.9);
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.24), transparent 35%),
        #102d43;
    color: #d8fff2;
    box-shadow:
        0 0 18px rgba(83, 224, 181, 0.72),
        0 8px 24px rgba(0, 0, 0, 0.42);
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    pointer-events: none;
    will-change: transform, opacity;
}

@keyframes selected-letter-arrive {
    0% {
        transform: scale(0.68);
        filter: brightness(1.8);
        box-shadow: 0 0 0 rgba(83, 224, 181, 0);
    }
    62% {
        transform: scale(1.22);
        filter: brightness(1.3);
        box-shadow: 0 0 18px rgba(83, 224, 181, 0.7);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
        box-shadow: 0 0 0 rgba(83, 224, 181, 0);
    }
}

.selected-letters-empty {
    color: var(--muted);
    font-size: 13px;
}

.wheel-stage {
    display: grid;
    width: min(100%, 620px);
    min-width: 0;
    max-width: 100%;
    aspect-ratio: 1;
    place-items: center;
}

.wheel-stage object {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 100%;
}

.setup-panel {
    padding: 24px;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    max-height: 540px;
    padding-right: 4px;
    overflow-y: auto;
}

.word-field {
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel-light);
}

.word-number {
    min-width: 36px;
    padding: 11px 6px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.word-field input {
    width: 100%;
    min-width: 0;
    padding: 11px 10px 11px 4px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    text-transform: uppercase;
}

.word-field:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(244, 185, 66, 0.12);
}

.word-field.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(255, 120, 120, 0.12);
}

.active-word-field {
    min-height: 45px;
}

.active-word-text {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: clamp(1px, 0.35vw, 4px);
    padding: 9px 7px 9px 2px;
    color: var(--text);
    font-size: clamp(12px, 1.25vw, 17px);
    font-weight: 800;
    letter-spacing: 0.03em;
}

.active-word-letter {
    display: inline-block;
    min-width: 0.72em;
    text-align: center;
    transition: color 180ms ease;
}

.active-word-letter.is-selected {
    color: #53e0b5;
    text-decoration: line-through;
    text-decoration-color: #53e0b5;
    text-decoration-thickness: 2px;
}

.validation-summary {
    margin: 0 0 14px;
    padding: 11px 13px;
    border: 1px solid rgba(255, 120, 120, 0.55);
    border-radius: 9px;
    background: rgba(255, 120, 120, 0.1);
    color: #ffd2d2;
    font-size: 14px;
    line-height: 1.45;
}

.validation-summary[hidden] {
    display: none;
}

.game-validation-modal .modal-dialog {
    width: min(560px, calc(100% - 28px));
    margin-inline: auto;
}

.game-validation-modal .modal-content {
    overflow: hidden;
    border: 1px solid rgba(244, 185, 66, 0.34);
    border-radius: 20px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}

.game-validation-modal .modal-header,
.game-validation-modal .modal-footer {
    border-color: var(--border);
}

.game-validation-modal .modal-header {
    align-items: flex-start;
    padding: 22px 24px 18px;
}

.game-validation-modal .modal-title {
    margin: 0;
    color: var(--gold);
    font-size: 24px;
    font-weight: 700;
}

.game-validation-modal .modal-eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
}

.game-validation-modal .modal-body {
    padding: 22px 24px;
}

.game-validation-modal .validation-error-alert {
    margin: 0;
    border-color: rgba(255, 120, 120, 0.52);
    background: rgba(255, 120, 120, 0.1);
    color: #ffd2d2;
}

.validation-error-heading {
    margin: 0 0 8px;
    font-weight: 700;
}

.game-validation-modal ul {
    margin: 0;
    padding-left: 21px;
}

.game-validation-modal li + li {
    margin-top: 6px;
}

.game-validation-rules {
    margin-top: 18px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(17, 43, 73, 0.72);
}

.game-validation-rules h3 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 16px;
}

.game-validation-rules ul {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.game-validation-modal .modal-footer {
    padding: 16px 24px 22px;
}

.game-validation-modal .modal-footer .button {
    min-width: 205px;
}

.game-winner-modal .modal-dialog {
    width: min(540px, calc(100% - 28px));
    margin-inline: auto;
}

.game-winner-modal .modal-content {
    overflow: hidden;
    border: 1px solid rgba(244, 185, 66, 0.52);
    border-radius: 22px;
    background:
        radial-gradient(circle at top, rgba(244, 185, 66, 0.12), transparent 48%),
        var(--panel);
    color: var(--text);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.64);
}

.game-winner-modal .modal-header,
.game-winner-modal .modal-footer {
    border-color: var(--border);
}

.game-winner-modal .modal-header {
    align-items: flex-start;
    padding: 24px;
}

.game-winner-modal .modal-eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
}

.game-winner-modal .modal-title {
    margin: 0;
    color: var(--gold);
    font-size: clamp(30px, 6vw, 44px);
    font-weight: 900;
    letter-spacing: 0.04em;
}

.game-winner-modal .modal-body {
    padding: 22px 24px;
}

.game-winner-summary {
    margin: 0 0 15px;
    color: var(--muted);
    line-height: 1.45;
}

.game-winner-list {
    display: grid;
    gap: 9px;
}

.game-winner-entry {
    padding: 13px 15px;
    border: 1px solid rgba(244, 185, 66, 0.3);
    border-radius: 11px;
    background: rgba(17, 43, 73, 0.82);
    color: var(--text);
}

.game-winner-entry span {
    color: var(--muted);
}

.game-winner-entry strong {
    color: #66e6bf;
    letter-spacing: 0.08em;
}

.game-winner-modal .modal-footer {
    padding: 16px 24px 22px;
}

.game-actions {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 12px;
    margin-top: 20px;
}

.button {
    min-height: 50px;
    padding: 12px 18px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font-weight: bold;
    transition:
        transform 150ms ease,
        background-color 150ms ease,
        border-color 150ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.button:focus-visible {
    outline: 3px solid rgba(244, 185, 66, 0.35);
    outline-offset: 3px;
}

.button-secondary {
    border: 1px solid var(--border);
    background: var(--panel-light);
    color: var(--text);
}

.button-primary {
    background: var(--gold);
    color: #221600;
}

.button-primary:hover {
    background: #ffc95c;
}

.button-shuffle {
    min-height: 42px;
    padding: 9px 14px;
    border: 1px solid rgba(244, 185, 66, 0.62);
    background: rgba(244, 185, 66, 0.1);
    color: var(--gold);
    font-size: 14px;
    white-space: nowrap;
}

.button-shuffle:hover {
    border-color: var(--gold);
    background: rgba(244, 185, 66, 0.18);
}

.settings-modal {
    width: min(520px, calc(100% - 28px));
    padding: 0;
    border: 1px solid rgba(244, 185, 66, 0.32);
    border-radius: 20px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}

.settings-modal::backdrop {
    background: rgba(2, 9, 20, 0.76);
    backdrop-filter: blur(4px);
}

.settings-modal form {
    padding: 24px;
}

.settings-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.settings-modal-header h2 {
    margin: 0;
    color: var(--gold);
    font-size: 24px;
}

.settings-modal-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.settings-modal-close {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--panel-light);
    color: var(--text);
    cursor: pointer;
    font-size: 25px;
    line-height: 1;
}

.settings-modal-close:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.settings-modal-close:focus-visible {
    outline: 3px solid rgba(244, 185, 66, 0.35);
    outline-offset: 2px;
}

.settings-fields {
    display: grid;
    gap: 16px;
    padding: 20px 0;
}

.settings-field {
    display: grid;
    gap: 7px;
}

.settings-field > span {
    font-weight: bold;
}

.settings-field input,
.settings-field select {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: 0;
    background: var(--panel-light);
    color: var(--text);
}

.settings-field input:focus,
.settings-field select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(244, 185, 66, 0.12);
}

.settings-field select option {
    background: var(--panel);
    color: var(--text);
}

.settings-field small {
    color: var(--muted);
    line-height: 1.35;
}

.settings-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 12px;
    padding-top: 4px;
}

@media (max-width: 980px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .wheel-stage {
        width: min(100%, 560px);
    }
}

@media (max-width: 620px) {
    body {
        padding: 14px;
    }

    .game-header {
        align-items: flex-start;
    }

    .brand {
        gap: 12px;
    }

    .brand-symbol {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
        font-size: 30px;
    }

    .brand p {
        display: none;
    }

    .game-status {
        padding: 7px 11px;
        font-size: 11px;
    }

    .panel,
    .wheel-panel,
    .setup-panel {
        border-radius: 16px;
    }

    .wheel-panel,
    .setup-panel {
        padding: 16px;
    }

    .wheel-heading {
        gap: 10px;
    }

    .button-shuffle {
        min-height: 38px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .word-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 7px;
        max-height: none;
        padding-right: 0;
        overflow: visible;
    }

    .word-field {
        border-radius: 8px;
    }

    .word-number {
        min-width: 26px;
        padding: 10px 2px;
        font-size: 10px;
    }

    .word-field input {
        padding: 10px 5px 10px 2px;
        font-size: 13px;
    }

    .selected-letters-panel {
        align-items: flex-start;
        gap: 8px;
        padding: 8px 9px;
    }

    .selected-letter-badge {
        width: 25px;
        height: 25px;
        font-size: 11px;
    }

    .active-word-text {
        gap: 0;
        padding-right: 3px;
        font-size: 12px;
    }

    .game-actions {
        grid-template-columns: 0.9fr 1.1fr;
        gap: 8px;
        margin-top: 16px;
    }

    .game-actions .button {
        min-height: 46px;
        padding: 10px 8px;
        font-size: 14px;
    }

    .settings-modal form {
        padding: 18px;
    }

    .settings-modal-header {
        gap: 12px;
    }

    .settings-modal-actions {
        gap: 8px;
    }
}

@media (max-width: 370px) {
    body {
        padding: 10px;
    }

    .wheel-panel,
    .setup-panel {
        padding: 13px;
    }

    .brand h1 {
        font-size: 23px;
    }

    .game-status {
        padding-inline: 8px;
        font-size: 10px;
    }

    .word-grid {
        gap: 5px;
    }

    .word-number {
        min-width: 23px;
    }

    .word-field input {
        padding-right: 3px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .selected-letter-badge.is-arriving {
        animation-duration: 140ms;
        animation-timing-function: ease-out;
    }
}
