/* 8 Hakkın Var — İznik çinisinden ilham: sırlı beyaz karolar, kobalt mürekkep, çini yeşili / safran / mercan kırmızısı sayaçlar.
   Yerleşim: tek ekran sütun. Başlık + çini şeridi, mod satırı, spiker satırı, 8 satırlık tahta, Türkçe Q klavye. */
:root {
  --bg: #F3F6FB;
  --surface: #FFFFFF;
  --ink: #132449;
  --muted: #5A6888;
  --line: #D2D9E8;
  --key: #E1E7F2;
  --key-edge: #C3CDE0;
  --accent: #1D4DB5;
  --on-accent: #FFFFFF;
  --g: #10806A;
  --y: #D59A16;
  --r: #C0352A;
  --on-g: #FFFFFF;
  --on-y: #241A00;
  --on-r: #FFFFFF;
  --glaze: rgba(255, 255, 255, 0.95);
  --shadow: rgba(19, 36, 73, 0.14);
  --scrim: rgba(12, 22, 48, 0.45);
  --f-display: "Bricolage Grotesque", "Arial Black", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1530; --surface: #14224A; --ink: #E9EFFF; --muted: #93A3C8; --line: #283A68;
    --key: #1E2E5A; --key-edge: #0E1838; --accent: #86A8FF; --on-accent: #0B1530;
    --g: #1FA586; --y: #E3AE2E; --r: #DD5240; --on-g: #FFFFFF; --on-y: #241A00; --on-r: #FFFFFF;
    --glaze: rgba(255, 255, 255, 0.07); --shadow: rgba(0, 0, 0, 0.4); --scrim: rgba(2, 6, 18, 0.62);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
}

/* ---------- Başlık ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.logo {
  margin: 0;
  display: flex; align-items: center; gap: 6px;
  font: 800 26px/1 var(--f-display);
  letter-spacing: -0.025em;
}
.logo b {
  font-weight: 800; font-size: 21px;
  padding: 3px 8px 5px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  transform: rotate(-4deg);
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: var(--key);
  box-shadow: inset 0 -3px 0 var(--key-edge);
  cursor: pointer;
  font: 800 17px/1 var(--f-display);
}
.icon svg { width: 18px; height: 18px; }
.streak {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 0 9px; height: 38px; border-radius: 10px;
  background: var(--key); color: var(--r);
  font: 600 15px/1 var(--f-mono);
}
.streak svg { width: 18px; height: 18px; }
.band {
  height: 6px; border-radius: 3px;
  background: conic-gradient(from 45deg, var(--accent) 25%, var(--g) 0 50%, var(--accent) 0 75%, var(--g) 0) 0 0 / 12px 12px;
  opacity: 0.9;
}

/* ---------- Mod satırı ---------- */
.meta { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.seg { display: flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--key); }
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 11px; border-radius: 8px;
  font: 700 13px/1.1 var(--f-body); color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22); }
.seg.practice button[aria-pressed="true"] { background: var(--y); color: var(--on-y); }
.hint-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; border-radius: 8px; padding: 5px 10px 5px 7px; cursor: pointer;
  background: var(--y); color: var(--on-y); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
  font: 700 12.5px/1.1 var(--f-body);
}
.hint-btn svg { width: 16px; height: 16px; }
.hint-btn[disabled] { opacity: 0.45; cursor: default; }
.levels { display: grid; gap: 8px; margin: 0 0 18px; }
.level { display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: baseline; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 13.5px; line-height: 1.45; }
.level b { font: 800 15px/1.2 var(--f-display); color: var(--accent); }
.tag {
  padding: 4px 9px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font: 600 12px/1.2 var(--f-body); letter-spacing: 0.04em; text-transform: uppercase;
}
.tag.practice { background: var(--y); color: var(--on-y); }
.tag.challenge { background: var(--r); color: var(--on-r); }
.num { font: 600 13.5px/1 var(--f-mono); color: var(--muted); }
.spacer { flex: 1; }
.back-btn {
  border: 1.5px solid var(--accent); background: transparent; color: var(--accent);
  border-radius: 8px; padding: 5px 10px; cursor: pointer;
  font: 600 12.5px/1.1 var(--f-body);
}

