:root {
  --bg: #F6F6F9;
  --card: #FFFFFF;
  --line: #E8E8EE;
  --line-soft: #F1F1F5;
  --text: #17181F;
  --muted: #4A4C59;
  --accent: #C2410C;
  --accent-soft: #FFF1E7;
  --accent-text: #9A3412;
  --on-accent: #FFFFFF;
  --invert-bg: #17181F;
  --invert-text: #FFFFFF;
  --hit: #16A34A; --hit-bg: #DCFCE7; --hit-text: #166534;
  --mid: #F59E0B; --mid-bg: #FEF3C7; --mid-text: #92400E;
  --none: #E4E4E7; --none-bg: #F1F1F5;
  --bad: #DC2626; --bad-bg: #FEE2E2; --bad-text: #991B1B;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E0F14; --card: #171820; --line: #2A2C36; --line-soft: #22232C; --text: #F1F1F5; --muted: #B9BBC7;
    --accent: #FB923C; --accent-soft: #2A1A0F; --accent-text: #FDBA74; --on-accent: #0E0F14; --invert-bg: #ECECF1; --invert-text: #0E0F14;
    --hit: #22C55E; --hit-bg: #12301F; --hit-text: #86EFAC; --mid: #F59E0B; --mid-bg: #2E2412; --mid-text: #FCD34D; --none: #3F3F46; --none-bg: #22232C; --bad: #EF4444; --bad-bg: #3A1618; --bad-text: #FCA5A5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E0F14; --card: #171820; --line: #2A2C36; --line-soft: #22232C; --text: #F1F1F5; --muted: #B9BBC7;
  --accent: #FB923C; --accent-soft: #2A1A0F; --accent-text: #FDBA74; --on-accent: #0E0F14; --invert-bg: #ECECF1; --invert-text: #0E0F14;
  --hit: #22C55E; --hit-bg: #12301F; --hit-text: #86EFAC; --mid: #F59E0B; --mid-bg: #2E2412; --mid-text: #FCD34D; --none: #3F3F46; --none-bg: #22232C; --bad: #EF4444; --bad-bg: #3A1618; --bad-text: #FCA5A5;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 900px) { .wrap { padding: 0 40px; } }

/* Üst bar */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 12px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 19px; text-decoration: none; }
.logo span { color: var(--accent); }
.teams { display: flex; gap: 8px; order: 3; width: 100%; }
.teams a { flex: 1; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 6px 12px;
  border-radius: 12px; border: 1px solid var(--line); text-decoration: none; font-weight: 700; font-size: 15px; color: var(--muted); white-space: nowrap; }
