:root {
    --ink: #1b1730;
    --paper: #f4efe4;
    --card: #fffdf8;
    --gold: #d7a21a;
    --gold-deep: #b8860b;
    --crimson: #c81e1e;
    --navy: #13204a;
    --muted: #6b6578;
    --line: #e4dccb;
    --win: #157a3a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Source Sans 3", sans-serif;
    background:
        radial-gradient(circle at top right, rgba(215, 162, 26, 0.18), transparent 28%),
        linear-gradient(180deg, #efe7d6 0%, var(--paper) 180px);
    color: var(--ink);
    min-height: 100vh;
}
h1, h2, h3, .brand strong {
    font-family: Fraunces, Georgia, serif;
    letter-spacing: -0.02em;
}
a { color: var(--navy); }
.topbar {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 16px 28px;
    background: var(--navy);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 5;
}
.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: #fff;
    text-decoration: none;
    min-width: 240px;
}
.brand small { display: block; color: #d7c9a4; font-size: 12px; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--gold); color: var(--navy);
    display: grid; place-items: center; font-weight: 700; font-family: Fraunces, serif;
}
.topbar nav { display: flex; gap: 8px; flex: 1; }
.topbar nav a {
    color: #f3ead6; text-decoration: none; padding: 8px 12px; border-radius: 999px;
}
.topbar nav a.is-active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.sync-form button, .btn {
    border: 0; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700;
}
.sync-form button {
    background: var(--gold); color: var(--navy); border-radius: 999px; padding: 10px 16px;
}
.wrap { width: min(1120px, calc(100% - 32px)); margin: 28px auto 64px; }
.hero {
    display: grid; grid-template-columns: 1.4fr .9fr; gap: 28px; margin-bottom: 36px;
}
.hero h1 { font-size: clamp(32px, 5vw, 52px); margin: 8px 0 12px; }
.lede { font-size: 18px; color: #3d3850; max-width: 46ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--gold-deep); font-weight: 700; }
.hero-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn-gold { background: var(--gold); color: var(--navy); border-radius: 999px; padding: 11px 18px; }
.btn-ghost { background: transparent; border: 1px solid var(--ink) !important; color: var(--ink); border-radius: 999px; padding: 10px 18px; }
.btn-small { padding: 6px 12px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 13px; }
.btn-danger { background: var(--crimson); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-stats { grid-template-columns: repeat(4, 1fr); margin: 0 0 22px; }
.is-loss { color: var(--crimson); }
.stat, .card {
    background: var(--card); border: 1px solid var(--line); border-radius: 18px;
    box-shadow: 0 10px 30px rgba(27, 23, 48, .06);
}
.stat { padding: 16px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; font-size: 22px; margin-top: 4px; }
.section-head { margin: 10px 0 16px; }
.section-head.split { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.section-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.upload-ticket { margin: 0; }
.upload-ticket .btn { cursor: pointer; }
.upload-ticket.is-busy .btn { opacity: .65; pointer-events: none; }
.game-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.game-card { padding: 16px; }
.game-card h3 { margin: 0; }
.game-card header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-links { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 0; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rules-card { padding: 18px; }
.rules-card header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.rules-card h2 { margin: 0 0 8px; }
.rules-play { margin: 8px 0 6px; font-weight: 600; }
.rules-card .odds { margin: 8px 0; }
.rules-table { margin-top: 12px; }
.rules-card .rules-table { border-radius: 12px; }
.rules-card td small { display: block; font-weight: 400; }
.is-jackpot-row { background: #fff8e6; }
.rules-card.is-focus { outline: 3px solid var(--gold-deep, #b8891a); outline-offset: 2px; }
.rules-more { margin: 12px 0 0; }
.muted { color: var(--muted); }
.balls { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ball {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    font-weight: 700; font-size: 13px; border: 1px solid rgba(0,0,0,.08);
}
.ball-yellow { background: #ffe14a; color: var(--navy); }
.ball-red { background: var(--crimson); color: #fff; }
.ball-color { color: #111; }
.ball-yellow.ball-color { background: #ffe14a; }
.ball-blue { background: #2f6bff; color: #fff; }
.ball-red.ball-color { background: #e10600; color: #fff; }
.ball-green { background: #1f9d4a; color: #fff; }
.ball-white { background: #f7f7f7; border-color: #bbb; }
.ball-black { background: #171717; color: #fff; }
.ball.is-hit { outline: 3px solid #157a3a; transform: translateY(-1px); }
.table-wrap { overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 700; }
.pill { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.pill-win { background: #ddf6e5; color: var(--win); }
.pill-miss { background: #f3efe6; color: var(--muted); }
.pill-wait { background: #eef3ff; color: #13204a; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.money.is-win { color: var(--win); }
.is-win-row { background: #f4fff7; }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; }
.flash-ok { background: #ddf6e5; color: #0f5c2e; }
.flash-error { background: #ffe1e1; color: #8a1212; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; background: #efe7d6; text-decoration: none; color: var(--ink); }
.tab.is-active { background: var(--navy); color: #fff; }
.empty, .help { background: var(--card); border: 1px dashed var(--line); padding: 18px; border-radius: 16px; }
.form-card, .detail-card { padding: 22px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; margin: 12px 0 20px; }
.pick {
    height: 42px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 700;
}
.pick.is-on { background: #ffe14a; border-color: var(--gold-deep); }
.pick-red.is-on { background: var(--crimson); color: #fff; border-color: #8a1212; }
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.pair { border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
label { display: block; margin: 12px 0; font-weight: 600; }
input[type=text],
input[type=password],
input[type=email],
input[type=number],
input[type=file],
select,
textarea {
    width: 100%;
    max-width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    font-family: "Source Sans 3", sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.35;
    background: #fff;
    color: var(--ink);
    box-sizing: border-box;
    box-shadow: none;
    background-clip: padding-box;
}
input[type=text],
input[type=password],
input[type=email],
input[type=number],
select,
textarea {
    min-height: 44px;
    appearance: none;
    -webkit-appearance: none;
}
input[type=password] {
    letter-spacing: 0.08em;
}
input[type=password]::placeholder {
    letter-spacing: 0;
    color: #9a93a6;
}
input[type=text]:focus,
input[type=password]:focus,
input[type=email]:focus,
input[type=number]:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(215, 162, 26, .45);
    border-color: var(--gold-deep);
}
input[type=password]::-ms-reveal,
input[type=password]::-ms-clear {
    display: none;
}
.import-box { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.sample {
    background: #1b1730; color: #f3ead6; padding: 14px 16px; border-radius: 12px; overflow: auto; font-size: 13px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.preview-list { display: grid; gap: 14px; }
.preview-play { padding: 18px 20px; }
.preview-play.is-existing { opacity: .72; }
.preview-check { display: flex; gap: 10px; align-items: center; margin: 0 0 8px; }
.preview-check input { width: auto; margin: 0; }
.preview-facts { margin-top: 8px; }
.preview-facts dd { font-size: 16px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.facts div { background: #f7f1e4; border-radius: 12px; padding: 12px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 4px 0 0; font-size: 20px; font-weight: 700; }
.foot { text-align: center; color: var(--muted); padding: 0 16px 40px; font-size: 13px; }
.rec-ticket { margin-bottom: 18px; }
.rec-ticket-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 8px; }
.rec-ticket-head h2 { margin: 4px 0 0; }
.picker-heat .pick.has-freq {
    height: 58px; display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 0; position: relative;
    background: rgba(215, 162, 26, var(--heat, .12));
    padding-bottom: 12px;
}
.picker-heat .pick.has-freq small {
    position: absolute; bottom: 4px; left: 0; right: 0; text-align: center;
    font-size: 9px; color: #5a5468; font-weight: 700;
}
.picker-heat .pick.has-freq.is-on { outline: 3px solid var(--navy); }
.picker-red.picker-heat .pick.has-freq {
    background: rgba(200, 30, 30, calc(var(--heat, .12) * .85));
    color: var(--navy);
}
.picker-red.picker-heat .pick.has-freq.is-on { background: var(--crimson); color: #fff; }
.rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank-list .ball { margin: 0; }
.rank-list strong { margin-left: auto; }
.color-heat { display: grid; gap: 6px; margin: 12px 0 18px; overflow: auto; }
.color-heat-head, .color-heat-row { display: grid; grid-template-columns: 92px repeat(7, 1fr); gap: 6px; align-items: center; }
.color-heat-head span, .color-heat-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.heat-cell {
    height: 42px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
    background: rgba(215, 162, 26, var(--heat, .1)); font-weight: 700; font-size: 12px;
    position: relative; display: grid; place-items: center;
}
.heat-cell.is-on { outline: 3px solid var(--navy); }
.rec-split { margin: 0 0 18px; }
.rec-sub { margin-top: 16px; }
.rec-warn { color: var(--crimson); font-weight: 700; margin: 8px 0 0; }
.rec-tools { margin: 16px 0 8px; }
.rec-last-mode select { max-width: 280px; }
.rec-live { background: #f7f1e4; border-radius: 12px; padding: 12px 14px; margin: 12px 0 8px; }
.rec-shape { margin: 0; font-weight: 600; }
.rec-trend {
    position: absolute; top: 2px; right: 4px;
    font-style: normal; font-size: 9px; line-height: 1; font-weight: 700;
}
.pick { position: relative; }
.pick.is-up .rec-trend, .heat-cell.is-up .rec-trend { color: #0f5c2e; }
.pick.is-down .rec-trend, .heat-cell.is-down .rec-trend { color: #8a1212; }
.picker-heat .pick.has-freq.is-last,
.heat-cell.is-last {
    box-shadow: inset 0 0 0 2px rgba(200, 30, 30, .85);
}
.picker-heat .pick.has-freq.is-pin,
.heat-cell.is-pin {
    outline: 3px dashed var(--navy);
}
.rec-packs { margin-top: 18px; }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.pack-card {
    border: 1px solid var(--line); border-radius: 14px; padding: 14px;
    background: #fff;
}
.pack-card .balls { margin: 8px 0; }
.pack-save { margin-top: 8px; }
.pack-save .btn { width: 100%; }
.auth-body { min-height: 100vh; display: grid; place-items: center; }
.auth-wrap { width: min(440px, calc(100% - 32px)); padding: 24px 0 48px; }
.auth-card h1 { margin: 8px 0 12px; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-name { color: #d7c9a4; font-size: 13px; white-space: nowrap; }
.logout-form button {
    background: transparent; color: #f3ead6; border-radius: 999px;
    padding: 8px 12px; border: 1px solid rgba(255,255,255,.28);
}
.admin-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: 220px; }
.admin-pass { display: grid; gap: 8px; }
.admin-pass input { width: 100%; margin: 0; min-width: 0; }
.auth-card .btn { width: 100%; margin-top: 8px; }
.jackpot { font-weight: 700; }
.odds { color: var(--muted); font-size: 13px; margin: 6px 0 10px; line-height: 1.35; }
.odds strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.compare-stack { display: grid; gap: 8px; }
.compare-stack small { display: block; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.settings-stack { display: grid; gap: 22px; margin-bottom: 22px; }
.settings-stack h2, .card.form-card h2 { margin-top: 0; }
.switch-row { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 8px; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.switch input { width: auto; margin: 0; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 8px; }
.choice {
    display: flex; gap: 10px; align-items: start;
    border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
    cursor: pointer; font-weight: 600;
}
.choice input { width: auto; margin: 6px 0 0; }
.choice small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--gold-deep); background: #fff8e6; }
.score-field small { display: block; margin-top: 6px; font-weight: 400; }
.recaptcha-box { margin: 14px 0 8px; overflow: auto; }
.flash-hint { background: #eef3ff; color: #13204a; }
.explain { margin-top: 8px; font-size: 13px; max-width: 36ch; }
.ai-summary { margin-bottom: 18px; }
.chat-card {
    display: flex; flex-direction: column;
    min-height: min(68vh, 720px); padding: 0; overflow: hidden;
}
.chat-log {
    display: flex; flex-direction: column; gap: 10px;
    flex: 1; overflow: auto; padding: 18px 18px 10px;
    background: linear-gradient(180deg, rgba(255,255,255,.2), transparent 40px);
}
.chat-hint { margin: 8px 4px 12px; }
.chat-bubble {
    border: 1px solid var(--line); border-radius: 16px 16px 16px 6px;
    padding: 10px 14px; background: #fff; max-width: 78%;
}
.chat-bubble.is-ai { background: #fff8e6; align-self: flex-start; }
.chat-bubble.is-me {
    align-self: flex-end; background: var(--navy); color: #f3ead6;
    border-color: transparent; border-radius: 16px 16px 6px 16px;
}
.chat-bubble.is-me small { color: #d7c9a4; }
.chat-bubble.is-pending { opacity: .75; }
.chat-bubble p { margin: 4px 0 0; white-space: pre-wrap; }
.chat-dots { display: inline-flex; gap: 4px; padding: 6px 0 2px; }
.chat-dots span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--gold-deep);
    animation: chat-dot 1s infinite ease-in-out;
}
.chat-dots span:nth-child(2) { animation-delay: .15s; }
.chat-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}
.chat-composer {
    display: flex; gap: 8px; align-items: center;
    padding: 12px; border-top: 1px solid var(--line); background: #fffdf8;
}
.chat-composer input { margin: 0; flex: 1; min-width: 0; }
.chat-composer .btn { margin: 0; flex-shrink: 0; }
.chat-error { color: var(--crimson); font-size: 13px; padding: 0 18px 10px; }
input[type=url] { width: 100%; max-width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); font-family: inherit; font-size: 16px; background: #fff; min-height: 44px; box-sizing: border-box; }

@media (max-width: 900px) {
    .hero, .game-grid, .rules-grid, .color-grid, .facts, .form-row, .summary-stats, .rank-grid, .choice-row { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; }
    .topbar nav { order: 3; width: 100%; overflow: auto; }
}
