:root {
    --bg: #0757c9;
    --ink: #10233f;
    --muted: #516c94;
    --panel: #ffffff;
    --line: #c9d9f4;
    --accent: #1267ff;
    --accent-dark: #073b95;
    --gold: #ffd447;
    --coral: #ff5d7a;
    --sky: #35d3ff;
    --violet: #7158ff;
    --danger: #e23d5b;
    --success: #18a86b;
    --shadow: 0 22px 48px rgba(4, 25, 73, 0.26);
    font-family: "Trebuchet MS", "Arial Black", "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 14% 10%, rgba(53, 211, 255, 0.42), transparent 22rem),
        radial-gradient(circle at 88% 18%, rgba(255, 212, 71, 0.34), transparent 20rem),
        radial-gradient(circle at 52% 86%, rgba(113, 88, 255, 0.28), transparent 24rem),
        linear-gradient(135deg, #073b95 0%, #1267ff 46%, #35d3ff 100%);
    background-attachment: fixed;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.view {
    min-height: calc(100vh - 64px);
}

.hidden {
    display: none !important;
}

.brand-panel,
.panel {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
}

.brand-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 22px;
    align-items: center;
    min-height: 250px;
    padding: clamp(24px, 5vw, 54px);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.72);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(229, 245, 255, 0.95)),
        #ffffff;
}

.brand-panel::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 10px;
    background: linear-gradient(90deg, var(--coral), var(--gold), var(--sky), var(--violet));
}

.brand-mark {
    display: grid;
    place-items: center;
    inline-size: 104px;
    block-size: 104px;
    border-radius: 50%;
    background: var(--accent-dark);
    box-shadow:
        inset 0 0 0 10px var(--sky),
        inset 0 0 0 22px #ffffff,
        inset 0 0 0 36px var(--coral),
        0 18px 28px rgba(18, 103, 255, 0.24);
}

.brand-mark span {
    display: block;
    grid-area: 1 / 1;
    border-radius: 50%;
}

.brand-mark span:nth-child(1) {
    width: 20px;
    height: 20px;
    background: var(--gold);
}

.brand-mark span:nth-child(2) {
    width: 54px;
    height: 4px;
    border-radius: 999px;
    background: #ffffff;
    transform: rotate(-35deg) translateX(7px);
}

.brand-mark span:nth-child(3) {
    width: 10px;
    height: 10px;
    background: var(--ink);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--violet);
    font-weight: 900;
    letter-spacing: 0;
}

h1,
h2,
p {
    margin-top: 0;
}

.brand-panel h1,
.game-header h1 {
    margin-bottom: 10px;
    font-size: clamp(2.3rem, 6vw, 5rem);
    line-height: 1;
    letter-spacing: 0;
    font-weight: 900;
}

.brand-panel h1 {
    color: #092f78;
    font-size: clamp(4rem, 11vw, 8rem);
    text-shadow:
        0 4px 0 rgba(255, 212, 71, 0.95),
        0 10px 22px rgba(18, 103, 255, 0.22);
}

.lead {
    max-width: 660px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.8;
}

.setup-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.75fr) minmax(320px, 1.25fr);
    gap: 18px;
    margin-top: 18px;
}

.join-panel {
    margin-top: 18px;
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-height: 0;
}

.home-action {
    display: grid;
    place-items: center;
    min-height: 138px;
    border-radius: 8px;
    color: #ffffff;
    padding: 18px;
    font-size: clamp(1.45rem, 4vw, 2.6rem);
    font-weight: 900;
    text-align: center;
    box-shadow: 0 22px 42px rgba(4, 25, 73, 0.22);
}

.home-action.create {
    background:
        radial-gradient(circle at 24% 18%, rgba(255, 212, 71, 0.34), transparent 9rem),
        linear-gradient(135deg, var(--coral), var(--violet), var(--accent));
}

.home-action.join {
    background:
        radial-gradient(circle at 74% 20%, rgba(255, 212, 71, 0.36), transparent 9rem),
        linear-gradient(135deg, var(--accent-dark), var(--accent), var(--sky));
}

.home-action:hover {
    transform: translateY(-2px);
}

.join-form {
    display: grid;
    gap: 10px;
}

.back-button {
    justify-self: start;
    min-height: 38px;
    border-radius: 8px;
    padding: 0 14px;
    color: var(--accent-dark);
    background: #eaf4ff;
    font-weight: 900;
}

#roomCodeFields {
    display: grid;
    gap: 10px;
}

.join-form .primary-action {
    margin-top: 8px;
}

.action-split {
    display: flex;
    margin: 4px 0 14px;
}