/* ---------- Tahta ---------- */
.board {
  --t: 46px;
  --c: max(20px, calc(var(--t) * 0.52));
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: safe center;
  justify-content: center;
  gap: 6px;
  padding-block: 2px;
}
.row { display: grid; grid-template-columns: repeat(5, var(--t)) auto; grid-auto-flow: column; gap: 5px; align-items: center; }
.tile {
  width: var(--t); height: var(--t);
  display: grid; place-items: center;
  padding: 0;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 7px;
  box-shadow: inset 0 2px 0 var(--glaze), 0 2px 0 var(--shadow);
  font: 800 calc(var(--t) * 0.52)/1 var(--f-display);
  color: var(--accent);
  user-select: none; -webkit-user-select: none;
}
.row.active .tile { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.row.active .tile.filled { border-color: var(--accent); animation: pop 0.13s ease-out; }
.row.last-chance .tile { border-style: dashed; border-color: var(--r); }
.row.done .tile { cursor: pointer; touch-action: manipulation; }
.tile.m-r { background: var(--r); border-color: var(--r); color: var(--on-r); }
.tile.m-y { background: var(--y); border-color: var(--y); color: var(--on-y); }
.tile.m-g, .row.win .tile { background: var(--g); border-color: var(--g); color: var(--on-g); }
.row.reveal .tile { animation: flip 0.45s ease-out both; animation-delay: calc(var(--i) * 80ms); }
.row.win .tile { animation: hop 0.5s ease-out both; animation-delay: calc(var(--i) * 90ms + 200ms); }
.row.shake { animation: shake 0.38s ease-in-out; }

.counts { display: flex; gap: 3px; margin-left: 7px; }
.cnt {
  width: var(--c); height: var(--c);
  display: grid; place-items: center;
  border-radius: 5px;
  font: 600 calc(var(--c) * 0.64)/1 var(--f-mono);
  font-variant-numeric: tabular-nums;
}
.cnt.g { background: var(--g); color: var(--on-g); }
.cnt.y { background: var(--y); color: var(--on-y); }
.cnt.r { background: var(--r); color: var(--on-r); }
.cnt.e { border: 1.5px dashed var(--line); }
.cnt.spin { filter: saturate(0.55) brightness(1.08); }
.cnt.land { animation: land 0.28s ease-out; }
.left {
  display: grid; justify-items: center; gap: 1px; min-width: 30px; margin-left: 6px;
  font: 600 calc(var(--c) * 0.62)/1 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums;
}
.left small { font: 600 9px/1 var(--f-body); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.hint-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 9px; border-radius: 8px; background: var(--g); color: var(--on-g);
  font: 700 12.5px/1.1 var(--f-body); white-space: nowrap;
}
.tdk-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg); color: var(--ink); text-decoration: none; font-weight: 600; }
.tdk-btn span { color: var(--accent); }

/* ---------- Klavye ---------- */
.kb { display: grid; gap: 7px; }
.kb-row { display: flex; gap: 4px; }
.key {
  flex: 1 1 0; min-width: 0;
  height: 50px;
  border: 0; border-radius: 7px;
  background: var(--key); color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--key-edge);
  font: 600 clamp(14px, 4.3vw, 19px)/1 var(--f-display);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.key:active { transform: translateY(2px); box-shadow: inset 0 -1px 0 var(--key-edge); }
.key.wide { flex: 1.55 1 0; font: 700 12.5px/1 var(--f-body); letter-spacing: 0.03em; }
.key.enter { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.key.wide svg { width: 21px; height: 21px; }
.key.k-r { background: var(--r); color: var(--on-r); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2); }
.key.k-y { background: var(--y); color: var(--on-y); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15); }
.key.k-g { background: var(--g); color: var(--on-g); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2); }
.kb.busy { opacity: 0.75; pointer-events: none; }

/* ---------- Bildirim ---------- */
.toast {
  position: fixed; left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 96px);
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px;
  font: 600 14.5px/1.25 var(--f-body);
  z-index: 40; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
  box-shadow: 0 8px 24px var(--shadow);
}
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 35; }

