/* ---------- Tema ---------- */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #16a34a;
  --primary-ink: #ffffff;
  --primary-soft: #dcfce7;
  --accent: #f59e0b;
  --accent-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --gold: #eab308;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --tab-h: 60px;
  --top-h: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #121a2b; --surface-2: #1a2437; --text: #e5e7eb; --muted: #94a3b8;
    --line: #243044; --primary: #22c55e; --primary-ink: #052e16; --primary-soft: #14321f;
    --accent: #fbbf24; --accent-soft: #3a2e0c; --danger: #f87171; --danger-soft: #3b1515;
    --info: #60a5fa; --info-soft: #14233d; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #121a2b; --surface-2: #1a2437; --text: #e5e7eb; --muted: #94a3b8;
  --line: #243044; --primary: #22c55e; --primary-ink: #052e16; --primary-soft: #14321f;
  --accent: #fbbf24; --accent-soft: #3a2e0c; --danger: #f87171; --danger-soft: #3b1515;
  --info: #60a5fa; --info-soft: #14233d; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

/* ---------- Temel ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[hidden] { display: none !important; }

#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 700; font-size: 17px; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center;
  font-size: 20px; color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }

.view { flex: 1; padding: 14px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 20px); max-width: 640px; width: 100%; margin: 0 auto; }
body.no-tabs .view { padding-bottom: 24px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar a .ic { font-size: 22px; line-height: 1; }
.tabbar a.active { color: var(--primary); }
.tabbar a .dot { position: absolute; margin-left: 22px; margin-top: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* ---------- Bileşenler ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card + .card { margin-top: 12px; }
.card-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }

.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(--line); background: var(--surface); font-weight: 600; width: 100%;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; width: auto; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); outline: none;
}
.input:focus { border-color: var(--primary); }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.chip.green { background: var(--primary-soft); color: var(--primary); }
.chip.amber { background: var(--accent-soft); color: var(--accent); }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.blue { background: var(--info-soft); color: var(--info); }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 18px; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 32px; }
.avatar.sm { width: 26px; height: 26px; font-size: 13px; }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; border: 0; background: transparent; border-radius: 10px; min-height: 36px; font-weight: 600; color: var(--muted); font-size: 14px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.week-nav .wk { font-weight: 700; font-size: 16px; text-align: center; }
.week-nav .wk small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.week-nav button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 18px; }

.list { display: grid; gap: 10px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; }
.list-item:active { background: var(--surface-2); }

/* ---------- Maç kartı ---------- */
.match { padding: 12px; }
.match .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.match .teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.match .team { font-weight: 700; font-size: 15px; }
.match .team.away { text-align: right; }
.match .team small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.score-box { display: flex; align-items: center; gap: 4px; }
.stepper { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stepper button { width: 40px; height: 30px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; font-size: 16px; line-height: 1; }
.stepper button:active { background: var(--primary-soft); }
.stepper .val { width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); text-align: center; font-size: 20px; font-weight: 800; padding: 0; }
.stepper .val.set { border-color: var(--primary); }
.stepper .val:focus { outline: none; border-color: var(--primary); }
.sep { font-weight: 800; font-size: 20px; color: var(--muted); }
.match.locked .stepper button { visibility: hidden; }
.match.locked .stepper .val { background: var(--surface-2); border-color: transparent; }
.result { text-align: center; font-size: 13px; margin-top: 6px; }
.result .fs { font-weight: 800; font-size: 18px; }
.pts { display: inline-block; min-width: 28px; padding: 2px 8px; border-radius: 8px; font-weight: 800; font-size: 13px; text-align: center; }
.pts.p0 { background: var(--surface-2); color: var(--muted); }
.pts.p1 { background: var(--info-soft); color: var(--info); }
.pts.p2 { background: var(--accent-soft); color: var(--accent); }
.pts.p3 { background: var(--primary-soft); color: var(--primary); }
.match .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.joker-btn { border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.joker-btn.on { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.others { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; display: grid; gap: 4px; }
.others .o { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.others .o .sc { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Kayıt durumu (maç kartı) */
.save-state { text-align: center; font-size: 12px; margin-top: 8px; min-height: 16px; color: var(--muted); transition: color .2s; }
.save-state[data-state="saved"] { color: var(--primary); font-weight: 600; }
.save-state[data-state="saving"] { color: var(--muted); font-style: italic; }
.save-state[data-state="incomplete"] { color: var(--accent); font-weight: 600; }
.save-state[data-state="error"] { color: var(--danger); font-weight: 600; }
.save-state[data-state="empty"] { color: var(--muted); opacity: .7; }

/* Alt onay çubuğu (sekme çubuğunun üstünde) */
.savebar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 19;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 640px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(15,23,42,.08);
}
.savebar .btn.sm { min-height: 40px; white-space: nowrap; }
body.has-savebar .view { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 90px); }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* ---------- Sıralama ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .rank { font-weight: 800; width: 32px; }
.table tr.me td { background: var(--primary-soft); }
.table tr.me td:first-child { border-radius: 10px 0 0 10px; }
.table tr.me td:last-child { border-radius: 0 10px 10px 0; }
.mv { font-size: 11px; font-weight: 700; margin-left: 2px; }
.mv.up { color: var(--primary); } .mv.down { color: var(--danger); } .mv.same { color: var(--muted); }
.crown { font-size: 14px; }
.total-pts { font-size: 17px; font-weight: 800; }

/* ---------- Sohbet ---------- */
.chat { display: flex; flex-direction: column; min-height: calc(100vh - var(--top-h) - var(--tab-h) - 120px); }
.chat .msgs { flex: 1; display: grid; gap: 8px; align-content: end; padding-bottom: 8px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 85%; }
.msg.me { margin-left: auto; flex-direction: row-reverse; }
.msg .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px; }
.msg.me .bubble { background: var(--primary-soft); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.msg .who { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.msg .time { font-size: 10px; color: var(--muted); margin-top: 2px; text-align: right; }
.composer { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 0; background: var(--bg); }
.composer .input { flex: 1; min-height: 44px; max-height: 120px; resize: none; }
.composer .btn { width: 48px; padding: 0; border-radius: 12px; }
.sys { text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Rozetler ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.badge { text-align: center; padding: 10px 6px; border-radius: 12px; background: var(--surface-2); }
.badge .ic { font-size: 28px; }
.badge .nm { font-size: 11px; font-weight: 700; margin-top: 4px; }
.badge.off { opacity: .35; filter: grayscale(1); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 10px 4px; background: var(--surface-2); border-radius: 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11px; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 48px; }
.spark i { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

/* ---------- Toast / Modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.err { background: var(--danger); color: #fff; }
body.has-savebar .toast { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 86px); }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet {
  width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.modal .sheet .handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Giriş ---------- */
.hero { text-align: center; padding: 40px 0 24px; }
.hero .logo { font-size: 64px; }
.hero h1 { font-size: 26px; margin-top: 8px; }
.hero p { color: var(--muted); margin-top: 8px; }
.gbtn { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.feature { display: flex; gap: 12px; align-items: flex-start; }
.feature .ic { font-size: 22px; width: 32px; text-align: center; }

.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 26px; font-weight: 800; letter-spacing: .25em; text-align: center; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; text-align: center; font-size: 20px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 10px; height: 72px; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.banner { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--info-soft); color: var(--info); font-size: 13px; font-weight: 600; }
.banner.warn { background: var(--accent-soft); color: var(--accent); }
.banner button { margin-left: auto; }
