/* =========================================================
   BASAMAK — tipografik merdiven
   Tasarım sistemi. Sahibi: tasarım tarafı (DESIGN.md'ye bak).
   Mantık tarafı bu dosyayı DEĞİŞTİRMEZ; yalnızca data-* / hidden
   niteliklerini çevirir.
   ========================================================= */

/* ---------- Yazı tipleri (self-host) ---------- */

@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 100%;
  font-display: swap;
  src: url('./fonts/BricolageGrotesque-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 100%;
  font-display: swap;
  src: url('./fonts/BricolageGrotesque-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('./fonts/JetBrainsMono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('./fonts/JetBrainsMono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Renk token'ları ----------
   <html data-theme="light|dark"> ile zorlanır; nitelik yoksa sistem temasını izler.
   data-theme herhangi bir eleman üzerinde de kullanılabilir (demo.html yan yana gösterir). */

:root,
[data-theme='light'] {
  --c-bg: #F1EDE4;
  --c-fg: #141414;
  --c-accent: #FF4A1C;
  --c-on-accent: #141414;
  --c-fg-70: rgba(20, 20, 20, 0.70);
  --c-fg-38: rgba(20, 20, 20, 0.38);
  --c-fg-55: rgba(20, 20, 20, 0.55);
  --c-fg-12: rgba(20, 20, 20, 0.12);
  --c-accent-14: rgba(255, 74, 28, 0.14);
  --c-google-bg: #FFFFFF;
  --c-google-fg: #1F1F1F;
  --c-google-line: #747775;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --c-bg: #121110;
    --c-fg: #EDE8DD;
    --c-fg-70: rgba(237, 232, 221, 0.70);
    --c-fg-38: rgba(237, 232, 221, 0.38);
    --c-fg-55: rgba(237, 232, 221, 0.55);
    --c-fg-12: rgba(237, 232, 221, 0.12);
    --c-google-bg: #131314;
    --c-google-fg: #E3E3E3;
    --c-google-line: #8E918F;
    color-scheme: dark;
  }
}

[data-theme='dark'] {
  --c-bg: #121110;
  --c-fg: #EDE8DD;
  --c-fg-70: rgba(237, 232, 221, 0.70);
  --c-fg-38: rgba(237, 232, 221, 0.38);
  --c-fg-55: rgba(237, 232, 221, 0.55);
  --c-fg-12: rgba(237, 232, 221, 0.12);
  --c-google-bg: #131314;
  --c-google-fg: #E3E3E3;
  --c-google-line: #8E918F;
  color-scheme: dark;
}

:root {
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;

  --gap: 14px;            /* satırlar arası boşluk (yol çizgisinin yatay şeridi burada) */
  --pad-x: 16px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --t-fast: 120ms;
  --t-base: 180ms;
}

/* ---------- Temel ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--c-bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  background: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

p, h1, h2, h3, ol, ul, fieldset, figure { margin: 0; }
ol, ul { padding: 0; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

::selection { background: var(--c-accent); color: var(--c-on-accent); }

.sr-only {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  margin: -1px !important; padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:focus-visible { outline: 2px solid var(--c-fg); outline-offset: 2px; }

/* ---------- Kâğıt greni (tek katman, sabit) ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* ---------- Kabuk ---------- */

.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  margin: 0 auto;
  padding:
    calc(16px + env(safe-area-inset-top))
    var(--pad-x)
    calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 560px) {
  .app { border-inline: 1px solid var(--c-fg-12); }
}

.masthead {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--c-fg-12);
}

.brand {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 760;
  font-variation-settings: 'opsz' 96;
  letter-spacing: 0.02em;
  line-height: 1;
  text-decoration: none;
}

.masthead-actions { display: flex; gap: 4px; }

/* ---------- Etiketler ve metin düğmeleri ---------- */

.label,
.text-button,
.meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.label { color: var(--c-fg-70); }
.label b, .meta b { color: var(--c-fg); font-weight: 600; }

.text-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--c-fg-70);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-out);
}
.text-button:hover { color: var(--c-fg); }
.text-button:active { transform: translateY(1px); }
.masthead-actions .text-button { margin-bottom: -14px; margin-top: -14px; padding: 0 6px; }
.masthead-actions .text-button:last-child { padding-right: 0; }

