/* Varsayılan tema KOYU'dur (cihazın temasına bakılmaz). Açık tema, üst çubuktaki düğmeyle seçilir. */
:root {
  color-scheme: dark;
  --bg: #0c120f; --surface: #141c17; --surface2: #1b251f; --text: #e8efe9; --muted: #92a199;
  --border: #25322a; --border-strong: #3a4a40; --accent: #1f8a58; --accent2: #2aa56c; --accent-ink: #ffffff; --gold: #e0b43a;
  --win: #43c274; --lose: #ef6f64; --warn: #e0a33a; --shadow: none;
  --radius: 14px; --tab-h: 62px; --top-h: 54px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f3; --surface: #ffffff; --surface2: #eef2ed; --text: #14201a; --muted: #5d6b63;
  --border: #dbe3da; --border-strong: #b6c4b9; --accent: #0f5a38; --accent2: #167a4b; --gold: #c99a1b;
  --win: #11803f; --lose: #b4382f; --warn: #a96b00; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); overscroll-behavior-y: contain; }
body.no-tabs { padding-bottom: 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--accent2); text-decoration: none; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.right { text-align: right; } .center { text-align: center; } .grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.num { font-variant-numeric: tabular-nums; }
.win { color: var(--win); } .lose { color: var(--lose); }

/* üst çubuk */
.topbar { position: sticky; top: 0; z-index: 20; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0;
  display: flex; align-items: center; gap: 10px; background: var(--accent); color: #fff; }
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; font-size: 17px; }
.topbar .brand img { width: 28px; height: 28px; border-radius: 8px; }
.iconbtn { margin-left: auto; width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; cursor: pointer; }
.iconbtn + .iconbtn { margin-left: 0; }
.iconbtn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn.on { background: #fff; color: var(--accent); }
.topbar .bal { margin-left: 0; background: rgba(255,255,255,.16); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; }
.topbar .back { background: none; border: 0; color: #fff; font-size: 22px; padding: 6px 8px 6px 0; cursor: pointer; }
.topbar .title { font-weight: 700; font-size: 16px; }

/* alt gezinme */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--accent2); }

main { padding: 14px; max-width: 760px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card + .card, .card + .col, .col + .card { margin-top: 12px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 2px 8px; }

/* düğmeler */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface2); font-weight: 650; cursor: pointer; user-select: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1c1500; }
.btn.danger { background: transparent; color: var(--lose); border-color: var(--lose); }
.btn.block { width: 100%; } .btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* form */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent2); outline-offset: 0; }
.error { color: var(--lose); font-size: 13px; font-weight: 600; min-height: 18px; }

/* çipler / rozetler */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 650; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface2); color: var(--muted); }
.badge.open { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--warn); }
.badge.won { background: color-mix(in srgb, var(--win) 18%, transparent); color: var(--win); }
.badge.lost { background: color-mix(in srgb, var(--lose) 16%, transparent); color: var(--lose); }
.badge.live { background: color-mix(in srgb, var(--accent2) 20%, transparent); color: var(--accent2); }

/* program listesi */
.race-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.race-row:last-child { border-bottom: 0; }
.race-row .no { width: 38px; height: 38px; border-radius: 10px; background: var(--surface2); display: grid; place-items: center; font-weight: 800; }
.race-row.done .no { opacity: .55; }
.list { padding: 0; overflow: hidden; }

