/* =========================================================
   Jogo da Forca — Tema escuro navy + ciano
   ========================================================= */

:root {
  --bg-deep: #0b132b;
  --bg-panel: #1c2541;
  --bg-panel-soft: #22305a;
  --accent: #48cae4;
  --accent-strong: #00b4d8;
  --accent-soft: rgba(72, 202, 228, 0.12);
  --text: #f4f9ff;
  --muted: #9db2ca;
  --muted-strong: #c3d3e6;
  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.1);
  --success: #6ee7b7;
  --line: rgba(157, 178, 202, 0.16);
  --line-accent: rgba(72, 202, 228, 0.26);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-card: 0 32px 90px rgba(0, 0, 0, 0.5), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
  --font-sans: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: clamp(14px, 3vw, 36px);
  display: grid;
  place-items: center;
  overflow-x: hidden;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 180, 216, 0.14), transparent 32rem),
    radial-gradient(circle at 88% 92%, rgba(72, 202, 228, 0.1), transparent 34rem),
    linear-gradient(160deg, #0b132b 0%, #0d1733 52%, #081021 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Grade discreta ao fundo */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(72, 202, 228, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(72, 202, 228, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 78%);
}

body.is-locked {
  overflow: hidden;
}

button {
  font-family: inherit;
}

.page {
  width: min(100%, 1000px);
  position: relative;
}

/* =========================================================
   Card principal
   ========================================================= */

.game-card {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 3.8vw, 40px);
  border: 1px solid var(--line-accent);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(155deg, rgba(34, 48, 90, 0.92) 0%, rgba(20, 30, 57, 0.96) 46%, rgba(11, 19, 43, 0.98) 100%);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(72, 202, 228, 0.65), transparent);
  opacity: 0.9;
}

.game-card::after {
  content: "";
  position: absolute;
  top: -180px;
  left: 50%;
  width: 520px;
  height: 320px;
  transform: translateX(-50%);
  pointer-events: none;
  background: radial-gradient(ellipse, rgba(72, 202, 228, 0.13), transparent 70%);
}

.game-card.is-won {
  border-color: rgba(110, 231, 183, 0.45);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.5), 0 0 60px rgba(72, 202, 228, 0.12);
}

.game-card.is-lost {
  border-color: rgba(255, 107, 129, 0.34);
}

/* =========================================================
   Cabeçalho
   ========================================================= */