/* ---------- Menü (açılır liste) ---------- */

.menu {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top) + 34px);
  right: var(--pad-x);
  z-index: 4;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
  border: 1px solid var(--c-fg);
}
.menu .text-button { justify-content: space-between; padding: 0 14px; color: var(--c-fg); }
.menu .text-button + .text-button { border-top: 1px solid var(--c-fg-12); }
.menu .text-button:hover { background: var(--c-fg-12); }

/* ---------- Ekranlar ---------- */

.screen {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen--game {
  flex: 1 1 auto;
  padding-top: 12px;
}

/* Oyun dışındaki ekranlar oyunun üstüne biner (kazanma kartı aşağıdan kayabilsin diye). */
.screen:not(.screen--game) {
  position: absolute;
  inset: 0;
  z-index: 5;
  padding:
    calc(16px + env(safe-area-inset-top))
    var(--pad-x)
    calc(16px + env(safe-area-inset-bottom));
  background: var(--c-bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.screen:not(.screen--game)::-webkit-scrollbar { display: none; }

.screen-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--c-fg-12);
}

.screen-title {
  font-size: 26px;
  font-weight: 700;
  font-variation-settings: 'opsz' 96;
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.back-button {
  appearance: none;
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  padding: 0;
  border: 1px solid var(--c-fg-38);
  border-radius: 0;
  background: none;
  font-size: 18px;
  line-height: 1;
  transition: border-color var(--t-fast) var(--ease-out);
}
.back-button:hover { border-color: var(--c-fg); }

/* ---------- Oyun: künye ---------- */

.meta-block {
  flex: none;
  display: grid;
  gap: 2px;
}
.meta-row { display: flex; justify-content: space-between; gap: 12px; }
.meta { color: var(--c-fg-70); }

/* ---------- Oyun: tahta ---------- */

.board {
  --n: 4;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  container-type: inline-size;
}
.board[data-n='5'] { --n: 5; }

.path-layer {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
}
.path-layer path {
  fill: none;
  stroke: var(--c-accent);
  stroke-width: 1.5;
  stroke-linecap: butt;
  stroke-linejoin: round;
}

.group { flex: none; position: relative; z-index: 1; }
.group > .label { display: block; margin-bottom: 8px; }

.group[data-group='target'] {
  margin-top: var(--gap);
  padding-top: 10px;
  border-top: 1px solid var(--c-fg-12);
}

.rungs {
  flex: 0 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--gap) 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.rungs::-webkit-scrollbar { display: none; }
.rungs:empty { padding: 0; }
.rungs:empty + .row[data-row='active'],
.rungs:empty ~ .row[data-row='active'] { margin-top: calc(var(--gap) * 2); }

/* Satır = n eşit sütun. Taşlar sütun merkezine hizalı; boyutu --s belirler. */
.row {
  --s: 0.5;
  --inset: 0px;
  position: relative;
  z-index: 1;
  flex: none;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
}
.row[data-row='active'] { --s: 1; --inset: 6px; }
.row[data-row='target'] { --s: 0.7; }

/* ---------- Taş ---------- */

.tile {
  appearance: none;
  position: relative;
  justify-self: center;
  width: calc(100% * var(--s) - var(--inset));
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--c-fg-38);
  border-radius: 2px;
  background: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--font-display);
  font-size: calc(100cqw / var(--n) * var(--s) * 0.64);
  font-weight: 500;
  font-variation-settings: 'opsz' 96;
  line-height: 1;
  letter-spacing: -0.02em;
  -webkit-user-select: none;
  user-select: none;
  transition: border-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}

.tile-ink,
.tile-fill {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease-out);
}
.tile-ink { background: var(--c-fg); }
.tile-fill { background: var(--c-accent-14); }