/* Bi'Talih tarzı ana sayfa */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.hcard { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.hcard b { display: block; font-size: 14px; } .hcard small { color: var(--muted); font-size: 12px; }
.hcard.live { background: linear-gradient(135deg, var(--accent), #0f5a38); border-color: transparent; color: #fff; }
.hcard.live small { color: rgba(255,255,255,.8); }
.hico { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); display: grid; place-items: center; }
.hcard.live .hico { background: rgba(255,255,255,.18); }
.hico svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.subtabs { display: flex; margin: 4px 0 10px; border-bottom: 1px solid var(--border); }
.subtabs button { flex: 1; padding: 11px 6px; background: none; border: 0; border-bottom: 2.5px solid transparent; font-weight: 700; color: var(--muted); cursor: pointer; font-size: 14px; }
.subtabs button.on { color: var(--text); border-bottom-color: var(--accent2); }
.mhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--surface2); }
.rrow { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 7px; }
.rrow:last-child { border-bottom: 0; }
.rrow.done .rr-grp { opacity: .85; }
.rr-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; }
.rr-head b { white-space: nowrap; }
.rr-win { font-weight: 700; text-align: right; }
.rr-mid { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rr-grp { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trk { flex: none; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.trk.kum { background: #ead9ae; color: #5b4510; } .trk.cim { background: color-mix(in srgb, var(--win) 22%, transparent); color: var(--win); } .trk.sen { background: var(--surface2); color: var(--muted); }
.rr-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rr-ord { font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.rr-btn { flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 92px; padding: 7px 12px; border-radius: 10px; font-weight: 800; font-size: 14px; background: var(--surface2); color: var(--muted); }
.rr-btn small { font-size: 11px; font-weight: 600; opacity: .9; }
.rr-btn.open { background: var(--accent); color: #fff; }
.rr-btn.closed { color: var(--warn); }

.agfbar { height: 6px; border-radius: 3px; background: var(--surface2); margin-top: 7px; overflow: hidden; } .agfbar i { display: block; height: 100%; background: var(--accent2); border-radius: 3px; }
.menu-item { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 15px 16px; background: none; border: 0; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 650; font-size: 15px; text-align: left; cursor: pointer; text-decoration: none; }
.menu-item:last-child { border-bottom: 0; } .menu-item b { color: var(--muted); font-weight: 600; }

/* at tablosu ve seçim */
.horse { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.horse:last-child { border-bottom: 0; }
.horse.scratched { opacity: .45; text-decoration: line-through; }
.hno { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; background: var(--surface2); }
.horse .nm { font-weight: 700; }
.agf { flex: none; text-align: right; font-size: 12px; color: var(--muted); line-height: 1.2; }
.agf b { display: block; font-size: 14px; color: var(--text); }
.pick { flex: none; width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 13px; cursor: pointer; color: var(--muted); }
.pick.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.picks { display: flex; gap: 6px; }
.coltabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; }
.coltab { flex: none; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 13px; cursor: pointer; }
.coltab.on { border-color: var(--accent2); color: var(--accent2); }
.colhead { display: flex; gap: 6px; justify-content: flex-end; font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 12px 0; }
.colhead span { width: 40px; text-align: center; }

/* alt yapışkan bahis çubuğu */
.betbar { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 25; background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 -6px 18px rgba(0,0,0,.08); }
.betbar .sum { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.betbar .sum b { display: block; font-size: 18px; color: var(--text); }
.betbar .sum span { display: block; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--surface2); font-size: 20px; cursor: pointer; }
.stepper span { min-width: 38px; text-align: center; font-weight: 800; }
main.has-betbar { padding-bottom: 96px; }

/* modal / sheet */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; background: #111; color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; max-width: 92vw; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.toast.err { background: var(--lose); }

/* istatistik */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface2); border-radius: 12px; padding: 12px; }
.stat .v { font-size: 18px; font-weight: 800; } .stat .k { font-size: 12px; color: var(--muted); }
.bigbal { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }

/* kupon fişi */
.receipt { background: #fff; color: #111; width: 100%; max-width: 360px; margin: 0 auto; padding: 18px 16px; border-radius: 6px; box-shadow: 0 8px 28px rgba(0,0,0,.22);
  font-family: "Courier New", ui-monospace, monospace; font-size: 13px; position: relative; }
.receipt::before, .receipt::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; background: radial-gradient(circle at 6px 0, transparent 5px, #fff 5.5px) 0 0/12px 8px repeat-x; }
.receipt::before { top: -7px; transform: rotate(180deg); } .receipt::after { bottom: -7px; }
.receipt .rhead { text-align: center; border-bottom: 2px dashed #999; padding-bottom: 10px; margin-bottom: 10px; }
.receipt .rhead img { width: 44px; height: 44px; border-radius: 10px; }
.receipt .rname { font-weight: 800; font-size: 18px; letter-spacing: 1px; margin-top: 4px; }
.receipt .rline { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.receipt .rline b { text-align: right; }
.receipt .sep { border-top: 1px dashed #999; margin: 8px 0; }
.receipt .tok { text-align: center; font-size: 17px; font-weight: 800; letter-spacing: 1px; margin: 8px 0 2px; }
.receipt .qr { display: grid; place-items: center; padding: 6px 0; } .receipt .qr svg { width: 170px; height: 170px; }
.receipt .stamp { text-align: center; font-weight: 800; font-size: 17px; padding: 6px; border: 2px solid; border-radius: 6px; margin: 8px 0; transform: rotate(-3deg); }
.stamp.won { color: #0a7d36; } .stamp.lost { color: #b3261e; } .stamp.cancelled, .stamp.refunded { color: #777; } .stamp.open { color: #8a6100; }
.receipt .sel { padding-left: 8px; font-size: 12.5px; }

/* oyun seçici ve misli */
.betrow { display: flex; gap: 10px; align-items: stretch; margin: 10px 0 4px; }
.vsel { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px; min-height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; cursor: pointer; }
.vsel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mislibox { flex: none; width: 112px; display: flex; flex-direction: column; justify-content: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 4px 12px; }
.mislibox label { font-size: 11px; font-weight: 700; color: var(--muted); }
.mislibox input { border: 0; padding: 0; min-height: 26px; background: transparent; font-weight: 800; font-size: 18px; outline: none; width: 100%; }
.mislibox:focus-within { border-color: var(--accent2); }
.radiolist .opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 4px; border-bottom: 1px solid var(--border); cursor: pointer; font-weight: 650; }
.radiolist .opt:last-child { border-bottom: 0; }
.radio { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong, #bbb); display: grid; place-items: center; color: transparent; font-size: 14px; }
.opt.on .radio { background: var(--accent); border-color: var(--accent); color: #fff; }
.odds { font-size: 12px; font-weight: 800; color: var(--gold); white-space: nowrap; }
.ret { color: var(--win); font-weight: 700; }

/* canlı yayın penceresi */
.liveview { position: fixed; z-index: 70; background: #000; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.45); overflow: hidden; touch-action: none; border: 1px solid rgba(255,255,255,.18); }
.lv-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: #151a17; color: #fff; cursor: grab; user-select: none; touch-action: none; }
.liveview.dragging .lv-bar { cursor: grabbing; }
.lv-title { font-size: 13px; font-weight: 700; }
.lv-dot { width: 8px; height: 8px; border-radius: 50%; background: #e5372b; box-shadow: 0 0 0 3px rgba(229,55,43,.25); }
.lv-btn { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(255,255,255,.1); color: #fff; font-size: 14px; display: grid; place-items: center; cursor: pointer; text-decoration: none; }
.lv-ratio { position: relative; width: 100%; padding-top: 56.25%; background: #000; }
.lv-ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.liveview.dragging iframe { pointer-events: none; }
.lv-note { font-size: 11px; color: #9aa59f; padding: 5px 9px; background: #151a17; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent2); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 380px; }
.login img { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 14px; }
.rules h2 { margin: 22px 0 8px; } .rules p, .rules li { color: var(--text); } .rules ul { padding-left: 20px; margin: 6px 0; }
.rules table { width: 100%; border-collapse: collapse; font-size: 14px; } .rules th, .rules td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); } .rules th { color: var(--muted); font-size: 12px; }

@media print {
  body { background: #fff; padding: 0; } .topbar, .tabbar, .betbar, .no-print, .toast, .overlay > .sheet > :not(.receipt-wrap) { display: none !important; }
  main { padding: 0; max-width: none; } .receipt { box-shadow: none; max-width: 80mm; margin: 0; } .receipt::before, .receipt::after { display: none; }
  @page { size: 80mm auto; margin: 4mm; }
}
