:root {
  --box: 44px;
  --bg: #F4EFE4;
  --card: #FFFDF8;
  --ink: #2B2A33;
  --muted: #8A8476;
  --line: #DCD4C4;
  --tile: #FFFFFF;
  --tile-edge: #D6CEBD;
  --accent: #2F57A6;
  --accent-soft: #DCE5F6;
  --good: #3E8A5B;
  --warn: #B4683F;
  --radius: 12px;
  --tile-size: 64px;
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

.app {
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Üst çubuk */
.topbar {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.topbar .icon-btn { justify-self: end; }
.levels { display: flex; gap: 6px; }
.level-dot {
  min-width: 36px; height: 36px;
  padding: 0 10px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: var(--card);
  font-weight: 800; font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.level-dot[disabled] { opacity: .45; cursor: default; }
.level-dot.done { border-color: var(--good); color: var(--good); }
.level-dot.current { border-color: var(--accent); background: var(--accent); color: #fff; }
.level-dot svg { width: 12px; height: 12px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 20px;
  border: 2px solid var(--line);
  background: var(--card);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--muted);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.94); }

/* Tema başlığı */
.hero { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: -4px; }
.art { width: 110px; height: 44px; }
.art svg { width: 100%; height: 100%; display: block; }
.level-label {
  margin: 0;
  font-size: 12px; font-weight: 800; letter-spacing: .12em;
  color: var(--muted);
}
.pill {
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: .04em;
  padding: 6px 18px;
  border-radius: 999px;
  box-shadow: 0 2px 0 rgba(0,0,0,.12);
}

/* Cevap yuvaları */
.slots {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.word-slot { display: flex; gap: 6px; }
.word-slot .box {
  width: var(--box);
  height: calc(var(--box) * 1.1);
  border: 2px solid var(--line);
  border-radius: calc(var(--box) * .22);
  background: var(--card);
  display: grid; place-items: center;
  font-weight: 900; font-size: calc(var(--box) * .56);
  color: var(--ink);
}
.word-slot.found .box {
  border-color: var(--accent);
  background: var(--accent-soft);
  animation: pop .38s ease both;
}
.word-slot.found .box:nth-child(2) { animation-delay: .04s; }
.word-slot.found .box:nth-child(3) { animation-delay: .08s; }
.word-slot.found .box:nth-child(4) { animation-delay: .12s; }
.word-slot.found .box:nth-child(5) { animation-delay: .16s; }
.word-slot.found .box:nth-child(6) { animation-delay: .2s; }
.word-slot.found .box:nth-child(n+7) { animation-delay: .24s; }
.word-slot.found.restored .box { animation: none; }

@keyframes pop {
  0% { transform: scale(.6); opacity: .2; }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

/* Durum satırı */
.status {
  min-height: 34px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
}
.status .preview {
  font-size: 22px; letter-spacing: .14em; color: var(--accent);
  background: var(--card); border: 2px solid var(--accent-soft);
  border-radius: 10px; padding: 2px 12px;
}
.status.good { color: var(--good); }
.status.soft { color: var(--warn); }

/* Oyun alanı: yuvalar, durum satırı ve tahta kalan yüksekliği paylaşır */
.play {
  flex: 1;
  gap: 14px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
}

/* Tahta */
.board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
.board {
  position: relative;
  display: grid;
  gap: 10px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 4px;
}
.board.shake { animation: shake .36s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.tile {
  position: relative;
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: var(--radius);
  background: var(--tile);
  border: 2px solid var(--tile-edge);
  box-shadow: 0 3px 0 var(--tile-edge);
  display: grid; place-items: center;
  font-weight: 900;
  font-size: calc(var(--tile-size) * .44);
  line-height: 1;
  transition: transform .12s ease, background-color .12s ease, color .12s ease, opacity .3s ease;
  z-index: 1;
  cursor: pointer;
}
.tile .count {
  position: absolute;
  top: 4px; right: 6px;
  font-size: calc(var(--tile-size) * .2);
  font-weight: 800;
  color: var(--muted);
}
.tile.sel {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  color: #fff;
  transform: translateY(-1px) scale(1.04);
}
.tile.sel .count { color: rgba(255,255,255,.8); }
.tile.tick .count { animation: tick .4s ease; }
@keyframes tick { 0% { transform: scale(1.8); color: var(--good); } 100% { transform: scale(1); } }
.tile.gone {
  animation: vanish .42s ease forwards;
  pointer-events: none;
}
.tile.gone.instant { animation-duration: 0s; }
@keyframes vanish {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(.2); opacity: 0; visibility: hidden; }
}
.hole {
  width: var(--tile-size); height: var(--tile-size);
  border-radius: var(--radius);
  border: 2px dashed rgba(0,0,0,.06);
}

.trail {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.trail polyline {
  fill: none;
  stroke: var(--accent);
  stroke-opacity: .55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Bitiş kartı */
.overlay {
  position: fixed; inset: 0;
  background: rgba(43, 42, 51, .35);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 10;
  animation: fade .25s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.card {
  width: min(360px, 100%);
  background: var(--card);
  border-radius: 22px;
  padding: 22px 20px 20px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  animation: rise .35s ease;
}
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.card h2 { margin: 8px 0 4px; font-size: 24px; font-weight: 900; }
.card p { margin: 0 0 12px; color: var(--muted); font-weight: 700; }
.art-big { width: 220px; height: 86px; margin: 0 auto; }
.done-words {
  list-style: none; padding: 0; margin: 0 0 18px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
}
.done-words li {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 14px;
  letter-spacing: .05em;
}
.card-actions { display: flex; gap: 10px; justify-content: center; }
.btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  padding: 12px 20px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.btn.ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent-soft); }
.btn:active { transform: translateY(1px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Kısa / dar ekranlar */
@media (max-height: 700px), (max-width: 360px) {
  .app { gap: 6px; }
  .art { width: 84px; height: 34px; }
  .pill { font-size: 14px; padding: 4px 14px; }
  .level-dot { min-width: 32px; height: 32px; font-size: 13px; }
  .icon-btn { width: 36px; height: 36px; }
  .status { min-height: 28px; font-size: 14px; }
  .status .preview { font-size: 18px; }
  .board { gap: 7px; }
}