.tile-letter {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}
.tile-letter--out {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* başlangıç + geçmiş basamak */
.row[data-row='start'] .tile,
.row[data-row='rung'] .tile {
  border-color: var(--c-fg-12);
  color: var(--c-fg-55);
  font-weight: 400;
}

/* hedef satırı */
.row[data-row='target'] .tile {
  border: 2px solid var(--c-fg);
  font-weight: 600;
}

/* değişen harf (istasyon) */
.tile[data-changed='true'],
.row .tile[data-changed='true'] {
  border-color: var(--c-accent);
  border-width: 1.5px;
}

/* hedefle eşleşen */
.tile[data-state='match'] { border-color: var(--c-accent); }
.tile[data-state='match'] .tile-fill { opacity: 1; }

/* seçili (eşleşenden önceliklidir; sonra yazıldığı için kazanır) */
.tile[data-state='selected'] { border-color: var(--c-fg); color: var(--c-bg); }
.tile[data-state='selected'] .tile-ink { opacity: 1; }

button.tile { cursor: pointer; touch-action: manipulation; }
button.tile:hover:not([data-state='selected']) { border-color: var(--c-fg); }
button.tile[data-state='match']:hover { border-color: var(--c-accent); }
button.tile:active { transform: scale(0.97); }
.tile:focus-visible { outline-offset: 3px; z-index: 2; }

/* ---------- Klavye ---------- */

.keyboard {
  flex: none;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--c-fg-12);
}
.key-row { display: flex; justify-content: center; margin-bottom: 4px; }

.key {
  appearance: none;
  position: relative;
  flex: 0 0 calc(100% / 11);
  height: 48px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 1px;
  background: none;
  color: var(--c-fg);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  font-variation-settings: 'opsz' 48;
  line-height: 1;
}
/* görünmez dokunma alanı: en az 44×44 */
.key::before { content: ''; position: absolute; inset: -2px -6px; }
.key:active { border-color: var(--c-fg); transition: none; }
.key[disabled] { color: var(--c-fg-38); }

.game-actions {
  flex: none;
  display: flex;
  justify-content: space-between;
  padding-top: 2px;
  border-top: 1px solid var(--c-fg-12);
  margin-top: 4px;
}
.game-actions .text-button { padding: 0 2px; }

/* ---------- Düğmeler ---------- */

.button {
  appearance: none;
  width: 100%;
  min-height: 52px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 20px;
  border: 1.5px solid var(--c-fg);
  border-radius: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}
.button:hover { background: var(--c-fg); color: var(--c-bg); }
.button:active { transform: translateY(1px); }
.button--primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.button--primary:hover { background: var(--c-fg); border-color: var(--c-fg); color: var(--c-bg); }

/* ---------- Kazanma ---------- */

.screen--win .meta-row { margin-bottom: 18px; }

.stars { display: flex; gap: 6px; margin-bottom: 14px; }
.star {
  width: 26px; height: 26px;
  background: var(--c-fg-12);
  clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 60%, 80% 100%, 50% 77%, 20% 100%, 30% 60%, 0 38%, 38% 35%);
}
.star[data-on='true'] { background: var(--c-accent); }

.win-title {
  font-size: clamp(44px, 14vw, 60px);
  font-weight: 760;
  font-variation-settings: 'opsz' 96;
  letter-spacing: -0.04em;
  line-height: 0.9;
}
.win-sub { margin-top: 10px; margin-bottom: 20px; }
.win-sub b { color: var(--c-fg); }

.route-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 16px 0 18px;
  border-top: 1px solid var(--c-fg-12);
  border-bottom: 1px solid var(--c-fg-12);
  margin-bottom: 18px;
}
.route > .label { display: block; margin-bottom: 12px; }

