/* Blue Fox Design System · vertical Games (acento roxo elétrico) */
:root {
  --brand-dark: #004aad;
  --brand-light: #38b6ff;
  --brand-accent: #8b5cf6;
  --navy: #0b132b;
  --navy-2: #1c2541;
  --navy-3: #26325a;
  --text: #eef4ff;
  --text-muted: #9fb0d0;
  --success: #10b981;
  --danger: #ef4444;
  --gradient: linear-gradient(135deg, #38b6ff 0%, #004aad 100%);
  --gradient-games: linear-gradient(135deg, #8b5cf6 0%, #004aad 100%);
  --p0: #38b6ff;
  --p1: #8b5cf6;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 20, 60, 0.45);
  --glow: 0 0 0 3px rgba(56, 182, 255, 0.25);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(56, 182, 255, 0.14), transparent 60%),
    var(--navy);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, .room-code, .brand, .turn, .result-card h2 {
  font-family: 'Outfit', system-ui, sans-serif;
  letter-spacing: -0.02em;
}

[hidden] { display: none !important; }

/* ---------- Status da conexão ---------- */
.status-row { display: flex; justify-content: flex-end; padding-top: 12px; }
.conn {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.conn::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}
.conn[data-state='online']::before { background: var(--success); }
.conn[data-state='offline']::before { background: var(--danger); }

/* ---------- Layout ---------- */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px clamp(16px, 4vw, 40px) 48px;
}
.screen { animation: fade-in 0.3s ease; }
.home, .lobby { text-align: center; }
h1 {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 800;
  margin: 24px 0 8px;
  background: linear-gradient(135deg, #ffffff 30%, #b9a6ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { color: var(--text-muted); margin: 0 0 28px; font-size: 1.05rem; }

.panel {
  background: rgba(28, 37, 65, 0.75);
  border: 1px solid rgba(56, 182, 255, 0.14);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  text-align: left;
}
.panel.center { text-align: center; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
.box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: var(--radius);
  background: rgba(11, 19, 43, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.18);
}
.box h2 { margin: 0; font-size: 1.15rem; }
.box .btn { margin-top: auto; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
input, select {
  font: inherit;
  color: var(--text);
  background: var(--navy);
  border: 1px solid var(--navy-3);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 46px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
input:focus, select:focus { outline: none; border-color: var(--brand-light); box-shadow: var(--glow); }
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  text-align: center;
}

/* ---------- Botões ---------- */
.btn {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  min-height: 46px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.25s, box-shadow 0.25s, background 0.25s, opacity 0.25s;
}
.btn:focus-visible { outline: none; box-shadow: var(--glow); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary { background: var(--gradient); box-shadow: 0 4px 14px rgba(0, 74, 173, 0.35); }
.btn-primary:hover { box-shadow: 0 6px 22px rgba(56, 182, 255, 0.4); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 2px solid var(--brand-accent); color: #d5c8ff; }
.btn-outline:hover { background: rgba(139, 92, 246, 0.15); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.btn-sm { min-height: 36px; padding: 6px 16px; font-size: 0.9rem; }

/* ---------- Lobby ---------- */
.room-code {
  font-size: clamp(3rem, 12vw, 4.5rem);
  font-weight: 800;
  letter-spacing: 0.25em;
  padding-left: 0.25em;
  background: var(--gradient-games);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.share { display: flex; gap: 10px; margin: 18px 0; }
.share input { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--text-muted); }
.waiting { color: var(--text-muted); display: flex; align-items: center; justify-content: center; gap: 10px; }
.dot-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-accent);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- Placar ---------- */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 12px 0 20px;
}
.player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(28, 37, 65, 0.8);
  border: 2px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s, opacity 0.3s;
  min-width: 0;
}
.player.p1 { flex-direction: row-reverse; text-align: right; }
.player.active.p0 { border-color: var(--p0); box-shadow: 0 0 24px rgba(56, 182, 255, 0.3); }
.player.active.p1 { border-color: var(--p1); box-shadow: 0 0 24px rgba(139, 92, 246, 0.35); }
.player.offline { opacity: 0.55; }
.player .info { min-width: 0; flex: 1; }
.player .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player .tag { font-size: 0.75rem; color: var(--text-muted); }
.player .score {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  line-height: 1;
}
.player.p0 .score { color: var(--p0); }
.player.p1 .score { color: var(--p1); }
.turn { font-weight: 700; text-align: center; font-size: 1rem; color: var(--text-muted); }
.turn.mine { color: #fff; }

/* ---------- Tabuleiro ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: clamp(6px, 1.5vw, 12px);
  max-width: calc(var(--cols, 4) * 120px);
  margin: 0 auto;
  perspective: 1000px;
}
.card {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 14px;
}
/* Botão disabled ganha cor translúcida no Chrome e o emoji herda: fixa a cor. */
.card, .card:disabled { color: var(--navy); opacity: 1; }
.card:disabled { cursor: default; }
.card:focus-visible { outline: none; box-shadow: var(--glow); }
.card .inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card.up .inner { transform: rotateY(180deg); }
.card .face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  backface-visibility: hidden;
  display: grid;
  place-items: center;
}
.card .back {
  background:
    url('/Favicon_logo5.png') center / 46% no-repeat,
    var(--gradient-games);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 16px rgba(0, 20, 60, 0.4);
}
.board.playable .card:not(:disabled):hover .back {
  box-shadow: 0 0 0 2px var(--brand-light), 0 10px 24px rgba(56, 182, 255, 0.35);
}
.card .front {
  transform: rotateY(180deg);
  background: #f1f6fc;
  font-size: clamp(2rem, 9vw, 3.2rem);
  border: 3px solid transparent;
}
.card.matched-0 .front { border-color: var(--p0); background: #e4f3ff; }
.card.matched-1 .front { border-color: var(--p1); background: #efe9ff; }
.card.matched-0, .card.matched-1 { animation: pop 0.35s ease; }

.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.game-footer strong { color: var(--text); letter-spacing: 0.15em; }

/* ---------- Resultado ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 43, 0.75);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade-in 0.3s ease;
  z-index: 10;
}
.result-card {
  background: var(--navy-2);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 24px;
  padding: 32px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow);
}
.result-emoji { font-size: 3.5rem; }
.result-card h2 { font-size: 1.8rem; margin: 8px 0; }
.result-card p { color: var(--text-muted); margin: 0 0 24px; }
.result-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-left: 4px solid var(--brand-light);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
  max-width: calc(100% - 32px);
  animation: fade-in 0.2s ease;
}
.toast.error { border-left-color: var(--danger); }

/* ---------- Animações ---------- */
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1.2); opacity: 1; } }
@keyframes pop { 50% { transform: scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .split { grid-template-columns: 1fr; }
  .share { flex-direction: column; }
  .scoreboard { grid-template-columns: 1fr 1fr; }
  .turn { grid-column: 1 / -1; grid-row: 2; }
  .player { padding: 10px 12px; }
  .player .score { font-size: 1.6rem; }
  .board[data-cards='24'] { --cols: 4 !important; }
}
