/* Geyikle: Türkçe Wordle. Özgün stil. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1a1a1b;
  --muted: #787c7e;
  --border: #d3d6da;
  --border-strong: #878a8c;
  --tile-empty-border: #d3d6da;
  --tile-filled-border: #878a8c;
  --key-bg: #d3d6da;
  --key-text: #1a1a1b;
  --header-border: #d3d6da;
  --modal-bg: #ffffff;
  --overlay: rgba(0, 0, 0, 0.45);
  --correct: #6aaa64;
  --present: #c9b458;
  --absent: #787c7e;
  --tile-text-revealed: #ffffff;
  --toast-bg: #1a1a1b;
  --toast-text: #ffffff;
  --good: #538d4e;
  --max-width: 500px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121213;
  --text: #ffffff;
  --muted: #818384;
  --border: #3a3a3c;
  --border-strong: #565758;
  --tile-empty-border: #3a3a3c;
  --tile-filled-border: #565758;
  --key-bg: #818384;
  --key-text: #ffffff;
  --header-border: #3a3a3c;
  --modal-bg: #121213;
  --overlay: rgba(0, 0, 0, 0.65);
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --toast-bg: #ffffff;
  --toast-text: #1a1a1b;
}

[data-contrast="high"] {
  --correct: #f5793a;
  --present: #85c0f9;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 12px;
  border-bottom: 1px solid var(--header-border);
}

.header__title {
  margin: 0;
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  flex: 1;
}

.header__side {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
}
.icon-btn:hover {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* ---------- Game ---------- */
.game {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px 0;
}

.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  padding: 10px;
  box-sizing: border-box;
  height: min(350px, 100%);
  width: min(330px, 100%);
}

.board-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--tile-empty-border);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
  color: var(--text);
  background: transparent;
  transition: transform 0.08s ease;
}

.tile[data-filled="true"] {
  border-color: var(--tile-filled-border);
  animation: pop 0.1s ease;
}

.tile[data-state="correct"],
.tile.tile--correct {
  background: var(--correct);
  border-color: var(--correct);
  color: var(--tile-text-revealed);
}
.tile[data-state="present"],
.tile.tile--present {
  background: var(--present);
  border-color: var(--present);
  color: var(--tile-text-revealed);
}
.tile[data-state="absent"],
.tile.tile--absent {
  background: var(--absent);
  border-color: var(--absent);
  color: var(--tile-text-revealed);
}

/* reveal flip */
.tile.flip {
  animation: flip 0.5s ease forwards;
}
@keyframes flip {
  0% {
    transform: rotateX(0);
  }
  50% {
    transform: rotateX(-90deg);
  }
  100% {
    transform: rotateX(0);
  }
}
@keyframes pop {
  0% {
    transform: scale(0.92);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

/* win bounce */
.tile.bounce {
  animation: bounce 0.6s ease;
}
@keyframes bounce {
  0%,
  20% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-26px);
  }
  50% {
    transform: translateY(4px);
  }
  60% {
    transform: translateY(-12px);
  }
  80% {
    transform: translateY(2px);
  }
  100% {
    transform: translateY(0);
  }
}

/* invalid shake */
.board-row.shake {
  animation: shake 0.5s ease;
}
@keyframes shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(2px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
}

/* ---------- Keyboard ---------- */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 6px 10px;
  margin-top: auto;
  height: 200px;
  user-select: none;
}
.kb-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex: 1;
}
.key {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: var(--key-bg);
  color: var(--key-text);
  font-weight: 700;
  font-size: 1.05rem;
  text-transform: uppercase;
  padding: 0 2px;
  height: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}
.key--wide {
  flex: 1.5;
  font-size: 0.72rem;
}
.key svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.key[data-state="correct"] {
  background: var(--correct);
  color: #fff;
}
.key[data-state="present"] {
  background: var(--present);
  color: #fff;
}
.key[data-state="absent"] {
  background: var(--absent);
  color: #fff;
}
[data-theme="dark"] .key[data-state="absent"] {
  color: #e6e6e6;
}
.key:active {
  filter: brightness(0.92);
}

/* ---------- Toaster ---------- */
.toaster {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}
.toast {
  background: var(--toast-bg);
  color: var(--toast-text);
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  animation: toastIn 0.12s ease;
}
.toast.fade {
  opacity: 0;
  transition: opacity 0.3s ease;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ---------- Modals ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-root[hidden] {
  display: none;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay);
}
.modal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--modal-bg);
  color: var(--text);
  border-radius: 10px;
  padding: 28px 28px 32px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
}
.modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}
.modal__close:hover {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.modal__title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}
.modal p {
  line-height: 1.5;
  margin: 0 0 12px;
}
.muted {
  color: var(--muted);
}
.rules {
  margin: 0 0 16px;
  padding-left: 20px;
  line-height: 1.6;
}
.rules li {
  margin-bottom: 4px;
}

.examples {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  margin-bottom: 14px;
}
.example {
  margin-bottom: 10px;
}
.example p {
  margin: 6px 0 0;
  font-size: 0.95rem;
}
.mini-row {
  display: flex;
  gap: 4px;
}
.mini-row .tile {
  width: 36px;
  height: 36px;
  aspect-ratio: auto;
  font-size: 1.3rem;
  border-width: 2px;
}

/* Stats */
.stats-grid {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 22px;
}
.stat {
  flex: 1;
  text-align: center;
}
.stat__num {
  font-size: 2.1rem;
  font-weight: 400;
  line-height: 1;
}
.stat__label {
  font-size: 0.72rem;
  margin-top: 4px;
  color: var(--text);
}
.dist-title {
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 12px;
}
.dist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.dist-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}
.dist-row__label {
  width: 12px;
  text-align: center;
  font-weight: 600;
}
.dist-row__bar {
  background: var(--absent);
  color: #fff;
  font-weight: 700;
  padding: 2px 8px;
  min-width: 24px;
  text-align: right;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.dist-row__bar--current {
  background: var(--correct);
}
.stats-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 18px;
}
.countdown {
  display: flex;
  flex-direction: column;
}
.countdown__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.countdown__time {
  font-size: 1.7rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--correct);
  color: #fff;
  border: 0;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 28px;
  font-size: 1rem;
}
.share-btn:hover {
  filter: brightness(1.05);
}
.share-btn::after {
  content: "▶";
  font-size: 0.85rem;
}

/* Settings */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.setting__name {
  font-size: 1rem;
}
.setting__desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}
.switch {
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: var(--border-strong);
  padding: 0;
  position: relative;
  transition: background 0.15s ease;
}
.switch[aria-checked="true"] {
  background: var(--correct);
}
.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.switch[aria-checked="true"] .switch__knob {
  transform: translateX(20px);
}

/* About */
.about-figure {
  margin: 16px 0;
}
.about-figure__img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}
.about-figure__placeholder {
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 160px;
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
  font-size: 0.9rem;
}
.about-figure.is-empty .about-figure__img {
  display: none;
}
.about-figure.is-empty .about-figure__placeholder {
  display: flex;
}
.about-figure figcaption {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}
.about-credit {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.modal a {
  color: var(--correct);
  font-weight: 600;
  text-decoration: none;
}
.modal a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .modal {
    padding: 24px 18px 28px;
  }
  .header__title {
    letter-spacing: 0.01em;
  }
}