.route-ladder {
  --mini: 28px;
  --n: 4;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.route-ladder[data-n='5'] { --n: 5; --mini: 24px; }
.route-row {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.route-ladder .row {
  --s: 1; --inset: 0px;
  grid-template-columns: repeat(var(--n), var(--mini));
  gap: 3px;
}
.route-ladder .tile {
  width: var(--mini);
  font-size: calc(var(--mini) * 0.62);
  font-weight: 500;
}
.route-ladder .row[data-row='start'] .tile,
.route-ladder .row[data-row='rung'] .tile { color: var(--c-fg-70); }
.route--player .row[data-row='start'] .tile,
.route--player .row[data-row='rung'] .tile { color: var(--c-fg); }

.gloss {
  min-width: 0;
  color: var(--c-fg-70);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gloss:empty { display: none; }

.win-actions { display: grid; gap: 8px; margin-top: 6px; }
.win-links { display: flex; justify-content: flex-start; }
.win-reward { margin-top: -6px; margin-bottom: 14px; color: var(--c-fg); }
.win-title-solution { display: none; }
/* pes edilmiş oyun: yıldız yok, başlık ÇÖZÜM, yalnızca örnek yol */
[data-outcome='surrender'] .win-title-steps { display: none; }
[data-outcome='surrender'] .win-title-solution { display: inline; }
[data-outcome='surrender'] .stars,
[data-outcome='surrender'] .win-reward,
[data-outcome='surrender'] .route--player { display: none; }
[data-outcome='surrender'] .route-grid { grid-template-columns: 1fr; }
.guest-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  margin-top: 6px;
  border-top: 1px solid var(--c-fg-12);
}
.guest-note .label { color: var(--c-fg-70); }
.countdown { margin-top: auto; padding-top: 18px; }

/* ---------- İstatistik ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--c-fg-12);
  margin-bottom: 24px;
}
.stat { padding: 16px 0 14px; border-bottom: 1px solid var(--c-fg-12); }
.stat:nth-child(odd) { padding-right: 14px; border-right: 1px solid var(--c-fg-12); }
.stat:nth-child(even) { padding-left: 14px; }
.stat-value {
  display: block;
  margin-bottom: 6px;
  font-size: 44px;
  font-weight: 700;
  font-variation-settings: 'opsz' 96;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

.panel { margin-bottom: 26px; }
.panel > .label { display: block; margin-bottom: 12px; }

.bars { display: grid; gap: 8px; }
.bar-row {
  display: grid;
  grid-template-columns: 62px 1fr 24px;
  align-items: center;
  gap: 10px;
}
.bar-track { height: 10px; background: var(--c-fg-12); }
.bar-fill { height: 100%; width: var(--bar, 0%); background: var(--c-accent); transform-origin: left; }
.bar-fill[data-dim='true'] { background: var(--c-fg-38); }
.bar-value { text-align: right; }

.history { display: grid; grid-template-columns: repeat(15, 1fr); gap: 3px; }
.day { aspect-ratio: 1; border: 1px solid var(--c-fg-12); }
.day[data-result='win'] { background: var(--c-accent); border-color: var(--c-accent); }
.day[data-result='loss'] { background: var(--c-fg-38); border-color: var(--c-fg-38); }

.screen-actions { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--c-fg-12); display: flex; justify-content: space-between; }

/* ---------- Nasıl oynanır ---------- */

.how-mark { display: block; height: 40px; width: 40px; margin-bottom: 14px; color: var(--c-fg); }

.how-intro { max-width: 34ch; margin-bottom: 18px; color: var(--c-fg-70); font-size: 15px; line-height: 1.5; }
.how-steps { list-style: none; border-top: 1px solid var(--c-fg-12); margin-bottom: 20px; }
.how-step {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--c-fg-12);
}
.how-number { align-self: start; padding-top: 3px; color: var(--c-fg-38); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; }
.how-step h3 { font-size: 19px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.15; }
.how-step p { margin-top: 3px; color: var(--c-fg-70); font-size: 13.5px; line-height: 1.45; }

/* Mini taşlar: gerçek taşla aynı biçim, sabit boyut. */
.mini { display: grid; grid-template-columns: repeat(4, 30px); gap: 3px; }
.mini .tile {
  width: 30px; font-size: 18px; --s: 1;
}
.mini .tile-letter { position: absolute; inset: 0; }

/* döngüler: 6s. Adım 1: dokun → mürekkep. Adım 2: harf düşer. Adım 3: eşleşme dolgusu. */
.mini--select .tile:first-child .tile-ink { animation: ink 6s var(--ease-out) infinite; }
.mini--select .tile:first-child { animation: inkText 6s var(--ease-out) infinite; }
.mini--swap .tile:first-child .tile-letter { animation: letterOut 6s var(--ease-out) infinite; }
.mini--swap .tile:first-child .tile-letter--in { animation-name: letterIn; }
.mini--match .tile:not(:first-child) .tile-fill { animation: fillIn 6s var(--ease-out) infinite; }
.mini--match .tile:not(:first-child) { animation: matchBorder 6s var(--ease-out) infinite; }
.mini--match .tile:nth-child(3) .tile-fill, .mini--match .tile:nth-child(3) { animation-delay: 120ms; }
.mini--match .tile:nth-child(4) .tile-fill, .mini--match .tile:nth-child(4) { animation-delay: 240ms; }

@keyframes ink { 0%, 12% { opacity: 0 } 20%, 82% { opacity: 1 } 92%, 100% { opacity: 0 } }
@keyframes inkText { 0%, 12% { color: var(--c-fg) } 20%, 82% { color: var(--c-bg) } 92%, 100% { color: var(--c-fg) } }
@keyframes letterOut { 0%, 25% { transform: none; opacity: 1 } 38%, 82% { transform: translateY(70%); opacity: 0 } 92%, 100% { transform: none; opacity: 1 } }
@keyframes letterIn { 0%, 25% { transform: translateY(-80%); opacity: 0 } 40%, 82% { transform: none; opacity: 1 } 92%, 100% { transform: translateY(-80%); opacity: 0 } }
@keyframes fillIn { 0%, 25% { opacity: 0 } 40%, 82% { opacity: 1 } 92%, 100% { opacity: 0 } }
@keyframes matchBorder { 0%, 25% { border-color: var(--c-fg-38) } 40%, 82% { border-color: var(--c-accent) } 92%, 100% { border-color: var(--c-fg-38) } }

.how-footer { margin-top: auto; }
.how-skip { margin: 6px auto 0; }

/* ---------- Ayarlar ---------- */

.settings { display: flex; flex-direction: column; border-bottom: 1px solid var(--c-fg-12); }
.field { padding: 16px 0; border-top: 1px solid var(--c-fg-12); }
.field > legend, .field > .label { display: block; margin-bottom: 10px; }
.field > legend { float: left; width: 100%; }
.field > legend + * { clear: both; }
.field--row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.field--row .label { margin-bottom: 0; }
.field-note { margin-top: 3px; color: var(--c-fg-70); font-size: 13px; line-height: 1.4; max-width: 30ch; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--c-fg-38); }
.segmented label { position: relative; min-width: 0; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: grid; place-items: center;
  min-height: 44px;
  border-right: 1px solid var(--c-fg-38);
  color: var(--c-fg-70);
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--c-accent); color: var(--c-on-accent); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--c-fg); outline-offset: -4px; }

