/* ── Wordle game styles ─────────────────────────────────────────────────── */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 12px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Daily button active/done state ───────────────────────────────────────── */
#daily-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
#daily-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

/* ── Daily label in title ─────────────────────────────────────────────────── */
#daily-label {
  font-size: 0.55em;
  color: var(--accent);
  margin-left: 0.5em;
  font-weight: 600;
  vertical-align: middle;
}

/* ── Status message ───────────────────────────────────────────────────────── */
.status-msg {
  min-height: 26px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-strong);
  letter-spacing: 0.02em;
  transition: opacity 0.3s ease;
}

/* ── Board ────────────────────────────────────────────────────────────────── */
.board-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}

.wordle-board {
  display: grid;
  grid-template-columns: repeat(5, clamp(44px, 12.5vw, 52px));
  grid-template-rows:    repeat(6, clamp(44px, 12.5vw, 52px));
  gap: 5px;
}

/* ── Tile ─────────────────────────────────────────────────────────────────── */
.tile {
  width: clamp(44px, 12.5vw, 52px);
  height: clamp(44px, 12.5vw, 52px);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-strong);
  background: var(--surface);
  user-select: none;
  perspective: 250px;
  transition: border-color 0.1s ease;

  /* 3-D flip container */
  transform-style: preserve-3d;
  position: relative;
}

/* Tile has a letter typed (not yet submitted) */
.tile.has-letter {
  border-color: var(--text-muted);
  animation: tile-pop 0.1s ease;
}

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

/* Shake animation for invalid word */
@keyframes tile-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.tile.shake {
  animation: tile-shake 0.4s ease;
}

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

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

.tile.flip-out {
  animation: tile-flip-out 0.15s ease-in forwards;
}

.tile.flip-in {
  animation: tile-flip-in 0.15s ease-out forwards;
}

/* ── Tile colour states ─────────────────────────────────────────────────── */
.tile.tile-correct {
  background: #538d4e;
  border-color: #538d4e;
  color: #ffffff;
}

.tile.tile-present {
  background: #b59f3b;
  border-color: #b59f3b;
  color: #ffffff;
}

.tile.tile-absent {
  background: var(--cell-bg);
  border-color: var(--cell-bg);
  color: var(--text-muted);
}

body.dark .tile.tile-absent {
  background: #3a3a3c;
  border-color: #3a3a3c;
  color: #818384;
}

/* ── On-screen keyboard ───────────────────────────────────────────────────── */
.wordle-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: 100%;
  max-width: 480px;
  padding: 0 4px;
  box-sizing: border-box;
}

.kb-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.kb-key {
  height: 56px;
  min-width: 32px;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, transform 0.08s ease;
  flex: 1;
  max-width: 42px;
  touch-action: manipulation;
}

.kb-key:active {
  transform: scale(0.94);
}

.kb-key.kb-wide {
  max-width: 64px;
  font-size: 0.78rem;
  letter-spacing: -0.02em;
}

/* Keyboard colour states */
.kb-key.kb-correct {
  background: #538d4e;
}

.kb-key.kb-present {
  background: #b59f3b;
}

.kb-key.kb-absent {
  background: #3a3a3c;
  color: #818384;
}

body:not(.dark) .kb-key.kb-absent {
  background: #787c7e;
  color: #ffffff;
}

/* ── Help modal colour hints ─────────────────────────────────────────────── */
.help-green  { display: inline-block; padding: 1px 6px; border-radius: 4px; background: #538d4e; color: #fff; font-weight: 700; }
.help-yellow { display: inline-block; padding: 1px 6px; border-radius: 4px; background: #b59f3b; color: #fff; font-weight: 700; }
.help-grey   { display: inline-block; padding: 1px 6px; border-radius: 4px; background: #787c7e; color: #fff; font-weight: 700; }

/* ── Responsive adjustments ─────────────────────────────────────────────── */
@media (max-width: 360px) {
  /* Tile sizes now scale fluidly via clamp(). Keep keyboard and font
     adjustments for narrow screens. */
  .tile  { font-size: 1.3rem; }
  .kb-key { height: 50px; font-size: 0.78rem; }
}

@media (max-height: 680px) {
  .wordle-board {
    gap: 4px;
  }
  .kb-key {
    height: 48px;
  }
}
