/* =========================================================
   Word Daily — DOM board + keyboard on top of the arcade kit.
   Deliberately not canvas: text needs to be crisp at every DPI,
   selectable, and reachable by screen readers.
   ========================================================= */
:root { --accent: #5ddb7a; --green: #4fa863; --yellow: #c9a227; --grey: #3a3f5a; }

#stage {
  aspect-ratio: auto;
  max-height: none;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;   /* board is DOM, so allow normal taps */
  background: #0c0f1e;
}

/* ---------- Board ---------- */
.board-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 54px 10px 6px;
}
.board { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px; }
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

.tile {
  width: clamp(38px, 12vw, 58px);
  height: clamp(38px, 12vw, 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(19px, 6vw, 28px);
  font-weight: 800;
  font-family: 'Chakra Petch', 'Segoe UI', sans-serif;
  border: 2px solid #2c3150;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  text-transform: uppercase;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.tile.filled { border-color: #4a5178; animation: tilePop 0.1s ease; }
@keyframes tilePop { 50% { transform: scale(1.09); } }

.tile.green  { background: var(--green);  border-color: var(--green);  color: #06210f; }
.tile.yellow { background: var(--yellow); border-color: var(--yellow); color: #221a02; }
.tile.grey   { background: var(--grey);   border-color: var(--grey);   color: #cdd0e0; }

/* Flip reveal, staggered per tile via inline animation-delay. */
.tile.reveal { animation: flip 0.5s ease forwards; }
@keyframes flip {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.row.shake { animation: rowShake 0.42s ease; }
@keyframes rowShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.row.bounce .tile { animation: bounce 0.5s ease; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-16px); }
  70% { transform: translateY(4px); }
}

/* ---------- Keyboard ---------- */
.kb {
  padding: 6px 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.kb-row { display: flex; gap: 5px; justify-content: center; width: 100%; }
.key {
  flex: 1 1 0;
  max-width: 44px;
  min-width: 0;
  height: 52px;
  border-radius: 6px;
  border: none;
  background: #4a5178;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.key:active { transform: scale(0.92); }
.key.wide { flex: 1.6 1 0; max-width: 68px; font-size: 11px; letter-spacing: 0.4px; }
.key.green  { background: var(--green);  color: #06210f; }
.key.yellow { background: var(--yellow); color: #221a02; }
.key.grey   { background: #262a42; color: #7b7f9c; }

/* ---------- Mode chips ---------- */
.mode-row { display: flex; gap: 8px; justify-content: center; }
.mode-btn {
  padding: 12px 22px;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.mode-btn:active { transform: scale(0.94); }
.mode-btn.primary { background: linear-gradient(135deg, var(--purple), #9b7bff); border-color: transparent; }
.mode-btn.alt { background: linear-gradient(135deg, #4fa863, #35784a); border-color: transparent; }

/* ---------- Results ---------- */
.answer-line { font-size: 14px; color: var(--text-dim); }
.answer-line b { color: var(--accent); font-size: 19px; letter-spacing: 2px; }

.stat-row { display: flex; gap: 16px; justify-content: center; width: 100%; margin: 2px 0 4px; }
.stat-row > div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-row .n { font-size: 22px; font-weight: 800; }
.stat-row .l { font-size: 9px; letter-spacing: 1px; color: var(--text-dim); text-align: center; }

.dist { width: 100%; display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; }
.dist-row { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.dist-row .k { width: 10px; color: var(--text-dim); font-weight: 700; }
.dist-row .bar {
  background: #3a3f5a;
  height: 18px;
  border-radius: 3px;
  min-width: 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-weight: 700;
  font-size: 11px;
  transition: width 0.4s ease;
}
.dist-row .bar.cur { background: var(--green); color: #06210f; }

.share-grid {
  font-size: 13px;
  line-height: 1.28;
  letter-spacing: 1px;
  color: var(--text);
}

.countdown { font-size: 12px; color: var(--text-dim); }
.countdown b { color: var(--gold); font-variant-numeric: tabular-nums; }

/* .toast now lives in the shared kit (arcade.css). */

@media (max-width: 360px) {
  .key { height: 46px; font-size: 12px; }
  .tile { border-width: 1.6px; }
}