.switch { position: relative; flex: none; width: 52px; height: 32px; border: 1px solid var(--c-fg-38); }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch-knob {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px;
  background: var(--c-fg-38);
  pointer-events: none;
  transition: transform var(--t-base) var(--ease-out), background-color var(--t-base) var(--ease-out);
}
.switch input:checked + .switch-knob { background: var(--c-accent); transform: translateX(20px); }
.switch:focus-within { outline: 2px solid var(--c-fg); outline-offset: 2px; }

.settings-note { margin-top: 20px; color: var(--c-fg-70); }

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  z-index: 8;
  top: calc(16px + env(safe-area-inset-top) + 38px);
  left: var(--pad-x);
  right: var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--c-fg);
  color: var(--c-bg);
  border-left: 3px solid var(--c-accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.toast-action {
  appearance: none;
  flex: none;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--c-bg);
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-transform: inherit;
}
.toast-action:focus-visible { outline-color: var(--c-bg); }

/* ---------- Yardımcılar: oturum durumuna göre görünürlük ----------
   <html data-auth="guest|user"> mantık tarafından yazılır. */

[data-auth='guest'] .only-user,
[data-auth='user'] .only-guest { display: none !important; }

/* ---------- Ana sayfa ---------- */

/* Başlık, ekran genişliğine (kare içinde de) göre ölçeklenir: cqi = ekran içerik genişliği. */
.screen--home { container-type: inline-size; }
.home-title {
  margin-top: 18px;
  font-size: clamp(40px, 20cqi, 92px);
  font-weight: 800;
  font-variation-settings: 'opsz' 96;
  letter-spacing: -0.05em;
  line-height: 0.86;
  white-space: nowrap;
}

