:root {
    color-scheme: light;
    --ink: #211c35;
    --muted: #716b80;
    --paper: #fffdf8;
    --surface: #ffffff;
    --line: #e9e4dc;
    --brand: #4a3478;
    --brand-dark: #352453;
    --accent: #e7aa3f;
    --success: #287b58;
    --danger: #a63d4b;
    --shadow: 0 16px 38px rgba(37, 29, 59, .09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 28px 18px 48px;
    background:
        radial-gradient(ellipse at 10% 0, rgba(231, 170, 63, .13), transparent 34rem),
        #f6f3ed;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--brand);
}

.page {
    width: min(100%, 980px);
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 auto 26px;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.account-actions form {
    margin: 0;
}

.account-actions button {
    min-height: 40px;
    padding: 9px 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 14px;
    background: var(--brand);
    color: white;
    font-size: 23px;
    box-shadow: 0 7px 15px rgba(74, 52, 120, .2);
}

.brand-name {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .02em;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 10px;
    font-size: clamp(28px, 5vw, 42px);
    letter-spacing: -.04em;
}

h2 {
    font-size: 22px;
    letter-spacing: -.02em;
}

.muted, .subtitle {
    color: var(--muted);
}

.subtitle {
    margin-bottom: 0;
    line-height: 1.65;
}

.panel, .card, .hero {
    border: 1px solid rgba(233, 228, 220, .9);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel {
    padding: clamp(20px, 4vw, 32px);
    margin-bottom: 20px;
}

.hero {
    padding: clamp(26px, 6vw, 52px);
    background: linear-gradient(135deg, #fff 10%, #f5efff 100%);
}

.hero h1 {
    max-width: 680px;
}

.round-status {
    margin: 18px 0;
    color: var(--muted);
}

.round-status strong {
    color: var(--brand);
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(120px, 170px) auto;
    align-items: end;
    gap: 12px;
    max-width: 520px;
    margin-top: 20px;
}

.inline-form label {
    grid-column: 1 / -1;
    margin: 0;
}

.inline-form input {
    max-width: none;
}

.inline-form button {
    width: auto;
}

.hero-actions, .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
}

.button, button {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 12px 19px;
    border: 0;
    border-radius: 13px;
    background: var(--brand);
    color: white;
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
    transition: background .16s ease, transform .16s ease;
}

.button:hover, button:hover {
    transform: translateY(-1px);
    background: var(--brand-dark);
}

.button.secondary {
    border: 1px solid var(--line);
    background: white;
    color: var(--brand);
}

.button.secondary:hover {
    background: #f7f4fb;
}

label {
    display: block;
    margin: 16px 0 7px;
    font-weight: 700;
}

input, textarea {
    width: 100%;
    max-width: 560px;
    padding: 12px 14px;
    border: 1px solid #d9d3e2;
    border-radius: 12px;
    background: white;
    color: var(--ink);
    font: inherit;
}

input:focus, textarea:focus {
    outline: 3px solid rgba(74, 52, 120, .15);
    border-color: var(--brand);
}

textarea {
    min-height: 140px;
    resize: vertical;
}

.notice {
    padding: 13px 16px;
    border-radius: 12px;
    background: #edf7f1;
    color: var(--success);
    font-weight: 700;
}

.notice.error {
    background: #fff0f0;
    color: var(--danger);
}

.last-ball {
    display: grid;
    min-height: 230px;
    place-content: center;
    margin: 22px 0;
    border-radius: 22px;
    background: linear-gradient(140deg, var(--brand-dark), #5b408c);
    color: white;
    text-align: center;
}

.last-ball-label {
    margin-bottom: 8px;
    color: #e6dff2;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.last-ball-number {
    margin: 0;
    color: #ffe2a5;
    font-size: clamp(74px, 15vw, 112px);
    font-weight: 850;
    line-height: 1;
}

.ball-list {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.ball {
    display: grid;
    width: 43px;
    height: 43px;
    place-items: center;
    border: 1px solid #e8e1f1;
    border-radius: 50%;
    background: #f7f3fc;
    color: var(--brand);
    font-weight: 800;
}

.ball.latest {
    border-color: var(--accent);
    background: #fff4d9;
    color: #80540b;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}

.card {
    padding: 19px;
    box-shadow: 0 6px 20px rgba(37, 29, 59, .05);
}

.card-management {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.card-management p {
    margin-bottom: 0;
}

.card-management form {
    margin: 0;
}

.button-danger {
    background: var(--danger);
}

.button-danger:hover {
    background: #842e3a;
}

.sequence-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.sequence-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}

.sequence-option h3,
.sequence-option p {
    margin-bottom: 0;
}

.sequence-option form {
    width: 100%;
    margin-top: auto;
}

.sequence-option button {
    width: 100%;
}

.button-restart {
    background: #6a4650;
}

.button-restart:hover {
    background: #4f333b;
}

.button-advance {
    background: #8d5b13;
}

.button-advance:hover {
    background: #68420e;
}

.card h3 {
    margin-bottom: 7px;
}

.card-count {
    margin-bottom: 12px;
    color: var(--brand);
    font-size: 14px;
    font-weight: 800;
}

.winner {
    border-color: #efcf83;
    background: #fff8e7;
}

.near-winner {
    border: 2px solid var(--accent);
    background: #fff9e9;
    box-shadow: 0 10px 24px rgba(141, 91, 19, .16);
}

.card-status {
    display: inline-flex;
    margin: 0 0 10px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .03em;
}

.near-winner-status {
    background: #ffebba;
    color: #704808;
}

.winner-status {
    background: #e7f4ec;
    color: var(--success);
}

.winner-banner {
    padding: 21px;
    border: 1px solid #f0d99f;
    border-radius: 18px;
    background: #fff4d7;
    color: #68460b;
}

.winner-banner h2 {
    margin-bottom: 8px;
}

.empty-state {
    color: var(--muted);
    font-style: italic;
}

@media (max-width: 560px) {
    body {
        padding: 18px 13px 32px;
    }

    .site-header {
        margin-bottom: 18px;
    }

    .panel, .hero {
        border-radius: 17px;
    }

    .button, button {
        width: 100%;
    }

    .card-management {
        align-items: stretch;
        flex-direction: column;
    }

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

    .inline-form button {
        width: 100%;
    }
}
