:root {
  --bg: #0a0a0f;
  --surface: #121220;
  --surface-2: #1a1a2b;
  --accent: #9b5de5;
  --text: #e8e8f0;
  --muted: #b4b4c6;
  --danger: #ef476f;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.tutorial-open {
  overflow: hidden;
}

.logo,
h1,
h2,
h3 {
  font-family: "Space Grotesk", Inter, sans-serif;
}

.app-shell {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.view {
  background: var(--surface);
  border: 1px solid #26263d;
  border-radius: 16px;
  padding: 18px;
  transition: opacity 250ms ease, transform 250ms ease;
}

.hidden {
  display: none;
}

.logo {
  margin: 0;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.12rem;
  color: var(--accent);
}

.subtitle {
  margin: 8px 0 18px;
  text-align: center;
  color: var(--muted);
}

.launch-intro {
  border: 1px solid #2f2a46;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  background: linear-gradient(160deg, #17142a, #121220);
}

.launch-kicker {
  margin: 0 0 6px;
  color: #cdb4ff;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06rem;
}

.launch-title {
  margin: 0 0 10px;
  font-size: 1.12rem;
}

.launch-pillars {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.launch-pillar {
  border-radius: 10px;
  background: #171728;
  border: 1px solid #2d2d44;
  padding: 8px 10px;
  font-size: 0.92rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.95rem;
  color: var(--muted);
}

input {
  min-height: 48px;
  border: 1px solid #2d2d48;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
  font-size: 1rem;
  text-transform: uppercase;
}

#nickname-input {
  text-transform: none;
}

.color-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.color-dot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 999px;
  border: 2px solid transparent;
  min-height: 40px;
  cursor: pointer;
}

.color-dot.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #000;
}