.ledger {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 26px 0 0;
  border-top: 1px solid var(--c-fg-12);
  border-bottom: 1px solid var(--c-fg-12);
}
.ledger-cell { min-width: 0; padding: 12px 10px 12px 0; }
.ledger-cell + .ledger-cell { padding-left: 12px; border-left: 1px solid var(--c-fg-12); }
.ledger dt, .ledger dd { margin: 0; }
.ledger dd {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 700;
  font-variation-settings: 'opsz' 96;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-line { display: flex; justify-content: flex-end; margin-bottom: 22px; }

.modes { display: grid; gap: 12px; }

.mode {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 16px 18px 18px;
  border: 1.5px solid var(--c-fg);
  border-radius: 0;
  background: none;
  color: var(--c-fg);
  text-align: left;
  transition: background-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}
.mode-title {
  font-size: clamp(44px, 14vw, 60px);
  font-weight: 800;
  font-variation-settings: 'opsz' 96;
  letter-spacing: -0.045em;
  line-height: 0.88;
}
.mode-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mode-state .st { display: none; }

/* günlük: birincil (dolu vurgu) */
.mode--daily { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.mode--daily .label { color: var(--c-on-accent); opacity: 0.8; }
.mode--daily:hover { background: var(--c-fg); border-color: var(--c-fg); color: var(--c-bg); }
.mode--daily:hover .label { color: var(--c-bg); }
.mode--daily[data-status='new'] .st-new,
.mode--daily[data-status='progress'] .st-progress,
.mode--daily[data-status='done'] .st-done { display: inline; }
.mode-stars { display: none; gap: 6px; }
.mode--daily[data-status='done'] .mode-stars { display: flex; }
.mode--daily .star { background: rgba(20, 20, 20, 0.28); }
.mode--daily .star[data-on='true'] { background: var(--c-on-accent); }

/* sonsuz: ikincil (çerçeve) */
.mode--endless { gap: 12px; }
.mode-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--c-fg-38);
}
.mode-pick {
  appearance: none;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--c-fg-38);
  border-radius: 0;
  background: none;
  color: var(--c-fg);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.mode-pick:last-child { border-right: 0; }
.mode-pick:hover { background: var(--c-fg); color: var(--c-bg); }

.home-foot {
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--c-fg-12);
}
.home-foot .text-button { padding: 0 2px; }

/* ---------- Giriş ---------- */

/* Google marka düğmesi: beyaz/koyu zemin, 1px çerçeve, resmi çok renkli G. */
.google-button {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  padding: 0 16px;
  border: 1px solid var(--c-google-line);
  border-radius: 0;
  background: var(--c-google-bg);
  color: var(--c-google-fg);
  font-family: Roboto, Arial, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: filter var(--t-fast) var(--ease-out);
}
.google-button:hover { filter: brightness(0.97); }
.google-g { flex: none; }

.notice {
  display: grid;
  justify-items: start;
  gap: 10px;
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--c-fg);
}
.notice-text { color: var(--c-fg-70); font-size: 14px; line-height: 1.5; }

.username { display: grid; gap: 12px; margin-top: 8px; }
.text-input {
  appearance: none;
  width: 100%;
  min-height: 56px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1.5px solid var(--c-fg);
  border-radius: 0;
  background: none;
  color: var(--c-fg);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 96;
}
.text-input::placeholder { color: var(--c-fg-38); }
.text-input:focus-visible { outline-offset: 4px; }

.username-status { display: block; min-height: 24px; color: var(--c-fg-70); }
.username-status [data-msg] { display: none; }
.username-status[data-state='ok'] [data-msg='ok'],
.username-status[data-state='taken'] [data-msg='taken'],
.username-status[data-state='invalid'] [data-msg='invalid'] { display: inline; }
.username-status[data-state='ok'] { padding-left: 10px; border-left: 3px solid var(--c-fg); color: var(--c-fg); }
.username-status[data-state='taken'],
.username-status[data-state='invalid'] { padding-left: 10px; border-left: 3px solid var(--c-accent); color: var(--c-fg); }

/* devre dışı düğme: yalnızca çizgiyle soluk */
.button[disabled],
.button[disabled]:hover { background: none; color: var(--c-fg-38); border-color: var(--c-fg-38); cursor: default; }

/* ikincil birincil-dışı düğme (PAYLAŞ) */
.button--quiet { border-color: var(--c-fg-38); }
.button--quiet:hover { background: var(--c-fg); border-color: var(--c-fg); color: var(--c-bg); }

/* ---------- Sıralama ---------- */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
  border: 1px solid var(--c-fg-38);
}
.tab {
  appearance: none;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--c-fg-38);
  border-radius: 0;
  background: none;
  color: var(--c-fg-70);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tab:last-child { border-right: 0; }
