/* === Wordle Game Styles === */

/* Tile state colors */
:root {
  --wordle-correct: #538d4e;
  --wordle-present: #b59f3b;
  --wordle-absent: #787c7e;
  --wordle-tile-bg: #fff;
  --wordle-tile-border: var(--color-border);
  --wordle-key-bg: #d3d6da;
  --wordle-key-text: #1a1a1b;
}


/* ── Title ── */
.wordle-title-section {
  text-align: center;
  padding: 1rem 0 0.75rem;
}

.wordle-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
}

.wordle-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
  letter-spacing: 0.04em;
}

/* ── Grid ── */
.wordle-grid-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 0.75rem;
}

.wordle-grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
}

.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, clamp(48px, 11vw, 62px));
  gap: 5px;
}

.wordle-tile {
  width: clamp(48px, 11vw, 62px);
  height: clamp(48px, 11vw, 62px);
  border: 2px solid var(--wordle-tile-border);
  border-radius: 4px;
  background: var(--wordle-tile-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--color-text);
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.1s;
  position: relative;
  /* 3D flip */
  transform-style: preserve-3d;
  perspective: 250px;
}

/* Tile has a letter typed but not submitted */
.wordle-tile[data-state="tbd"] {
  border-color: var(--color-text-muted);
  animation: tile-pop 0.1s ease-out;
}

/* Submitted tiles — color assigned after flip */
.wordle-tile[data-state="correct"] {
  border-color: var(--wordle-correct);
  background: var(--wordle-correct);
  color: #fff;
}

.wordle-tile[data-state="present"] {
  border-color: var(--wordle-present);
  background: var(--wordle-present);
  color: #fff;
}

.wordle-tile[data-state="absent"] {
  border-color: var(--wordle-absent);
  background: var(--wordle-absent);
  color: #fff;
}

/* ── Flip animation ── */
@keyframes flip-in {
  0%   { transform: rotateX(0deg); }
  100% { transform: rotateX(-90deg); }
}

@keyframes flip-out {
  0%   { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}

.wordle-tile.flip-in {
  animation: flip-in 150ms ease-in forwards;
}

.wordle-tile.flip-out {
  animation: flip-out 150ms ease-out forwards;
}

/* ── Pop animation when letter typed ── */
@keyframes tile-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ── Shake animation (wrong word) ── */
@keyframes row-shake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-6px); }
  30%       { transform: translateX(6px); }
  45%       { transform: translateX(-4px); }
  60%       { transform: translateX(4px); }
  75%       { transform: translateX(-2px); }
  90%       { transform: translateX(2px); }
}

.wordle-row.shake {
  animation: row-shake 0.5s ease-in-out;
}

/* ── Bounce animation (win) ── */
@keyframes tile-bounce {
  0%, 100% { transform: translateY(0); }
  30%       { transform: translateY(-20px); }
  60%       { transform: translateY(-10px); }
  80%       { transform: translateY(-4px); }
}

.wordle-tile.bounce {
  animation: tile-bounce 0.6s ease forwards;
}

/* ── On-screen keyboard ── */
.wordle-keyboard {
  padding: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
}

.wordle-key-row {
  display: flex;
  gap: 5px;
}

.wordle-key {
  height: 58px;
  min-width: 40px;
  padding: 0 6px;
  border: none;
  border-radius: 4px;
  background: var(--wordle-key-bg);
  color: var(--wordle-key-text);
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.wordle-key:active {
  filter: brightness(0.85);
}

.wordle-key--wide {
  min-width: 58px;
  font-size: 0.75rem;
}

/* Key state colors (best result wins: correct > present > absent) */
.wordle-key[data-state="correct"] {
  background: var(--wordle-correct);
  color: #fff;
}

.wordle-key[data-state="present"] {
  background: var(--wordle-present);
  color: #fff;
}

.wordle-key[data-state="absent"] {
  background: var(--wordle-absent);
  color: #fff;
}

/* ── Countdown & mode bar ── */
.wordle-countdown {
  text-align: center;
  padding: 0.5rem 0 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.wordle-countdown-time {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* ── Victory overlay ── */
.wordle-victory {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.wordle-victory.show { display: flex; }

.wordle-victory-card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  width: 100%;
  padding: 1.75rem 1.5rem;
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

.wordle-victory-stars {
  font-size: 1.75rem;
  margin: 0.25rem 0;
  min-height: 2.2rem;
}

.wordle-victory-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.wordle-victory.won .wordle-victory-title { color: var(--color-success); }

.wordle-victory-answer {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.wordle-victory-answer strong {
  color: var(--color-text);
}

/* Emoji share grid preview */
.wordle-share-grid {
  font-size: 1.1rem;
  line-height: 1.4;
  margin: 0.5rem auto 0.75rem;
  display: inline-block;
  text-align: left;
  letter-spacing: 2px;
}

.wordle-victory-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wordle-victory-actions .btn { width: 100%; }

/* ── Stats modal ── */

/* Guess distribution */
.guess-dist { margin-top: 0.75rem; }

.guess-dist h3 {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}

.guess-row .guess-label { width: 1rem; text-align: right; font-weight: 700; }

.guess-bar-track {
  flex: 1;
  height: 20px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.guess-bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  transition: width 0.3s ease;
}

.guess-bar.current {
  background: var(--wordle-correct);
}

/* ── Help modal ── */
.wordle-example-row {
  display: flex;
  gap: 4px;
  margin: 0.5rem 0;
}

.wordle-example-tile {
  width: 40px;
  height: 40px;
  border: 2px solid var(--color-border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
}

.wordle-example-tile.correct {
  background: var(--wordle-correct);
  border-color: var(--wordle-correct);
  color: #fff;
}

.wordle-example-tile.present {
  background: var(--wordle-present);
  border-color: var(--wordle-present);
  color: #fff;
}

.wordle-example-tile.absent {
  background: var(--wordle-absent);
  border-color: var(--wordle-absent);
  color: #fff;
}

/* ── Settings modal ── */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}


/* ── Responsive ── */
@media (max-width: 380px) {
  .wordle-key {
    height: 50px;
    min-width: 32px;
    font-size: 0.7rem;
  }

  .wordle-key--wide {
    min-width: 46px;
    font-size: 0.65rem;
  }
}

@media (min-width: 480px) {
  .wordle-key {
    height: 62px;
    min-width: 44px;
  }

  .wordle-key--wide {
    min-width: 66px;
  }
}
