/* ==========================================================================
   Caça-Palavras Competitivo — tema "Cyber Deep Blue"
   Fundo azul-marinho quase noturno, cartões flutuantes com cantos muito
   arredondados, acentos em azul elétrico / roxo neon e glow suave.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  /* --- cor --- */
  --bg-void:      #05070f;
  --bg-deep:      #0a0f22;
  --bg-panel:     #0f1730;
  --bg-card:      #131d3c;
  --bg-card-soft: #101a36;
  --line-soft:    rgba(140, 160, 255, 0.14);

  --blue:         #4f7cff;
  --blue-bright:  #7ea2ff;
  --purple:       #a855f7;
  --cyan:         #22d3ee;
  --green:        #34e2a0;
  --amber:        #ffb454;
  --red:          #ff6a88;

  --text-hi:      #f5f7ff;
  --text-mid:     #b7c0e6;
  --text-low:     #7883ad;

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-void);
  color: var(--text-hi);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(circle at 12% -10%, rgba(79, 124, 255, 0.20), transparent 45%),
    radial-gradient(circle at 88% 0%, rgba(168, 85, 247, 0.16), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(34, 211, 238, 0.08), transparent 50%),
    var(--bg-void);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  margin: 0;
}

p { margin: 0; color: var(--text-mid); line-height: 1.55; }

a { color: inherit; }

button, input, textarea, select {
  font-family: inherit;
}

::selection { background: rgba(79, 124, 255, 0.35); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(140, 160, 255, 0.25); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* --- foco visível (acessibilidade) --- */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ==========================================================================
   Layout genérico
   ========================================================================== */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.page--narrow { max-width: 620px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px 2px var(--cyan);
}

/* ==========================================================================
   Cartões flutuantes
   ========================================================================== */

.card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card-soft) 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow:
    0 24px 60px -24px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.015) inset;
}

.card + .card { margin-top: 20px; }

.card--tight { padding: 20px; border-radius: var(--radius-lg); }

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

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primary {
  color: #06101f;
  background: linear-gradient(135deg, var(--cyan), var(--blue-bright));
  box-shadow: 0 0 0 rgba(79,124,255,0); 
}
.btn--primary:not(:disabled):hover {
  box-shadow: 0 8px 28px -6px rgba(79, 124, 255, 0.65);
}

.btn--ghost {
  color: var(--text-hi);
  background: rgba(140, 160, 255, 0.08);
  border: 1px solid var(--line-soft);
}
.btn--ghost:not(:disabled):hover { background: rgba(140, 160, 255, 0.14); }

.btn--danger {
  color: #2a0410;
  background: linear-gradient(135deg, #ff8aa6, var(--red));
}

.btn--block { width: 100%; }

/* ==========================================================================
   Formulários
   ========================================================================== */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 8px;
}

.field { margin-bottom: 20px; }

.input, textarea.input, select.input {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-hi);
  font-size: 15px;
  resize: vertical;
}
.input::placeholder { color: var(--text-low); }
.input:focus { border-color: var(--blue); }

.hint { font-size: 12.5px; color: var(--text-low); margin-top: 6px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; } }

/* ==========================================================================
   Chips / badges
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.pill--waiting { background: rgba(255, 180, 84, 0.14); color: var(--amber); }
.pill--running { background: rgba(52, 226, 160, 0.14); color: var(--green); }
.pill--ended   { background: rgba(120, 131, 173, 0.16); color: var(--text-mid); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--on  { background: var(--green); box-shadow: 0 0 6px 1px var(--green); }
.dot--off { background: var(--text-low); }

/* ==========================================================================
   Código da sala — elemento de "assinatura"
   ========================================================================== */

.room-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 40px;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, var(--cyan), var(--blue-bright) 60%, var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.room-link {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-mid);
  word-break: break-all;
}

/* ==========================================================================
   Tabuleiro
   ========================================================================== */

.board-wrap {
  display: flex;
  justify-content: center;
  touch-action: none;
}

.board {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-mid);
  background: rgba(140, 160, 255, 0.05);
  border-radius: 10px;
  position: relative;
  z-index: 2;
  transition: color 0.12s ease, background 0.12s ease;
}

.cell.is-selecting {
  color: var(--bg-void);
  background: var(--blue-bright);
}

.cell.is-found {
  color: var(--bg-void);
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 0 14px -2px var(--cyan);
}

.selection-line {
  position: absolute;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  border-radius: 999px;
  transform-origin: left center;
  opacity: 0.55;
  z-index: 1;
  pointer-events: none;
}

.found-line {
  position: absolute;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  border-radius: 999px;
  transform-origin: left center;
  opacity: 0.45;
  z-index: 1;
  pointer-events: none;
  box-shadow: 0 0 16px -2px var(--cyan);
}

.cell.is-missing {
  color: var(--bg-void);
  background: linear-gradient(135deg, var(--amber), var(--red));
  box-shadow: 0 0 14px -2px var(--red);
}

.missing-line {
  position: absolute;
  background: linear-gradient(90deg, var(--amber), var(--red));
  border-radius: 999px;
  transform-origin: left center;
  opacity: 0.45;
  z-index: 1;
  pointer-events: none;
  box-shadow: 0 0 16px -2px var(--red);
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
.board.is-invalid { animation: shake 0.32s ease; }

@keyframes pop-found {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.cell.just-found { animation: pop-found 0.32s ease; }

/* ==========================================================================
   Lista de palavras
   ========================================================================== */

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-chip {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(140, 160, 255, 0.08);
  color: var(--text-mid);
  border: 1px solid var(--line-soft);
  transition: all 0.2s ease;
}

.word-chip.is-found {
  color: var(--bg-void);
  background: linear-gradient(135deg, var(--cyan), var(--green));
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  border-color: transparent;
}

.word-chip.is-missing {
  color: var(--text-hi);
  background: rgba(255, 106, 136, 0.14);
  border-color: rgba(255, 106, 136, 0.4);
}

/* ==========================================================================
   Ranking
   ========================================================================== */

.ranking { display: flex; flex-direction: column; gap: 10px; }

.rank-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
}

.rank-row--top1 { border-color: rgba(34, 211, 238, 0.5); box-shadow: 0 0 20px -8px var(--cyan); }

.rank-pos {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-low);
}
.rank-row--top1 .rank-pos { color: var(--cyan); }

.rank-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }

.rank-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(140, 160, 255, 0.12);
  margin-top: 6px;
  overflow: hidden;
}
.rank-progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  border-radius: 999px;
}

.rank-score {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-hi);
  text-align: right;
}

/* ==========================================================================
   Timer
   ========================================================================== */

.timer {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-hi);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(140, 160, 255, 0.08);
  border: 1px solid var(--line-soft);
}
.timer.is-low { color: var(--red); border-color: rgba(255, 106, 136, 0.4); }

/* ==========================================================================
   Overlay de fim de jogo
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 15, 0.86);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.podium-place {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
}

/* ==========================================================================
   Utilidades
   ========================================================================== */

.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.muted { color: var(--text-low); font-size: 13px; }
.center { text-align: center; }

@media (max-width: 640px) {
  .card { padding: 20px; border-radius: var(--radius-lg); }
  .room-code { font-size: 30px; }
}
