:root {
  --zemin: #151a22;
  --yuzey: #1e2530;
  --yazi: #eef1f5;
  --soluk: #9aa3b2;
  --cizgi: #333c4a;
  --cizgi-dolu: #5d6879;
  --tus: #3a4352;
  --tus-yazi: #eef1f5;
  --dogru: #3a9d5d;
  --var: #d9a521;
  --yok: #4a5260;
  --vurgu: #3a9d5d;
  --golge: 0 18px 50px rgba(0,0,0,.45);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --zemin: #f6f4ef;
    --yuzey: #ffffff;
    --yazi: #1d222b;
    --soluk: #6b7280;
    --cizgi: #d6d3cb;
    --cizgi-dolu: #8f96a3;
    --tus: #e2e0da;
    --tus-yazi: #1d222b;
    --yok: #7d8594;
    --golge: 0 18px 50px rgba(0,0,0,.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--zemin);
  color: var(--yazi);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }

/* Üst çubuk */
.ust {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--cizgi);
  flex: none;
}
.ust h1 {
  margin: 0; font-size: clamp(1rem, 5vw, 1.55rem); font-weight: 800; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; text-align: center;
}
.ust h1 .kalp { color: #e0475b; }
.ikon {
  width: 40px; height: 40px; border: 0; background: none; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
}
.ikon:hover { background: var(--yuzey); }
.ikon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ikon svg .dolu { fill: currentColor; stroke: none; }

/* Tahta */
#alan {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 16px;
}
#tahta { display: grid; gap: var(--ara, 6px); }
.satir { display: flex; justify-content: center; gap: var(--ara, 6px); }
.bosluk { flex: none; width: calc(var(--kutu, 58px) * .4); }
.kutu {
  flex: none;
  width: var(--kutu, 58px); height: var(--kutu, 58px);
  border: 2px solid var(--cizgi);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: calc(var(--kutu, 58px) * .52); font-weight: 800;
  user-select: none;
}
.kutu.dolu { border-color: var(--cizgi-dolu); animation: vur .1s ease-out; }
.kutu.dogru, .kutu.var, .kutu.yok { border-color: transparent; color: #fff; }
.kutu.dogru { background: var(--dogru); }
.kutu.var   { background: var(--var); }
.kutu.yok   { background: var(--yok); }
.kutu.cevir { animation: cevir .5s ease-in-out; }
.satir.salla { animation: salla .5s; }
.kutu.zipla { animation: zipla .5s ease; }

@keyframes vur { 50% { transform: scale(1.1); } }
@keyframes cevir { 0% { transform: rotateX(0); } 50% { transform: rotateX(-90deg); } 100% { transform: rotateX(0); } }
@keyframes salla { 10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); } 30%,50%,70% { transform: translateX(-6px); } 40%,60% { transform: translateX(6px); } }
@keyframes zipla { 0%,20% { transform: translateY(0); } 40% { transform: translateY(-24px); } 50% { transform: translateY(4px); } 60% { transform: translateY(-12px); } 80% { transform: translateY(2px); } 100% { transform: translateY(0); } }

/* Süre */
.sure-cubugu { flex: none; display: flex; justify-content: center; padding-top: 10px; }
.sure {
  min-width: 92px; padding: 6px 14px; border-radius: 999px;
  background: var(--yuzey); border: 1px solid var(--cizgi);
  font-size: 1.25rem; font-weight: 800; text-align: center;
  font-variant-numeric: tabular-nums; color: var(--soluk);
}
.sure.calisiyor { color: var(--yazi); }
.sure.az { color: #fff; background: #c8443a; border-color: #c8443a; animation: nabiz 1s infinite; }
@keyframes nabiz { 50% { transform: scale(1.06); } }

/* Klavye */
#klavye {
  flex: none;
  width: 100%; max-width: 520px; margin: 0 auto;
  padding: 0 6px calc(10px + env(safe-area-inset-bottom));
  user-select: none;
}
.k-satir { display: flex; gap: 5px; margin-bottom: 7px; justify-content: center; }
.tus {
  flex: 1 1 0; min-width: 0; height: 56px;
  border: 0; border-radius: 7px;
  background: var(--tus); color: var(--tus-yazi);
  font-size: 1.15rem; font-weight: 700;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background-color .15s;
}
.tus:active { filter: brightness(1.2); }
.tus.genis { flex: 1.6 1 0; font-size: .78rem; letter-spacing: .03em; }
.tus.genis svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tus.dogru { background: var(--dogru); color: #fff; }
.tus.var   { background: var(--var); color: #fff; }
.tus.yok   { background: var(--yok); color: #fff; opacity: .55; }

/* Bildirimler */
#bildirimler {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 30; pointer-events: none;
}
.bildirim {
  background: var(--yazi); color: var(--zemin);
  padding: 11px 16px; border-radius: 8px; font-weight: 700;
  box-shadow: var(--golge);
  transition: opacity .3s;
}
.bildirim.git { opacity: 0; }

/* Pencereler */
.perde {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: belir .2s ease-out;
}
.perde[hidden] { display: none; }
.pencere {
  position: relative;
  width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto;
  background: var(--yuzey);
  border-radius: 14px;
  padding: 24px 22px 22px;
  box-shadow: var(--golge);
}
.pencere h2 { margin: 0 0 12px; font-size: 1.3rem; }
.pencere h3 { margin: 18px 0 10px; font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; color: var(--soluk); }
.pencere p, .pencere li { line-height: 1.5; }
.pencere ul { padding-left: 20px; }
.kapat {
  position: absolute; top: 10px; right: 12px;
  width: 36px; height: 36px; border: 0; background: none;
  font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--soluk); border-radius: 8px;
}
.kapat:hover { color: var(--yazi); }
.ornek { display: flex; gap: 5px; --kutu: 40px; margin-top: 4px; }
.ornek .kutu { border-color: var(--cizgi-dolu); }
.ornek .kutu.dogru, .ornek .kutu.var, .ornek .kutu.yok { border-color: transparent; }
.not { color: var(--soluk); font-size: .92rem; border-top: 1px solid var(--cizgi); padding-top: 12px; margin-top: 18px; }

.sayilar { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 4px; }
.sayilar strong { display: block; font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sayilar span { font-size: .75rem; color: var(--soluk); }

.d-satir { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.d-satir > span { width: 12px; text-align: right; }
.d-cubuk {
  min-width: 26px; padding: 2px 8px; border-radius: 4px;
  background: var(--yok); color: #fff; text-align: right;
}
.d-cubuk.son { background: var(--dogru); }

.sonuc { margin: 18px 0 0; font-weight: 700; text-align: center; }
.alt { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--cizgi); }
.yeni {
  flex: 1; height: 52px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--cizgi-dolu); background: none; font-weight: 800; font-size: 1.05rem;
}
.yeni:hover { background: var(--zemin); }
.paylas[hidden] { display: none; }
.paylas {
  flex: 1; height: 52px; border: 0; border-radius: 10px;
  background: var(--vurgu); color: #fff; font-weight: 800; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
.paylas svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

@keyframes belir { from { opacity: 0; } }

@media (max-height: 640px) {
  .tus { height: 48px; }
  .ust { padding: 4px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .kutu.cevir, .kutu.zipla, .satir.salla, .kutu.dolu { animation-duration: .01s; }
}
