* {
  box-sizing: border-box;
  /* sem seleção de texto / destaque de toque: arrastar peças no jogo
     não deve acionar o overlay de seleção do navegador */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; }

body {
  margin: 0;
  background: #06080f;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color: #e8ecf6;
  touch-action: manipulation;
  display: flex;
}

/* celular: tela cheia; desktop: coluna retrato centralizada */
.wrap {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
@media (min-width: 700px) {
  body { align-items: center; justify-content: center; }
  .wrap {
    width: min(430px, 100vw);
    height: min(100dvh, 932px);
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid #232e4a;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  }
}

/* modo thumbnail (?thumb=1): cena de divulgação em paisagem, sem moldura */
body.thumb { align-items: stretch; justify-content: stretch; }
body.thumb .wrap {
  width: 100%;
  height: 100dvh;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
body.thumb .hud { display: none; }

.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: none;
  background: #06080f;
  /* o tabuleiro não desce até a barra de gestos do sistema */
  padding-bottom: env(safe-area-inset-bottom);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  /* acima do overlay: o botão de som continua clicável nos menus */
  z-index: 4;
  display: flex;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 18px 0;
  font-weight: 700;
  font-size: 17px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.hud .record {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
}
.hud .record-label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.65;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* progresso até o próximo marco (24h, 168h, …) */
.ms {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}
.ms-track {
  width: 84px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.ms-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff7a1a, #ffce54);
  transition: width 0.35s ease;
}
.ms-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
}

.mute {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  font-size: 16px;
  line-height: 1;
  color: #fff;
  background: rgba(13, 18, 32, 0.55);
  border: 1px solid #2a3550;
  border-radius: 999px;
  cursor: pointer;
}
.mute:active { transform: translateY(1px); }

/* vinheta cinematográfica por cima do jogo */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(0, 0, 0, 0.42));
}

.floater {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  color: #ffce54;
  font-weight: 800;
  font-size: 17px;
  text-shadow: 0 1px 8px rgba(255, 140, 0, 0.65);
  pointer-events: none;
  white-space: nowrap;
  animation: floatUp 0.9s ease-out forwards;
}
.floater.gold {
  color: #ffe066;
  font-size: 19px;
  text-shadow: 0 1px 10px rgba(255, 200, 0, 0.8);
}
.floater.big {
  color: #fff1c9;
  font-size: 22px;
  text-shadow: 0 1px 12px rgba(255, 170, 40, 0.9);
}
@keyframes floatUp {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -52px; }
}

/* faixa de marco (1 dia, 1 semana…): entra, respira e some */
.banner {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  padding: 12px 26px;
  border-radius: 999px;
  background: rgba(12, 16, 30, 0.82);
  border: 1px solid rgba(255, 140, 26, 0.55);
  box-shadow: 0 8px 40px rgba(255, 122, 26, 0.35);
  color: #ffe1b0;
  font-weight: 800;
  font-size: clamp(17px, 5vw, 22px);
  white-space: nowrap;
  pointer-events: none;
  animation: bannerPop 2.2s ease forwards;
}
@keyframes bannerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(0.94); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px calc(20px + env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
  background: rgba(8, 11, 20, 0.74);
  backdrop-filter: blur(4px);
}
.overlay.visible { display: flex; }

.overlay h1 {
  margin: 0 0 4px;
  font-size: clamp(30px, 9vw, 44px);
  letter-spacing: -0.5px;
}
.overlay h1 .accent { color: #ff8c1a; }
.overlay p { margin: 2px 0; line-height: 1.5; }
.overlay .big { font-size: 19px; }
.overlay .small { font-size: 14px; opacity: 0.7; }

.btn {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #1a0f05;
  background: linear-gradient(180deg, #ffb347, #ff7a1a);
  border: none;
  border-radius: 999px;
  padding: 15px 44px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 122, 26, 0.4);
}
.btn:active { transform: translateY(1px); }

a.btn {
  text-decoration: none;
  display: inline-block;
}

.btn-ghost {
  background: transparent;
  color: #e8ecf6;
  box-shadow: none;
  border: 1.5px solid #3a4666;
  font-size: 16px;
  padding: 12px 36px;
  margin-top: 2px;
}

.overlay .cta {
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.5;
  margin-top: 12px;
  max-width: 300px;
}
.overlay .lead {
  font-size: 15.5px;
  opacity: 0.86;
  max-width: 300px;
}

/* seleção de modo: dois cartões que explicam a diferença */
.modes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 344px;
  margin-top: 4px;
}
.mode-card {
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  width: 100%;
  padding: 13px 16px;
  border-radius: 18px;
  border: 1.5px solid #2a3550;
  background: rgba(18, 24, 40, 0.72);
  color: #e8ecf6;
  cursor: pointer;
  transition: transform 0.06s ease, border-color 0.2s ease;
}
.mode-card:active { transform: translateY(1px); }
/* modo recomendado (relaxado): moldura em brasa */
.mode-card.reco {
  border-color: rgba(255, 138, 26, 0.5);
  background: linear-gradient(180deg, rgba(255, 122, 26, 0.15), rgba(18, 24, 40, 0.72));
  box-shadow: 0 6px 22px rgba(255, 122, 26, 0.16);
}
.mode-emoji {
  font-size: 26px;
  line-height: 1;
  flex: 0 0 auto;
}
.mode-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mode-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.mode-name .tag {
  font-size: 10.5px;
  font-weight: 700;
  color: #ffce54;
  border: 1px solid rgba(255, 206, 84, 0.4);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.mode-sub {
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0.74;
  line-height: 1.4;
}

/* link discreto "Como jogar" */
.btn-link {
  margin-top: 2px;
  background: none;
  border: none;
  color: #a2b2d2;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
}
.btn-link:active { transform: translateY(1px); }

/* tutorial "Como jogar" */
.mini-demo {
  display: flex;
  gap: 5px;
  margin: 2px 0 2px;
}
.mini-demo i {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  background: linear-gradient(180deg, #ffd28f, #ff9a3d 46%, #c76410);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 2px 6px rgba(255, 122, 26, 0.25);
}
.mini-demo i.ghost {
  background: none;
  border: 1.6px dashed rgba(255, 206, 84, 0.65);
  box-shadow: none;
}
.help-steps {
  text-align: left;
  max-width: 336px;
  margin: 2px 0;
  padding-left: 24px;
  line-height: 1.45;
  font-size: 15px;
}
.help-steps li { margin: 8px 0; }
.help-steps li::marker {
  color: #ff8c1a;
  font-weight: 800;
}
.help-steps b { color: #ffe1b0; font-weight: 700; }