.panel {
    border-radius: 8px;
    padding: 20px;
    border-width: 2px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.section-title h2 {
    margin: 0;
    font-size: 1.24rem;
    font-weight: 900;
}

.section-title span,
.hint {
    color: var(--muted);
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: #f8fbff;
    outline: none;
    font-weight: 800;
}

input {
    min-height: 46px;
    padding: 0 14px;
}

select {
    min-height: 44px;
    padding: 0 12px;
}

textarea {
    min-height: 270px;
    resize: vertical;
    padding: 14px;
    line-height: 1.7;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(53, 211, 255, 0.2);
}

.inline-form button,
.text-button,
.primary-action,
.secondary-action {
    min-height: 44px;
    border-radius: 6px;
    padding: 0 18px;
    font-weight: 800;
}

.inline-form button,
.primary-action {
    color: #fff;
    background: linear-gradient(135deg, var(--coral), var(--violet), var(--accent));
    box-shadow: 0 12px 20px rgba(18, 103, 255, 0.22);
}

.inline-form button:hover,
.primary-action:hover {
    background: linear-gradient(135deg, #ff315a, #5c43f0, #0757d8);
}

.primary-action {
    min-width: 180px;
}

.secondary-action {
    color: var(--accent-dark);
    border: 2px solid rgba(18, 103, 255, 0.25);
    background: #eaf4ff;
}

.secondary-action:hover {
    background: #d7ecff;
}

.text-button {
    color: var(--accent-dark);
    background: #e7f3ef;
}

.setup-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.players-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.player-chip,
.score-row,
.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    padding: 11px 12px;
}

.player-chip button {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--danger);
    background: #f7e7e3;
    font-weight: 900;
}

.empty-state {
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 6px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.45);
}

.game-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 12px;
    padding: 12px 16px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    background: rgba(7, 59, 149, 0.52);
    color: #ffffff;
    box-shadow: 0 14px 32px rgba(4, 25, 73, 0.16);
}

.home-button {
    align-self: start;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 9px 13px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    font-weight: 900;
}

.home-button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.game-header h1 {
    max-width: 960px;
    margin-bottom: 0;
    color: #ffffff;
    font-size: clamp(1.8rem, 4.8vw, 3.3rem);
    text-shadow: 0 4px 0 rgba(9, 47, 120, 0.35);
}

.game-header .lead {
    min-height: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.95rem;
    line-height: 1.4;
}

.round-meter {
    grid-column: 1 / -1;
    height: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(30, 39, 35, 0.12);
}

.round-meter div {
    width: 5%;
    height: 100%;
    background: linear-gradient(90deg, var(--coral), var(--gold), var(--accent));
    transition: width 220ms ease;
}

.game-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}

.scoreboard {
    position: static;
}

.scoreboard-list,
.round-results {
    display: grid;
    gap: 10px;
}

.scoreboard-list {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.score-value {
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--accent);
}

.used-values {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.turn-panel {
    min-height: 560px;
}

.play-panel {
    min-height: 360px;
}

.turn-label {
    margin-bottom: 4px;
    color: var(--muted);
}

#activePlayerName,
#winnerTitle {
    margin-bottom: 24px;
    font-size: clamp(1.8rem, 4vw, 3rem);
}

.big-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: min(100%, 320px);
    min-height: 92px;
    margin: 8px 0 22px;
    border: 3px dashed var(--accent);
    border-radius: 8px;
    color: var(--accent-dark);
    background: #eaf4ff;
    font-size: clamp(2.2rem, 8vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 0;
}

.waiting-players {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.waiting-player {
    min-width: 86px;
    border: 1px solid rgba(18, 103, 255, 0.22);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--accent-dark);
    background: #f8fbff;
    font-size: 0.92rem;
    font-weight: 900;
    text-align: center;
}

.question-block {
    margin-bottom: 22px;
}

.round-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.timer-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    height: 52px;
    border-radius: 6px;
    color: #fff;
    background: linear-gradient(135deg, var(--violet), var(--accent), var(--sky));
    font-size: 1.55rem;
    font-weight: 900;
}

.timer-badge.danger {
    background: var(--danger);
}

.question-block h2 {
    margin-bottom: 0;
    font-size: clamp(1.7rem, 4vw, 3rem);
    line-height: 1.25;
}

.host-controls {
    display: grid;
    grid-template-columns: minmax(160px, 220px) auto;
    gap: 10px;
    align-items: end;
    margin: 14px 0;
}

.host-controls label {
    grid-column: 1 / -1;
    color: var(--muted);
    font-weight: 700;
}

.submitted-panel {
    display: grid;
    place-items: start;
    min-height: 260px;
    align-content: center;
}

.countdown-panel {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 18px;
    color: #fff;
    background:
        radial-gradient(circle at 50% 45%, rgba(255, 212, 71, 0.24), transparent 18rem),
        linear-gradient(135deg, #061d58 0%, #1267ff 54%, #35d3ff 100%);
}

.countdown-panel p {
    margin: 0;
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    font-weight: 900;
}

.countdown-panel div {
    display: grid;
    place-items: center;
    width: clamp(150px, 34vw, 280px);
    aspect-ratio: 1;
    border: 10px solid rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    color: var(--gold);
    background: rgba(6, 29, 88, 0.42);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.25);
    font-size: clamp(6rem, 22vw, 14rem);
    font-weight: 900;
    line-height: 1;
}

