:root {
    color-scheme: light;
    --bg: #f6f7f4;
    --panel: #ffffff;
    --panel-soft: #fbfcf8;
    --text: #182026;
    --muted: #68737d;
    --line: #dfe4dc;
    --line-strong: #cbd3c8;
    --primary: #146c5a;
    --primary-dark: #0b4d40;
    --accent: #c49a3a;
    --accent-soft: #fff7df;
    --danger-bg: #fff1f0;
    --danger-text: #9f1f17;
    --success-bg: #eefaf4;
    --success-text: #17613c;
    --success-line: #bfe6cf;
    --shadow-sm: 0 8px 24px rgba(24, 32, 38, 0.07);
    --shadow-md: 0 20px 50px rgba(24, 32, 38, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(246, 247, 244, 0.96)),
        var(--bg);
    color: var(--text);
}

.login-page {
    display: grid;
    place-items: center;
}

.login-shell {
    width: min(100%, 440px);
    padding: 24px;
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow-md);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 18px;
}

h1 {
    margin: 0 0 24px;
    font-size: 28px;
    line-height: 1.2;
}

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

.login-form label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 16px;
    color: var(--text);
    background: #fff;
}

.login-form input:focus {
    outline: 3px solid rgba(20, 108, 90, 0.18);
    border-color: var(--primary);
}