/* ---------- Alt sayfalar ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: var(--scrim);
  display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 16px) max(16px, env(safe-area-inset-left, 0px));
}
.sheet {
  position: relative;
  width: 100%; max-width: 440px; max-height: 100%;
  overflow-y: auto;
  background: var(--surface); color: var(--ink);
  border-radius: 16px;
  padding: 24px 20px 20px;
  box-shadow: 0 18px 50px var(--shadow);
  animation: rise 0.28s ease-out;
}
@media (max-width: 600px) {
  .overlay { align-items: flex-end; padding: calc(env(safe-area-inset-top, 0px) + 24px) 0 0; }
  .sheet {
    max-width: none; border-radius: 18px 18px 0 0;
    padding: 24px max(18px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 18px) max(18px, env(safe-area-inset-left, 0px));
  }
}
.sheet h2 { margin: 0 40px 12px 0; font: 800 24px/1.12 var(--f-display); letter-spacing: -0.015em; text-wrap: balance; }
.sheet h3 { margin: 22px 0 10px; font: 600 11.5px/1 var(--f-body); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.lead { margin: 0 0 14px; color: var(--muted); line-height: 1.5; }
.close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: var(--key); cursor: pointer; font: 600 20px/1 var(--f-body);
}
.steps { margin: 0 0 18px; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 16px; }
.steps li { counter-increment: s; position: relative; padding-left: 38px; line-height: 1.45; }
.steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: -2px;
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 7px; background: var(--accent); color: var(--on-accent);
  font: 800 14px/1 var(--f-display);
}
.steps b { display: block; margin-bottom: 2px; }
.ex { --t: 36px; --c: 21px; display: grid; justify-content: start; margin: 10px 0 8px; }
.ex .row.done .tile { cursor: default; }
.legend-line { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.chip { display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 5px; font: 600 12px/1 var(--f-mono); }
.chip.g { background: var(--g); color: var(--on-g); } .chip.y { background: var(--y); color: var(--on-y); } .chip.r { background: var(--r); color: var(--on-r); }
.fine { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

.btn {
  border: 0; border-radius: 11px; padding: 13px 18px;
  background: var(--accent); color: var(--on-accent);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22);
  font: 700 15px/1 var(--f-body); cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--key); color: var(--ink); box-shadow: inset 0 -3px 0 var(--key-edge); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: default; }

/* Sonuç */
.res-head { display: grid; gap: 6px; margin-bottom: 14px; }
.res-head .kicker { font: 600 12px/1 var(--f-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.answer-tiles { display: flex; gap: 6px; margin: 4px 0 2px; }
.answer-tiles span {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 7px; background: var(--g); color: var(--on-g);
  font: 800 23px/1 var(--f-display);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), 0 2px 0 var(--shadow);
}
.answer-tiles.lost span { background: var(--r); color: var(--on-r); }
.meaning { margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--bg); line-height: 1.5; font-size: 14.5px; }
.meaning small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.res-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.res-actions .btn:first-child { grid-column: 1 / -1; }
.community { display: grid; gap: 10px; }
.community .line { font-size: 14.5px; line-height: 1.45; }
.community .line b { font-family: var(--f-mono); font-weight: 600; }
.dist { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: center; font: 600 12px/1 var(--f-mono); }
.bar i {
  display: block; min-width: 26px; width: var(--w);
  background: var(--key); padding: 4px 6px; border-radius: 4px;
  text-align: right; font-style: normal; font-variant-numeric: tabular-nums;
}
.bar.me i { background: var(--g); color: var(--on-g); }
.mine { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.mine b { display: block; font: 600 24px/1.1 var(--f-mono); font-variant-numeric: tabular-nums; }
.mine span { font-size: 11.5px; color: var(--muted); }
.mine.three { grid-template-columns: repeat(3, 1fr); }
.next { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1.5px solid var(--line); font-size: 13px; color: var(--muted); }
.next b { font: 600 20px/1 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.ad-slot { margin-top: 18px; min-height: 100px; display: grid; place-items: center; border-radius: 10px; background: var(--bg); }

/* Meydan okuma */
.ch-form { display: flex; gap: 8px; }
.ch-form input {
  flex: 1; min-width: 0;
  padding: 12px 14px; border-radius: 11px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
  font: 800 22px/1 var(--f-display); letter-spacing: 0.12em; text-transform: uppercase;
}
.err { margin: 10px 0 0; color: var(--r); font-weight: 600; font-size: 14px; }
.ch-link {
  width: 100%; margin-top: 14px; padding: 11px 12px;
  border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
  font: 13px/1.3 var(--f-mono);
}
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.banner { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--r); color: var(--on-r); font: 600 13.5px/1.35 var(--f-body); }

/* ---------- Hareket ---------- */
@keyframes flip { 0% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes pop { 0% { transform: scale(0.86); } 100% { transform: scale(1); } }
@keyframes land { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes bump { 0% { transform: translateY(3px); opacity: 0.6; } 100% { transform: none; opacity: 1; } }
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-10px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes rise { 0% { transform: translateY(24px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-height: 640px) {
  .key { height: 44px; }
}