.tab[aria-selected='true'] { background: var(--c-accent); color: var(--c-on-accent); font-weight: 600; }
.lb-date { margin-bottom: 12px; }

.ranks { margin: 0; padding: 0; list-style: none; }
.rank {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 44px 64px 12px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 8px;
  border-bottom: 1px solid var(--c-fg-12);
  font-variant-numeric: tabular-nums;
}
.rank-head { min-height: 0; padding-top: 0; padding-bottom: 8px; border-bottom-color: var(--c-fg-38); }
.rank-head span:nth-child(3), .rank-head span:nth-child(4) { text-align: right; }
.rank-no { color: var(--c-fg-55); font-family: var(--font-mono); font-size: 11px; }
.rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 600; }
.rank-steps, .rank-time {
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.rank-joker { justify-self: center; width: 7px; height: 7px; background: var(--c-accent); }
.rank[data-me='true'] { background: var(--c-accent-14); box-shadow: inset 3px 0 0 var(--c-accent); }
.rank-gap { padding: 8px 8px 0; text-align: center; color: var(--c-fg-55); }
.ranks--self { border-top: 1px solid var(--c-fg-38); margin-top: 4px; }
.empty { padding: 28px 0; color: var(--c-fg-70); font-size: 15px; }

/* ---------- Açılış demosu ---------- */

/* Karartma: tutorial ekranında yalnızca [data-spot] öğeler üstte kalır. */
.tut-scrim {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(20, 20, 20, 0.5);
  pointer-events: none;
}
.tut-head, .tut-dots, .tut-caption { position: relative; z-index: 7; }
.tut-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tut-dots { display: flex; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.tut-dots li { width: 16px; height: 4px; background: var(--c-fg-12); }
.tut-dots li[data-on='true'] { background: var(--c-fg); }
.tut-caption { min-height: 118px; margin-bottom: 16px; }
.tut-title {
  margin-bottom: 10px;
  font-size: 34px;
  font-weight: 720;
  font-variation-settings: 'opsz' 96;
  letter-spacing: -0.025em;
  line-height: 1;
}
.tut-title .tut-step { display: none; }
.tut-text { color: var(--c-fg-70); font-size: 15px; line-height: 1.45; }
.tut-text .tut-step { display: none; }
.screen--tutorial[data-step='1'] [data-step='1'],
.screen--tutorial[data-step='2'] [data-step='2'],
.screen--tutorial[data-step='3'] [data-step='3'],
.screen--tutorial[data-step='4'] [data-step='4'] { display: block; }
/* karartılmış katmanın üstünde kalacak öğelerin ata bağlamı kırılmasın */
.screen--tutorial .row,
.screen--tutorial .group { z-index: auto; }
.screen--tutorial [data-spot='true'] { position: relative; z-index: 7; }
.screen--tutorial .tile[data-spot='true'] { outline: 2px solid var(--c-accent); outline-offset: 3px; }
.screen--tutorial .key[data-spot='true'] { border-color: var(--c-accent); background: var(--c-accent-14); }
.tut-keyboard { position: relative; }

/* ---------- Joker şeridi ---------- */

.joker-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 10px;
  border-top: 1px solid var(--c-fg-12);
  border-bottom: 1px solid var(--c-fg-12);
}
.joker-total { flex: none; margin: 0; white-space: nowrap; }
.joker-total b { font-variant-numeric: tabular-nums; }
.joker-chips {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 6px;
  padding: 6px 0;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.joker-chips::-webkit-scrollbar { display: none; }
.joker {
  appearance: none;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--c-fg-38);
  border-radius: 0;
  background: none;
  color: var(--c-fg);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.joker-mark { width: 6px; height: 6px; background: var(--c-fg); }
.joker:hover:not(:disabled) { border-color: var(--c-fg); }
/* joker yok: soluk, işaret içi boş */
.joker[data-state='empty'],
.joker:disabled { color: var(--c-fg-38); border-color: var(--c-fg-12); cursor: default; }
.joker[data-state='empty'] .joker-mark,
.joker:disabled .joker-mark { background: none; box-shadow: inset 0 0 0 1px var(--c-fg-38); }
/* kullanıldı: üstü çizili, dolgu soluk */
.joker[data-state='used'] {
  color: var(--c-fg-38);
  border-color: var(--c-fg-12);
  background: var(--c-fg-12);
  text-decoration: line-through;
  cursor: default;
}
.joker[data-state='used'] .joker-mark { display: none; }
.joker-ends { flex: none; display: flex; align-items: center; }
.joker-ends .text-button { min-height: 44px; padding: 0 6px; }
/* bu modda yok: gizli */
.joker-bar[data-mode='daily'] .endless-only { display: none !important; }

.joker-confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--c-fg-12);
}
.joker-confirm .label { color: var(--c-fg); }
.joker-confirm-actions { display: flex; gap: 4px; }

