/* Modo Palavra Secreta (estilo Wordle). Usa os tokens de style.css. */
.wd-host { overflow-y: auto; justify-content: safe center; }
.wd-host [hidden] { display: none !important; }

.wd {
  --cell: max(34px, min(60px, calc((100vw - 40px) / var(--n, 5) - 6px), calc((100vh - 480px) / 6), calc((100dvh - 480px) / 6)));
  --c-correct: var(--ok, #72d14b);
  --c-correct-dark: #3f8f2a;
  --c-present: var(--warn, #f7d038);
  --c-present-dark: #b8901a;
  --c-absent: #2b2044;
  --c-absent-dark: #1a1230;
  width: min(560px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: auto 0;
}

/* ───────── HUD */
.wd-hud {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
}
.wd-hud-name { font-weight: 700; font-size: 15px; letter-spacing: .04em; }
.wd-hud-sub { font-size: 12px; color: var(--muted); }
.wd-hud-right { display: flex; align-items: center; gap: 12px; }
.wd-score { font-family: var(--title); font-size: 24px; color: var(--warn); min-width: 48px; text-align: right; }
.wd-score.bump { animation: wdBump .4s steps(4); }
.wd-streak { font-size: 14px; font-weight: 700; color: var(--muted); }
.wd-streak.hot { color: #ff9a3c; }
@keyframes wdBump { 50% { transform: scale(1.3); } }

.wd-dots { display: flex; gap: 6px; }
.wd-dots i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.wd-dots i.current { background: var(--academe-light); animation: wdBlink 1s steps(2) infinite; }
.wd-dots i.ok { background: var(--c-correct); }
.wd-dots i.bad { background: var(--bad); }
@keyframes wdBlink { 50% { opacity: .4; } }

.wd-tools { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wd-theme { font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-hint-btn {
  flex: none; padding: 6px 12px; font-size: 13px; font-weight: 600; border-radius: 8px;
  background: #0c0a1c; border: 2px solid var(--line);
}
.wd-hint-btn:hover:not(:disabled) { border-color: var(--academe-light); }
.wd-hint-btn:disabled { opacity: .4; cursor: default; }
.wd-hint {
  width: 100%; padding: 10px 12px; font-size: 14px; line-height: 1.4;
  background: rgba(247, 208, 56, .08); border: 2px dashed rgba(247, 208, 56, .45); border-radius: 10px;
}

/* ───────── Grade */
.wd-grid { display: grid; gap: 6px; }
.wd-row { display: grid; grid-template-columns: repeat(var(--n), var(--cell)); gap: 6px; }
.wd-row.shake { animation: wdShake .45s; }
@keyframes wdShake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.wd-tile {
  width: var(--cell); height: var(--cell);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--title); font-weight: 700; font-size: calc(var(--cell) * .55); text-transform: uppercase;
  background: rgba(12, 10, 28, .7); border: 2px solid var(--line); border-radius: 8px; color: #fff;
  user-select: none;
}
.wd-tile.filled { border-color: var(--academe-light); }
.wd-tile.pop { animation: wdPop .12s ease-out; }
@keyframes wdPop { 50% { transform: scale(1.12); } }
.wd-tile.flip { animation: wdFlip .52s ease-in-out both; }
@keyframes wdFlip { 50% { transform: rotateX(90deg); } }
.wd-tile.correct { background: var(--c-correct); border-color: var(--c-correct); box-shadow: inset 0 -4px 0 var(--c-correct-dark); color: #0f2108; }
.wd-tile.present { background: var(--c-present); border-color: var(--c-present); box-shadow: inset 0 -4px 0 var(--c-present-dark); color: #2a2104; }
.wd-tile.absent { background: var(--c-absent); border-color: var(--c-absent); box-shadow: inset 0 -4px 0 var(--c-absent-dark); color: #8c7fae; }
.wd-tile.win { animation: wdWin .5s ease-out; }
@keyframes wdWin { 40% { transform: translateY(-14px); } 70% { transform: translateY(3px); } }

.wd-msg { min-height: 22px; font-size: 14px; font-weight: 700; color: var(--warn); text-align: center; }
.wd-msg.show { animation: wdPop .25s; }

/* ───────── Teclado */
.wd-bottom { width: 100%; }
.wd-keys { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.wd-krow { display: flex; justify-content: center; gap: 5px; }
.wd-key {
  flex: 1 1 0; max-width: 46px; height: 50px; padding: 0;
  font-weight: 700; font-size: 15px;
  background: #3a2d5c; border: 0; border-radius: 7px; box-shadow: inset 0 -3px 0 #251a40;
  transition: background .2s;
}
.wd-key.wide { flex: 1.6 1 0; max-width: 74px; font-size: 12px; }
.wd-key:active { transform: translateY(2px); box-shadow: none; }
.wd-key.correct { background: var(--c-correct); box-shadow: inset 0 -3px 0 var(--c-correct-dark); color: #0f2108; }
.wd-key.present { background: var(--c-present); box-shadow: inset 0 -3px 0 var(--c-present-dark); color: #2a2104; }
.wd-key.absent { background: var(--c-absent); box-shadow: none; color: #5d5180; }

/* ───────── Revelação da palavra */
.wd-panel {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  background: var(--panel); border: 2px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
  animation: wdIn .35s steps(5) both;
}
.wd-panel.ok { border-color: var(--c-correct); }
.wd-panel.bad { border-color: var(--bad); }
@keyframes wdIn { from { opacity: 0; transform: translateY(10px); } }
.wd-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wd-panel-status { font-size: 18px; font-weight: 800; }
.wd-panel.ok .wd-panel-status { color: var(--c-correct); }
.wd-panel.bad .wd-panel-status { color: var(--bad); }
.wd-panel-pts { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.08); cursor: help; }
.wd-panel-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.wd-panel-word { font-family: var(--title); font-size: 34px; letter-spacing: 4px; color: #fff; }
.wd-panel-def { font-size: 15px; line-height: 1.45; color: var(--ink); }

.wd-btn {
  margin-top: 6px; padding: 11px 18px; font-size: 16px; font-weight: 700; border-radius: 10px;
  background: #0c0a1c; border: 2px solid var(--line);
}
.wd-btn.primary { background: var(--academe); border-color: var(--academe); color: #fff; box-shadow: inset 0 -4px 0 var(--academe-dark); }
.wd-btn:hover { filter: brightness(1.1); }

/* ───────── Tela de escolha */
.wd-title {
  margin: 0; text-align: center; font-family: var(--title); font-weight: 700; letter-spacing: 2px;
  font-size: clamp(32px, 7vw, 58px); color: #e9e4d8;
  text-shadow: 0 2px 0 #b9b3a3, 0 4px 0 #6b6759, 0 10px 14px rgba(0,0,0,.5);
}
.wd-title span { color: var(--academe-light); text-shadow: 0 2px 0 #9a4fe6, 0 4px 0 var(--academe-dark), 0 10px 14px rgba(0,0,0,.5); }
.wd-lead { margin: 4px 0; text-align: center; font-size: 16px; line-height: 1.45; color: var(--muted); max-width: 460px; }
.wd-legend { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.wd-legend span { display: flex; align-items: center; gap: 10px; }
.wd-legend .wd-tile { --cell: 32px; width: 32px; height: 32px; font-size: 17px; font-style: normal; flex: none; }
.wd-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin-top: 8px; }
.wd-sizes button {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 8px; text-align: center;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
}
.wd-sizes button:hover { border-color: var(--academe-light); transform: translateY(-2px); }
.wd-sizes b { font-size: 18px; }
.wd-sizes small { font-size: 12px; color: var(--muted); }
.wd-note { margin: 0; font-size: 13px; color: var(--muted); }
.wd-link { background: none; border: 0; color: var(--muted); font-size: 14px; text-decoration: underline; }

/* ───────── Fim */
.wd-end-score { display: flex; align-items: baseline; gap: 8px; }
.wd-end-score b { font-family: var(--title); font-size: 64px; color: var(--warn); }
.wd-end-score small { font-size: 16px; color: var(--muted); }
.wd-end-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.wd-end-stats div {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; text-align: center;
  font-size: 12px; color: var(--muted); background: var(--panel); border: 2px solid var(--line); border-radius: 10px;
}
.wd-end-stats b { font-size: 22px; color: var(--ink); }
.wd-end-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.wd-end-list li {
  display: grid; grid-template-columns: 24px 1fr auto 48px; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--panel); border: 2px solid var(--line); border-radius: 10px;
}
.wd-end-mark { font-weight: 800; }
.wd-end-list li.ok .wd-end-mark { color: var(--c-correct); }
.wd-end-list li.bad .wd-end-mark { color: var(--bad); }
.wd-end-word { font-family: var(--title); font-size: 20px; letter-spacing: 2px; }
.wd-end-info { font-size: 12px; color: var(--muted); }
.wd-end-pts { text-align: right; font-weight: 700; }
.wd-end-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 420px) {
  .wd { gap: 7px; }
  .wd-hint { font-size: 13px; padding: 8px 10px; }
  .wd-panel-word { font-size: 28px; }
  .wd-sizes { grid-template-columns: 1fr; }
  .wd-end-stats { grid-template-columns: repeat(2, 1fr); }
  .wd-key { height: 46px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .wd-tile.flip, .wd-tile.win, .wd-tile.pop, .wd-row.shake { animation: none; }
}