.login-form button {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    margin-top: 8px;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.login-form button:hover {
    background: var(--primary-dark);
}

.alert {
    margin-bottom: 18px;
    border: 1px solid #f2c6c2;
    border-radius: 8px;
    padding: 12px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: 14px;
}

.alert-success {
    border-color: var(--success-line);
    background: var(--success-bg);
    color: var(--success-text);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 24px;
    min-height: 52px;
    padding: 0 24px;
    border-bottom: 1px solid rgba(203, 211, 200, 0.78);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(16px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

.topbar-user {
    min-width: 0;
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-menu {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.topbar a {
    text-decoration: none;
}

.nav-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.66);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 1px 1px rgba(24, 32, 38, 0.03);
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item::after {
    position: absolute;
    right: 12px;
    bottom: 4px;
    left: 12px;
    height: 2px;
    background: var(--accent);
    content: "";
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 160ms ease;
}

.nav-item:hover,
.nav-item:focus-visible {
    border-color: rgba(20, 108, 90, 0.28);
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.nav-item:hover::after,
.nav-item:focus-visible::after {
    transform: scaleX(1);
}

.topbar-date {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: right;
}

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

.app-layout {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    gap: 0;
    min-height: calc(100vh - 52px);
}

.sidebar {
    position: sticky;
    top: 52px;
    align-self: start;
    min-height: calc(100vh - 52px);
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    padding: 18px 14px;
}

.sidebar-profile {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--panel);
    box-shadow: var(--shadow-sm);
}

.sidebar-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.sidebar-profile-text {
    min-width: 0;
}

.sidebar-profile-text strong,
.sidebar-profile-text span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-profile-text strong {
    font-size: 14px;
}

.sidebar-profile-text span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-title {
    margin: 0 0 10px 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-menu {
    display: grid;
    gap: 8px;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 12px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

.sidebar-link::before {
    width: 3px;
    height: 18px;
    border-radius: 999px;
    margin-right: 10px;
    background: var(--primary);
    content: "";
    transform: scaleY(0);
    transition: transform 160ms ease;
}

.sidebar-link:hover,
.sidebar-link:focus-visible {
    border-color: rgba(20, 108, 90, 0.18);
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: 0 8px 20px rgba(24, 32, 38, 0.06);
    transform: translateX(2px);
}

.sidebar-link:hover::before,
.sidebar-link:focus-visible::before {
    transform: scaleY(1);
}

.content {
    width: 100%;
    max-width: 1120px;
    padding: 36px 32px;
}

.content p {
    color: var(--muted);
}

.dashboard-section {
    margin-bottom: 28px;
}

.page-heading {
    max-width: 680px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border: 1px solid #ead89e;
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 0 10px;
    background: var(--accent-soft);
    color: #785b13;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.page-heading h1 {
    margin-bottom: 10px;
    font-size: 34px;
    line-height: 1.1;
}

.page-heading p {
    margin: 0;
    font-size: 16px;
}

.draws-section {
    margin-bottom: 28px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 26px;
    background: var(--panel);
    box-shadow: var(--shadow-md);
    scroll-margin-top: 72px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.draws-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 14px;
}

.draws-table th,
.draws-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
}

.draws-table th {
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.draws-table tbody tr:last-child td {
    border-bottom: 0;
}

.draws-table tbody tr:hover {
    background: rgba(20, 108, 90, 0.04);
}

.draws-table td:not(:first-child) {
    font-weight: 700;
}

.empty-table {
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.number-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.number-pill {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    min-height: 42px;
    border: 1px solid rgba(20, 108, 90, 0.2);
    border-radius: 8px;
    padding: 0 12px;
    background: var(--panel-soft);
    color: var(--primary-dark);
    font-size: 16px;
    font-weight: 800;
}

.prediction-box {
    display: grid;
    gap: 6px;
    margin-bottom: 20px;
    border: 1px solid #ead89e;
    border-radius: 8px;
    padding: 14px;
    background: var(--accent-soft);
    color: #60480f;
}

.prediction-box strong {
    font-size: 13px;
    text-transform: uppercase;
}

.prediction-box span {
    line-height: 1.5;
}

.prediction-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 6px 0 0;
}

.prediction-details div {
    border: 1px solid rgba(196, 154, 58, 0.32);
    border-radius: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.46);
}

.prediction-details dt {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.prediction-details dd {
    margin: 0;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 10px;
}

.stat-item {
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.stat-number {
    color: var(--primary-dark);
    font-size: 20px;
    font-weight: 800;
}

.stat-count,
.stat-probability {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.empty-analysis {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
    color: var(--muted);
    font-weight: 700;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.tip-card {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.tip-title {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.tip-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tip-number {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.tip-score {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

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

.prediction-row {
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--panel-soft);
}

.prediction-row strong {
    color: var(--primary-dark);
}

.prediction-row span {
    color: var(--muted);
    line-height: 1.45;
}

.comparison-list {
    display: grid;
    gap: 12px;
}

.comparison-card {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr) minmax(130px, auto);
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.comparison-card-simple {
    grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
}

.comparison-date {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.comparison-block {
    display: grid;
    gap: 8px;
}

.comparison-block strong,
.comparison-result strong {
    color: var(--primary-dark);
    font-size: 13px;
}

.comparison-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.comparison-number {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    min-height: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 2px 7px;
    background: var(--panel-soft);
    font-size: 13px;
    font-weight: 800;
}

.comparison-number-match {
    border-color: red;
    background: red;
    color: #fff;
}

.comparison-bonus,
.comparison-bonus-match {
    border-color: yellow;
    background: yellow;
    color: var(--text);
}

.comparison-result {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.my-games-section {
    display: none;
    margin-bottom: 28px;
}

.my-games-section:target {
    display: block;
}

.my-games-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 560px));
    align-items: stretch;
    gap: 16px;
}

.my-games-form-card,
.my-games-side-card {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow-md);
}

.my-games-form-card {
    padding: 26px;
}

.my-games-side {
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr);
    gap: 14px;
}

.my-games-side-card {
    display: grid;
    align-content: start;
    gap: 10px;
    align-items: center;
    padding: 14px;
    min-width: 0;
}

.my-games-side-card strong {
    color: var(--primary-dark);
    font-size: 14px;
}

.compact-inputs {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    align-items: center;
    justify-items: center;
}

.compact-inputs input {
    width: 100%;
    min-width: 0;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 6px;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    text-align-last: center;
    appearance: textfield;
    -moz-appearance: textfield;
}

.compact-inputs input::-webkit-inner-spin-button,
.compact-inputs input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
}

.compact-inputs input::placeholder {
    color: var(--muted);
    opacity: 1;
}

.compact-inputs input:focus {
    outline: 3px solid rgba(20, 108, 90, 0.18);
    border-color: var(--primary);
}

.compact-inputs .compact-zz-input {
    border-color: #ead89e;
    background: var(--accent-soft);
}

.compact-warning {
    color: var(--danger-text);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.mini-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.mini-table {
    width: 100%;
    min-width: 430px;
    border-collapse: collapse;
    font-size: 12px;
}

.mini-table th,
.mini-table td {
    border-bottom: 1px solid var(--line);
    padding: 8px 9px;
    text-align: center;
    white-space: nowrap;
}

.mini-table th {
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.mini-table tbody tr:last-child td {
    border-bottom: 0;
}

.mini-table td:not(:first-child) {
    font-weight: 700;
}

.mini-table [data-game-number] {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    min-height: 24px;
    border-radius: 8px;
    padding: 2px 6px;
}

.mini-table [data-game-number].number-match {
    background: red;
    color: #fff;
}

.mini-table [data-game-number].bonus-match {
    background: yellow;
    color: var(--text);
}

.empty-mini {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.match-message {
    position: relative;
    border: 1px solid var(--success-line);
    border-radius: 8px;
    margin: 2px 10px 0;
    padding: 12px 38px 12px 12px;
    background: var(--success-bg);
    color: var(--success-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
}

.match-message-close {
    position: absolute;
    top: 7px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--success-line);
    border-radius: 8px;
    background: #fff;
    color: var(--success-text);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
}

.match-message-close:hover,
.match-message-close:focus-visible {
    border-color: var(--success-text);
}

.compare-button {
    width: calc(100% - 20px);
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    margin: 2px 10px 0;
    padding: 8px 12px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.compare-button:hover,
.compare-button:focus-visible {
    background: var(--primary-dark);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.settings-panel {
    display: none;
    max-width: 560px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 26px;
    background: var(--panel);
    box-shadow: var(--shadow-md);
}

.settings-panel:target {
    display: block;
}

.settings-panel-visible {
    display: block;
}

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

.section-header h2 {
    margin: 0 0 8px;
    font-size: 22px;
    line-height: 1.25;
}

.section-header p {
    margin: 0;
}

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

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

.form-field {
    display: grid;
    gap: 8px;
}

.form-field-wide {
    grid-column: 1 / -1;
}

.settings-form label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.settings-form input,
.settings-form select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 16px;
    color: var(--text);
    background: #fff;
}

.settings-form input:focus,
.settings-form select:focus {
    outline: 3px solid rgba(20, 108, 90, 0.18);
    border-color: var(--primary);
}

.settings-form button {
    justify-self: start;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    margin-top: 8px;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.settings-form button:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

@media (max-width: 520px) {
    .login-shell {
        padding: 16px;
    }

    .login-panel {
        padding: 24px;
    }

    .topbar {
        grid-template-columns: 1fr;
        gap: 8px;
        align-items: start;
        padding: 0 16px;
        padding-bottom: 10px;
        padding-top: 10px;
    }

    .topbar-menu {
        flex-wrap: wrap;
        justify-content: start;
    }

    .topbar-actions {
        flex-wrap: wrap;
        justify-content: start;
    }

    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        min-height: 0;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 14px 16px;
    }

    .sidebar-menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar-link {
        justify-content: center;
    }

    .sidebar-link::before {
        display: none;
    }

    .content {
        padding: 24px 16px;
    }

    .settings-panel {
        padding: 20px;
    }

    .my-games-layout {
        grid-template-columns: 1fr;
    }

    .my-games-form-card {
        padding: 20px;
    }

    .my-games-side {
        grid-template-rows: auto minmax(120px, auto);
    }

    .compact-inputs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .draws-section {
        padding: 20px;
        scroll-margin-top: 156px;
    }

    .prediction-details {
        grid-template-columns: 1fr;
    }

    .comparison-card {
        grid-template-columns: 1fr;
    }
}