.btn {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 0 0 rgba(155, 93, 229, 0.5);
  transition: transform 250ms ease, box-shadow 250ms ease, opacity 250ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-big {
  width: 100%;
  font-size: 1.05rem;
  letter-spacing: 0.04rem;
}

.btn-primary {
  background: var(--accent);
  box-shadow: 0 0 16px rgba(155, 93, 229, 0.38);
}

.btn-secondary {
  background: #3a3a58;
}

.btn-danger {
  width: 100%;
  background: var(--danger);
  margin-top: 14px;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  align-items: end;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.join-field {
  margin-bottom: 0;
}

.room-label {
  margin: 0;
  color: var(--muted);
}

.room-code {
  margin: 6px 0 18px;
  font-size: 2rem;
  letter-spacing: 0.28rem;
  text-align: center;
  color: var(--accent);
}

.players-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-live-dots {
  margin-top: 12px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  opacity: 0.85;
  animation: floaty 2.2s ease-in-out infinite;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
}

.player-color {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.player-name {
  flex: 1;
}

.waiting {
  margin: 12px 0 0;
  color: var(--muted);
  text-align: center;
}

.dots::after {
  content: "...";
  display: inline-block;
  width: 18px;
  animation: pulse 1.2s infinite steps(3);
}

.status {
  min-height: 24px;
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.status.error {
  color: #ff8fab;
}

.status.loading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 999px;
  border: 2px solid #8d8da2;
  border-top-color: #e8e8f0;
  animation: spin 0.9s linear infinite;
  vertical-align: middle;
}

@keyframes pulse {
  0% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.game-shell {
  justify-content: space-between;
}

.game-card {
  background: var(--surface);
  border: 1px solid #26263d;
  border-radius: 16px;
  padding: 18px;
  transition: opacity 250ms ease, transform 250ms ease;
}

.role-warning {
  margin: 0 0 12px;
  text-align: center;
  color: #ff8fab;
  font-weight: 700;
}

.role-badge {
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 20px 14px;
  text-align: center;
  background: #0f0f1a;
}

.role-icon {
  margin: 0;
  font-size: 2.4rem;
}

.role-name {
  margin: 10px 0 0;
  font-size: 1.7rem;
}

.role-secret {
  margin: 12px 0 0;
  color: var(--muted);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-header p,
.game-header h2 {
  margin: 0;
}

.timer-block {
  margin-top: 16px;
}

.timer-track {
  height: 14px;
  border-radius: 999px;
  background: #1f1f35;
  overflow: hidden;
}

.timer-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #5a189a, #9b5de5);
  transition: width 0.2s linear;
}

.timer-text {
  margin: 10px 0 0;
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
}

.timer-pulse {
  color: #ff6b6b;
  animation: pulse 0.6s infinite;
}

.phase-content {
  margin-top: 16px;
  border-radius: 12px;
  padding: 14px;
  background: var(--surface-2);
  color: var(--muted);
  min-height: 110px;
}

.phase-pane {
  margin-top: 14px;
}

.pista-card {
  border-radius: 14px;
  padding: 18px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #171728;
  border: 1px solid #2d2d44;
}

.pista-text {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.4;
  font-weight: 700;
}

.pista-reminder {
  border-radius: 12px;
  background: #161626;
  border: 1px solid #2a2a42;
  padding: 10px 12px;
  margin-bottom: 12px;
  color: #d6d6e5;
}

.pista-reminder p {
  margin: 0;
  font-size: 0.95rem;
}

.acao-cta {
  margin: 0 0 12px;
  text-align: center;
  color: #cfc2ff;
  font-weight: 700;
  letter-spacing: 0.05rem;
}

.pista-acao {
  background: #19172a;
}

.pista-mentira {
  background: #241726;
}

.pista-observacao {
  background: #17212a;
}

.pista-vazia {
  background: #1f1f25;
  border-color: #3c3c48;
}

.player-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.player-footer-color {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.motion-title {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.motion-text {
  margin: 0 0 14px;
  color: var(--muted);
}

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #2f2244;
  color: #f5ebff;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #5f3b8a;
  z-index: 30;
  font-weight: 700;
}

.apagao-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Garante que modais com classe .hidden realmente ficam invisíveis */
.apagao-overlay.hidden {
  display: none !important;
}

.apagao-screen {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.apagao-text {
  color: #9a9aa5;
  font-size: 0.9rem;
  letter-spacing: 0.03rem;
}

.apagao-countdown {
  color: #7d7d8f;
  font-size: 0.85rem;
}

.inverse-title {
  margin: 0 0 12px;
  color: #cbb6ff;
}

.inverse-content {
  margin: 0 0 14px;
  color: #ece8ff;
  font-size: 1.15rem;
  line-height: 1.5;
}

.spectator-banner {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #33210f;
  color: #ffd8a8;
  font-weight: 700;
  text-align: center;
}

.declaracao-now {
  background: #17172a;
  border: 1px solid #313154;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.declaracao-me {
  background: #173326;
  border-color: #2b925c;
}

.declaracao-avatar {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  margin: 8px auto;
}

.declaracao-turn-timer {
  margin: 8px 0 0;
  font-size: 2rem;
  font-weight: 800;
}

.declaracao-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vote-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.night-pane {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
}

.objective-banner {
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: linear-gradient(145deg, #1e1a32, #151425);
}

.objective-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.objective-body {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}

.lobby-game-hint {
  margin: 10px 0 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
}

.declaracao-hint,
.vote-hint,
.social-hint {
  margin: 0 0 10px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
}

.social-pane {
  border: 1px solid #2f2a46;
  border-radius: 12px;
  padding: 12px;
  background: #151425;
}

.social-title {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.social-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.roles-reveal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.link-btn {
  margin-top: 10px;
  background: transparent;
  color: #cdb4ff;
  border: 0;
  text-decoration: underline;
  font-size: 0.95rem;
  cursor: pointer;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  isolation: isolate;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

/* A classe .hidden e .tutorial-overlay têm a mesma especificidade.
 * Sem esta regra, o display:flex de .tutorial-overlay vence no cascade e o popup nunca fecha. */
.tutorial-overlay.hidden {
  display: none !important;
}

.tutorial-card {
  position: relative;
  z-index: 10001;
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  background: #141425;
  border: 1px solid #2f2f4f;
  border-radius: 14px;
  padding: 16px;
}

.tutorial-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #2a2a44;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.tutorial-step {
  margin: 0 0 8px;
  color: var(--muted);
}

.tutorial-text {
  margin: 0 0 14px;
  line-height: 1.5;
}

/* Botoes do tutorial: duas colunas com area tocavel ampla (evita taps perdidos em mobile) */
.tutorial-actions {
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

.tutorial-actions .btn {
  position: relative;
  z-index: 2;
  min-height: 52px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(155, 93, 229, 0.35);
}

.help-btn {
  align-self: flex-end;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 0;
  background: #332850;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.confetti-piece {
  position: fixed;
  top: -10px;
  font-size: 14px;
  z-index: 70;
  animation: confettiFall 1.8s ease-in forwards;
  pointer-events: none;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-10px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(105vh) rotate(360deg);
    opacity: 0;
  }
}

:focus-visible {
  outline: 3px solid #cdb4ff;
  outline-offset: 2px;
}

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