.teams a[aria-current="page"] { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.tcrest { width: 24px; height: 24px; object-fit: contain; background: #fff; border-radius: 999px; padding: 2px; }
.badge-n { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-style: normal; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.user { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; text-decoration: none; border: 0; background: var(--line-soft); color: var(--text); }
.chip.me { background: var(--accent-soft); color: var(--accent-text); }
.iconbtn { width: 36px; height: 36px; border-radius: 999px; border: 0; background: var(--line-soft); display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.iconbtn svg { width: 18px; height: 18px; }

/* Oyun menüsü: telefonda altta sabit, masaüstünde üst barın altında */
.games { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.games .wrap { display: flex; padding: 0; }
.games a { flex: 1; text-align: center; padding: 14px 4px 16px; text-decoration: none; font-weight: 600; font-size: 14px; color: var(--muted); }
.games a[aria-current="page"] { color: var(--accent); font-weight: 800; }
main { padding: 20px 0 110px; }
@media (min-width: 900px) {
  .top .wrap { column-gap: 28px; flex-wrap: nowrap; }
  .teams { order: 0; width: auto; }
  .teams a { flex: none; }
  .games { position: static; border-top: 0; border-bottom: 1px solid var(--line); }
  .games .wrap { gap: 28px; padding: 0 40px; }
  .games a { flex: none; padding: 12px 0; font-size: 15px; border-bottom: 3px solid transparent; }
  .games a[aria-current="page"] { border-bottom-color: var(--accent); }
  main { padding-bottom: 60px; }
}
@media (max-width: 520px) { .teams a span { display: none; } .teams a { padding: 6px; } .tcrest { width: 30px; height: 30px; } }

/* Takım başlığı ve oyun çubuğu */
.teamhead { display: flex; align-items: center; gap: 14px; padding: 14px 0 16px; margin-bottom: 18px; border-bottom: 4px solid; border-image: linear-gradient(90deg, var(--c1) 50%, var(--c2) 50%) 1; }
.teamhead h1 { margin: 0; font-size: 28px; font-weight: 800; }
.bigcrest { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 999px; padding: 4px; }
.gamebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.gamebar h2 { margin: 0; font-size: 20px; font-weight: 800; }
.gamebtns { display: flex; gap: 8px; }
.gamebtns .btn { min-height: 40px; padding: 0 14px; font-size: 14px; }

/* Açılır pencere */
dialog#modal { width: min(900px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); color: var(--text); }
dialog#modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; background: var(--card); border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.modal-head small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.modal-body { padding: 16px 18px 22px; }

/* Kim Kazanır: Excel tablosu, ilk sütun sabit */
.sheet td, .sheet th { padding: 9px 10px; }
.sheet .stick { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: 1px 0 0 var(--line); max-width: 180px; white-space: normal; }
.sheet td.mecol, .sheet th.mecol { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
.sheet tr.sum td { border-top: 2px solid var(--line); background: var(--line-soft); }
.sheet tr.sum td.stick { background: var(--line-soft); }

/* Başlıklar */
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.head h1, .head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.head h2 { font-size: 20px; }
.head .muted { font-size: 14px; }
.section { margin-bottom: 36px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; }
.box-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 16px; margin-bottom: 8px; }
.box-title small { font-size: 12px; color: var(--muted); font-weight: 600; }
.split { display: grid; gap: 18px; }
@media (min-width: 900px) { .split { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } }

/* Maç listesi */
.list { display: grid; gap: 10px; }
@media (min-width: 700px) { .list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mrow { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 12px; }
.mrow.done { border-color: var(--hit-bg); }
.mmeta { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.mstate { font-weight: 600; white-space: nowrap; }
.mrow:not(.done):not(.locked) .mstate { color: var(--accent-text); }
.mrow.done .mstate { color: var(--hit-text); }
.tline { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; }
.tm { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; font-size: 17px; }
.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal { flex-shrink: 0; width: 54px; height: 44px; text-align: center; border: 2px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 800; font-size: 22px; -moz-appearance: textfield; }
.goal:focus { border-color: var(--accent); outline: none; }
.goal::placeholder { color: var(--muted); opacity: .6; }
.goal::-webkit-outer-spin-button, .goal::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score { font-weight: 800; font-size: 22px; min-width: 54px; text-align: center; }
.pts { padding: 1px 10px; border-radius: 999px; background: var(--none-bg); color: var(--text); }
.pts.p5 { background: var(--hit-bg); color: var(--hit-text); }
.pts.p3, .pts.p2 { background: var(--mid-bg); color: var(--mid-text); }
.livebadge { color: var(--accent-text); }
details { margin-top: 6px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
summary { cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; min-height: 32px; display: flex; align-items: center; gap: 4px; }
summary b { color: var(--text); }
details .picks { margin-top: 8px; }
.progress { font-size: 14px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; }
.progress.ok { color: var(--hit-text); background: var(--hit-bg); }
.hint { margin: -6px 0 14px; color: var(--muted); font-size: 15px; }
.btn { min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--line-soft); color: var(--text); }
.save-state { font-size: 14px; color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { border-radius: 999px; padding: 4px 11px; font-size: 14px; background: var(--none-bg); color: var(--muted); }
.pick b { color: var(--text); }
.pick.p5 { background: var(--hit-bg); color: var(--hit-text); }
.pick.p3, .pick.p2 { background: var(--mid-bg); color: var(--mid-text); }
.pick.p5 b, .pick.p3 b, .pick.p2 b { color: inherit; }
.pick.me { font-weight: 700; box-shadow: inset 0 0 0 2px currentColor; }
.empty { padding: 20px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 14px; }

/* Form kareleri (son 5 maç) */
.form { display: inline-flex; gap: 3px; }
.form i { width: 14px; height: 14px; border-radius: 4px; background: var(--none); }
.form i.p5 { background: var(--hit); }
.form i.p3, .form i.p2 { background: var(--mid); }

/* Tablolar */
.tablebox { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
th:first-child, td:first-child, td.l, th.l { text-align: left; }
tr.me td { background: var(--accent-soft); }
tr.me td.name { font-weight: 800; }
td.name { font-weight: 600; }
td.big { font-weight: 800; font-size: 16px; }
td.hit { background: var(--hit-bg); color: var(--hit-text); font-weight: 700; }
td.miss { background: var(--bad-bg); color: var(--bad-text); }
td.c, th.c { text-align: center; }
.rank { width: 2.5em; color: var(--muted); font-weight: 700; }
tr:first-child .rank, .rank.first { color: var(--accent); }
.mini table td { padding: 9px 4px; }
.mini .tablebox, .mini table { border: 0; }

/* İstatistik kartları */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 28px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 30px; font-weight: 800; line-height: 1.15; margin-top: 4px; }
.stat .who { font-weight: 700; }
.stat.dark { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.stat.dark .label { color: inherit; opacity: .75; }
h3.sub { font-size: 18px; font-weight: 800; margin: 28px 0 12px; }

/* Grafik */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--none); stroke-width: 2; }
.chart .line.on { stroke: var(--accent); stroke-width: 3.5; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.legend button { font-size: 13px; padding: 6px 12px; min-height: 36px; border-radius: 999px; background: var(--line-soft); border: 0; }
.legend button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }

/* Giriş */
.login { max-width: 520px; margin: 0 auto; padding: 32px 0 60px; }
.login h1 { font-size: 28px; font-weight: 800; margin: 0 0 6px; }
.names { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.names button { min-height: 60px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-weight: 700; font-size: 17px; text-align: left; padding: 10px 16px; }
.names button:hover { border-color: var(--accent); color: var(--accent); }
.pinform { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.pinform label { font-size: 13px; font-weight: 700; color: var(--muted); }
.pinform input { height: 56px; font-size: 26px; font-weight: 800; letter-spacing: .3em; padding: 0 16px; background: var(--card); border: 2px solid var(--line); border-radius: 14px; max-width: 240px; }
.pinform input:focus { border-color: var(--accent); outline: none; }
.err { color: var(--accent-text); font-weight: 600; font-size: 14px; min-height: 1.2em; margin: 0; }

.admin-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.admin-row:last-child { border-bottom: 0; }
.admin-row .name { flex: 1; min-width: 120px; font-weight: 700; }
.foot { margin-top: 20px; font-size: 13px; color: var(--muted); }

/* Takım logoları */
.team { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.crest { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; background: #fff; border-radius: 999px; padding: 3px; }
h2.team .crest { width: 28px; height: 28px; }
@media (max-width: 899px) { .user { gap: 6px; } .user .chip { padding: 6px 10px; font-size: 12px; } .logo { font-size: 17px; } }
.iconbtn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 420px) { .user .chip.me { display: none; } }
@media (max-width: 1099px) { .user .chip.me { display: none; } }
@media (max-width: 599px) { .hide-sm { display: none; } }
th { font-size: 13px; }
table { font-size: 15px; }
.foot { font-size: 14px; }
.pick.miss { opacity: .6; }
.pick.p0, .pts.p0 { background: var(--bad-bg); color: var(--bad-text); }
.pick.p0 b { color: inherit; }
.form i.p0 { background: var(--bad); }
.lockbanner { margin: 0 0 16px; padding: 16px 18px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); font-size: 22px; font-weight: 800; line-height: 1.25; }
.lockbanner small { display: block; margin-top: 4px; font-size: 15px; font-weight: 600; }
.score.sm { font-size: 18px; min-width: 0; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat .v { font-size: 26px; }
.stat .who { overflow-wrap: anywhere; }
.badge-n[hidden] { display: none; }
.sheet .stick small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
@media (max-width: 599px) { dialog#modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; } .modal-body { padding: 12px 12px 24px; } .modal-body th, .modal-body td { padding: 9px 7px; } }
.allpicks { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.picks-title { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