.game-header {
  position: relative;
  z-index: 1;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(72, 202, 228, 0.12), 0 0 14px rgba(72, 202, 228, 0.8);
  animation: pulseDot 2.8s ease-in-out infinite;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4.4vw, 2.85rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  background: linear-gradient(115deg, #ffffff 16%, #c9f4fb 58%, #7fe0f3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 10px auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: clamp(0.83rem, 1.7vw, 0.96rem);
  line-height: 1.55;
}

/* =========================================================
   Barra de status
   ========================================================= */

.status-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(14px, 3vw, 30px);
  margin-top: clamp(20px, 3vw, 28px);
  padding: 14px clamp(14px, 2.2vw, 20px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(11, 19, 43, 0.52);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.status-info {
  display: flex;
  align-items: stretch;
  gap: clamp(16px, 3vw, 30px);
  min-width: 0;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.status-item + .status-item {
  padding-left: clamp(16px, 3vw, 30px);
  border-left: 1px solid var(--line);
}

.status-item--hint {
  max-width: 52ch;
}

.status-label {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
}

.status-value {
  color: var(--muted-strong);
  font-size: clamp(0.78rem, 1.5vw, 0.88rem);
  line-height: 1.45;
}

.status-category {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.lives {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  flex-shrink: 0;
}

.lives-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.lives-count {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.lives-total {
  margin-left: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.lives-pips {
  display: flex;
  gap: 5px;
}

.life-pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(72, 202, 228, 0.55);
  transition: background 0.35s ease, box-shadow 0.35s ease, transform 0.35s ease;
}

.life-pip.is-lost {
  background: rgba(157, 178, 202, 0.14);
  box-shadow: none;
  transform: scale(0.72);
}

.lives.is-critical .life-pip:not(.is-lost) {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 107, 129, 0.6);
  animation: pulseDot 1.2s ease-in-out infinite;
}

/* =========================================================
   Corpo do jogo
   ========================================================= */

.game-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  align-items: center;
  gap: clamp(22px, 4vw, 46px);
  margin-top: clamp(22px, 3.4vw, 32px);
}

/* ---------- Palco / SVG ---------- */

.stage {
  padding: clamp(10px, 2vw, 18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(72, 202, 228, 0.11);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 34%, rgba(72, 202, 228, 0.1), transparent 62%),
    rgba(11, 19, 43, 0.28);
}

.stage.is-shaking {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.gallows {
  display: block;
  width: 100%;
  max-width: 285px;
  height: auto;
  overflow: visible;
}

.gallows-frame path,
.gallows-frame line {
  fill: none;
  stroke: #405a7d;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallows-frame .frame-ground {
  stroke: #2e4463;
  stroke-width: 9;
}

.gallows-frame .frame-brace {
  stroke-width: 5;
  stroke: #36506f;
}

.gallows-frame .frame-rope {
  stroke: #7b93b3;
  stroke-width: 3.5;
}

.part {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 280;
  stroke-dashoffset: 280;
  opacity: 0;
  filter: drop-shadow(0 0 7px rgba(72, 202, 228, 0.38));
  transition: stroke-dashoffset 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease, stroke 0.4s ease;
}

.part-head {
  stroke-dasharray: 138.23;
  stroke-dashoffset: 138.23;
}

.part.is-visible {
  opacity: 1;
  stroke-dashoffset: 0;
}

.gallows.is-lost .part {
  stroke: var(--danger);
  filter: drop-shadow(0 0 8px rgba(255, 107, 129, 0.45));
}

.stage-caption {
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- Área de jogo ---------- */

.play-area {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.4vw, 20px);
  min-width: 0;
}

.word {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1vw, 9px);
  min-height: 58px;
  padding: 4px 0;
}

.slot {
  display: grid;
  place-items: center;
  width: clamp(30px, 4.2vw, 46px);
  height: clamp(42px, 5.6vw, 58px);
  border: 1px solid rgba(157, 178, 202, 0.17);
  border-bottom: 2px solid rgba(72, 202, 228, 0.32);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: clamp(1.05rem, 2.5vw, 1.4rem);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.slot.is-revealed {
  border-color: rgba(72, 202, 228, 0.48);
  border-bottom-color: var(--accent);
  background: rgba(72, 202, 228, 0.11);
  box-shadow: 0 8px 22px rgba(0, 180, 216, 0.12), 0 1px 0 rgba(255, 255, 255, 0.07) inset;
  animation: slotPop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slot.is-missed {
  border-color: rgba(255, 107, 129, 0.25);
  border-bottom-color: rgba(255, 107, 129, 0.55);
  background: var(--danger-soft);
  color: var(--danger);
}

.word.is-compact {
  gap: 5px;
}

.word.is-compact .slot {
  width: clamp(20px, 2.9vw, 33px);
  height: clamp(38px, 4.6vw, 47px);
  font-size: clamp(0.92rem, 2vw, 1.18rem);
  border-radius: 8px;
}

.feedback {
  min-height: 1.55em;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.77rem, 1.5vw, 0.86rem);
  line-height: 1.55;
  text-align: center;
  transition: color 0.25s ease;
}

.feedback[data-tone="good"] {
  color: var(--accent);
}

.feedback[data-tone="bad"] {
  color: var(--danger);
}

.feedback[data-tone="win"] {
  color: var(--success);
  font-weight: 700;
}

/* ---------- Teclado virtual ---------- */

.keyboard {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.9vw, 8px);
}

.key-row {
  display: flex;
  justify-content: center;
  gap: clamp(4px, 0.9vw, 8px);
}

.key-row:nth-child(2) {
  padding-inline: 3.5%;
}

.key-row:nth-child(3) {
  padding-inline: 9%;
}

.key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 47px;
  height: clamp(38px, 4.8vw, 46px);
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(157, 178, 202, 0.18);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(47, 65, 108, 0.92), rgba(28, 37, 65, 0.92));
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.24);
  color: #e9f4ff;
  font-size: clamp(0.76rem, 1.8vw, 0.95rem);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    background 0.16s ease, box-shadow 0.16s ease, opacity 0.2s ease;
}

.key:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(72, 202, 228, 0.62);
  color: var(--accent);
  background: linear-gradient(180deg, rgba(55, 78, 128, 0.95), rgba(31, 43, 76, 0.95));
  box-shadow: 0 8px 20px rgba(0, 180, 216, 0.18), 0 0 0 3px rgba(72, 202, 228, 0.08);
}

.key:active:not(:disabled) {
  transform: translateY(1px) scale(0.97);
  box-shadow: none;
}

.key:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(72, 202, 228, 0.35);
}

.key:disabled {
  cursor: not-allowed;
  opacity: 0.32;
  box-shadow: none;
}

.key.is-used {
  background: rgba(11, 19, 43, 0.45);
  border-color: rgba(157, 178, 202, 0.12);
}