/* ---------- Harf ışığı (ipucu) ---------- */

/* Değiştirilmesi gereken taş: kesikli çerçeve + alt kalın çizgi. Seçili (ink) ve eşleşme (turuncu) durumlarından ayrı. */
.row[data-row='active'] .tile[data-hint='true']:not([data-state='selected']) { border-style: dashed; border-color: var(--c-fg); }
.row[data-row='active'] .tile[data-hint='true']::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--c-fg);
}
.row[data-row='active'] .tile[data-hint='true'][data-state='selected']::after { display: none; }

/* ---------- Kelime anlamı kartı ---------- */

.sheet-backdrop { position: absolute; inset: 0; z-index: 8; background: transparent; }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  max-height: 62%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px var(--pad-x) calc(14px + env(safe-area-inset-bottom));
  background: var(--c-bg);
  border-top: 1.5px solid var(--c-fg);
}
.sheet-grip { align-self: center; width: 36px; height: 3px; background: var(--c-fg-38); }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-width: 0; }
.sheet-word {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 40px;
  font-weight: 760;
  font-variation-settings: 'opsz' 96;
  letter-spacing: -0.03em;
  line-height: 0.95;
  text-transform: uppercase;
}
.sheet-body { min-height: 56px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.sheet-body::-webkit-scrollbar { display: none; }
.sheet [data-when] { display: none; }
.sheet[data-state='loading'] [data-when='loading'],
.sheet[data-state='found'] [data-when='found'],
.sheet[data-state='notfound'] [data-when='notfound'],
.sheet[data-state='offline'] [data-when='offline'] { display: block; }
.loader {
  position: relative;
  display: block;
  height: 2px;
  margin-top: 12px;
  overflow: hidden;
  background: var(--c-fg-12);
}
.loader::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  background: var(--c-fg);
  animation: loader 1.1s var(--ease-in) infinite;
}
@keyframes loader { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.gloss-list { margin: 0; padding: 0; list-style: none; }
.gloss-item { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; font-size: 17px; line-height: 1.4; }
.gloss-item + .gloss-item { margin-top: 10px; }
.gloss-no { padding-top: 4px; color: var(--c-fg-55); font-family: var(--font-mono); font-size: 11px; }
.sheet-msg { color: var(--c-fg-70); font-size: 15px; line-height: 1.45; }
.sheet-source { padding-top: 10px; border-top: 1px solid var(--c-fg-12); color: var(--c-fg-55); }

/* ---------- Dar ekran ---------- */

@media (max-width: 374px) {
  :root { --pad-x: 12px; --gap: 12px; }
  .key { font-size: 17px; height: 46px; }
  .route-grid { gap: 12px; }
  .route-ladder { --mini: 24px; }
  .route-ladder[data-n='5'] { --mini: 20px; }
  .stat-value { font-size: 38px; }
}

/* kısa ekran: klavye ve boşluklar sıkışır */
@media (max-height: 700px) {
  .key { height: 42px; }
  .key::before { inset: -3px -6px; }
  .key-row { margin-bottom: 2px; }
  :root { --gap: 10px; }
}

/* ---------- Hareket azaltma ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  /* animasyonlu anlatım sabit son kareyi gösterir */
  .mini--select .tile:first-child .tile-ink { opacity: 1; }
  .mini--select .tile:first-child { color: var(--c-bg); }
  .mini--swap .tile:first-child .tile-letter { opacity: 0; }
  .mini--swap .tile:first-child .tile-letter--in { opacity: 1; }
  .mini--match .tile:not(:first-child) .tile-fill { opacity: 1; }
  .mini--match .tile:not(:first-child) { border-color: var(--c-accent); }
}