.wager-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 22px 0 12px;
}

.wager-header span {
    color: var(--accent-dark);
    font-weight: 800;
}

.wager-grid {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 22px;
}

.wager-grid button {
    aspect-ratio: 1;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: #f8fbff;
    font-weight: 900;
}

.wager-grid button:hover:not(:disabled),
.wager-grid button.selected {
    color: #fff;
    border-color: var(--coral);
    background: linear-gradient(135deg, var(--coral), var(--violet));
}

.wager-grid button:disabled {
    cursor: not-allowed;
    color: #7c7164;
    border-color: #c9bda9;
    background: repeating-linear-gradient(
        135deg,
        #e7dfd0,
        #e7dfd0 7px,
        #d9cfbd 7px,
        #d9cfbd 14px
    );
    text-decoration: line-through;
    opacity: 0.82;
}

.result-row.unique {
    border-color: rgba(35, 139, 87, 0.38);
    background: #effaf4;
}

.result-row.duplicate {
    border-color: rgba(239, 111, 94, 0.36);
    background: #fff0ed;
}

.result-row.rejected {
    border-color: rgba(101, 113, 106, 0.34);
    background: #eee9df;
}

.answer-text {
    color: var(--muted);
}

.result-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.reject-button,
.accept-button {
    min-height: 36px;
    border-radius: 6px;
    padding: 0 12px;
    font-weight: 800;
}

.judge-icon {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    height: 38px;
    padding: 0;
    font-size: 1.35rem;
    line-height: 1;
    opacity: 0.72;
}

.judge-icon.active {
    opacity: 1;
    box-shadow: 0 0 0 3px rgba(18, 103, 255, 0.15);
}

.reject-button {
    color: var(--danger);
    background: #f7e7e3;
}

.accept-button {
    color: var(--success);
    background: #e4f4e8;
}

.ranking-showcase {
    margin-bottom: 18px;
    border: 1px solid #dbe5ee;
    border-radius: 8px;
    padding: 16px;
    background:
        linear-gradient(90deg, rgba(18, 103, 255, 0.08), rgba(53, 211, 255, 0.1), rgba(255, 212, 71, 0.14)),
        #ffffff;
}

.ranking-screen {
    margin-bottom: 0;
    min-height: 430px;
    display: grid;
    align-content: center;
    gap: 14px;
    border-color: rgba(255, 212, 71, 0.55);
    background:
        radial-gradient(circle at 18% 8%, rgba(255, 212, 71, 0.22), transparent 14rem),
        linear-gradient(135deg, rgba(18, 103, 255, 0.1), rgba(53, 211, 255, 0.14)),
        #ffffff;
}

.compact-title {
    margin-bottom: 12px;
}

.ranking-list {
    display: grid;
    gap: 10px;
}

.ranking-card {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
}

.rank-badge {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: #fff;
    background: var(--muted);
    font-weight: 900;
}

.rank-1 .rank-badge {
    color: #2d2105;
    background: var(--gold);
    box-shadow: 0 0 0 5px rgba(244, 185, 66, 0.2);
}

.rank-2 .rank-badge {
    background: var(--sky);
    box-shadow: 0 0 0 5px rgba(90, 169, 230, 0.18);
}

.rank-3 .rank-badge {
    background: var(--coral);
    box-shadow: 0 0 0 5px rgba(239, 111, 94, 0.18);
}

.rank-info {
    min-width: 0;
}

.rank-info strong {
    display: block;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf3;
}

.rank-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--coral), var(--violet), var(--sky), var(--gold));
}

.rank-score {
    min-width: 58px;
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--accent-dark);
    background: #eaf8fb;
    font-size: 1.4rem;
    font-weight: 900;
    text-align: center;
}

.rank-score span {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.1;
}

.rank-score strong {
    display: block;
    color: var(--accent-dark);
    font-size: 1.45rem;
    line-height: 1.1;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100% - 40px));
    border-radius: 8px;
    padding: 14px 16px;
    color: #fff;
    background: var(--ink);
    box-shadow: var(--shadow);
    z-index: 10;
}

@media (max-width: 860px) {
    .app-shell {
        width: min(100% - 20px, 720px);
        padding: 10px 0;
    }

    .view {
        min-height: calc(100vh - 20px);
    }

    .brand-panel,
    .setup-grid,
    .game-layout {
        grid-template-columns: 1fr;
    }

    .brand-panel {
        gap: 16px;
        min-height: auto;
    }

    .brand-mark {
        inline-size: 60px;
    }

    .wager-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .brand-panel,
    .panel {
        padding: 16px;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .section-title,
    .wager-header,
    .host-controls {
        align-items: flex-start;
        flex-direction: column;
    }

    .host-controls {
        grid-template-columns: 1fr;
    }

    .primary-action {
        width: 100%;
    }

    .home-actions {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .home-action {
        min-height: 108px;
    }
}