.key.is-correct:disabled {
  opacity: 0.9;
  color: var(--accent);
  border-color: rgba(72, 202, 228, 0.55);
  background: rgba(72, 202, 228, 0.12);
  text-decoration: none;
}

.key.is-wrong:disabled {
  opacity: 0.75;
  color: var(--danger);
  border-color: rgba(255, 107, 129, 0.4);
  background: var(--danger-soft);
  text-decoration: line-through;
}

/* =========================================================
   Rodapé
   ========================================================= */

.game-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(22px, 3vw, 30px);
  padding-top: clamp(14px, 2vw, 18px);
  border-top: 1px solid var(--line);
}

.footer-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
}

/* =========================================================
   Botões
   ========================================================= */

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease,
    background 0.16s ease, color 0.16s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(72, 202, 228, 0.4);
}

.btn-primary {
  padding: 15px 28px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #05101f;
  font-size: 0.92rem;
  box-shadow: 0 12px 28px rgba(0, 180, 216, 0.26);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(0, 180, 216, 0.36);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
}

.btn-ghost:hover {
  border-color: rgba(72, 202, 228, 0.45);
  background: rgba(72, 202, 228, 0.06);
  color: var(--accent);
}

/* =========================================================
   Modal de fim de jogo
   ========================================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0s linear 0s;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 9, 22, 0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.modal-card {
  position: relative;
  width: min(100%, 432px);
  padding: clamp(26px, 5vw, 40px);
  border: 1px solid rgba(72, 202, 228, 0.25);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(40, 56, 100, 0.72), rgba(13, 22, 45, 0.82));
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.09) inset;
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  text-align: center;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition: opacity 0.32s ease, transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal.is-open .modal-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-card[data-outcome="lost"] {
  border-color: rgba(255, 107, 129, 0.3);
}

.modal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  padding: 6px 14px;
  border: 1px solid rgba(72, 202, 228, 0.35);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

.modal-card[data-outcome="lost"] .modal-badge {
  border-color: rgba(255, 107, 129, 0.35);
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.95rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.modal-message {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.6;
}

.modal-word {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(11, 19, 43, 0.48);
}

.modal-word-label {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.modal-word-value {
  color: var(--accent);
  font-size: clamp(1.3rem, 5vw, 1.75rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.modal-card[data-outcome="lost"] .modal-word-value {
  color: var(--danger);
}

.modal-card .btn-primary {
  width: 100%;
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 200;
  margin: 0;
  padding: 12px 18px;
  border: 1px solid var(--line-accent);
  border-radius: 12px;
  background: var(--bg-panel);
  color: var(--text);
  font-size: 0.85rem;
  text-align: center;
}

/* =========================================================
   Animações
   ========================================================= */

@keyframes slotPop {
  0% {
    opacity: 0.25;
    transform: translateY(7px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* =========================================================
   Responsivo
   ========================================================= */

@media (max-width: 860px) {
  .game-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage {
    width: 100%;
    max-width: 430px;
    margin-inline: auto;
  }

  .gallows {
    max-width: 235px;
  }

  .status-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .status-info {
    width: 100%;
  }

  .lives {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .lives-pips {
    order: -1;
  }

  .play-area {
    width: 100%;
    max-width: 560px;
    margin-inline: auto;
  }
}

@media (max-width: 560px) {
  body {
    padding: 10px;
  }

  .game-card {
    padding: 20px 16px;
    border-radius: 22px;
  }

  .status-info {
    flex-direction: column;
    gap: 12px;
  }

  .status-item + .status-item {
    padding-top: 12px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .status-item--hint {
    max-width: none;
  }

  .word {
    gap: 5px;
  }

  .slot {
    width: clamp(24px, 5.4vw, 34px);
    height: clamp(38px, 7.4vw, 48px);
    font-size: clamp(0.95rem, 3.4vw, 1.2rem);
  }

  .word.is-compact {
    gap: 3px;
  }

  .word.is-compact .slot {
    width: clamp(19px, 4.4vw, 27px);
    height: clamp(34px, 6.8vw, 42px);
    font-size: clamp(0.82rem, 2.9vw, 1rem);
  }

  .key {
    height: 40px;
    border-radius: 8px;
  }

  .key-row:nth-child(2) {
    padding-inline: 2%;
  }

  .key-row:nth-child(3) {
    padding-inline: 6%;
  }

  .game-footer {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .game-card {
    padding: 18px 12px;
  }

  .gallows {
    max-width: 200px;
  }

  .key {
    height: 36px;
    font-size: 0.72rem;
  }

  .slot {
    width: 22px;
    height: 36px;
  }

  .word.is-compact .slot {
    width: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
