* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1b2a;
  color: #e9f1f7;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  touch-action: none;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

/* ---- Cabeçalho: placar + relógio ---- */
#cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 13px;
  flex: 0 0 auto;
  background: #112233;
}

#placar {
  display: flex;
  gap: 10px;
  font-weight: 600;
}

#placar .lado-pessoa { color: #4fa8ff; }
#placar .lado-cpu { color: #ff6b6b; }

#relogio {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ---- Campo ---- */
#area-campo {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

#campo {
  touch-action: none;
  display: block;
}

/* ---- Painel inferior: fôlego + cartas ---- */
#painel {
  flex: 0 0 auto;
  padding: 6px 8px 8px;
  background: #112233;
}

#barra-folego {
  position: relative;
  height: 14px;
  border-radius: 7px;
  background: #1c2e42;
  overflow: hidden;
  margin-bottom: 6px;
}

#barra-folego-preenchida {
  position: absolute;
  inset: 0;
  width: 50%;
  background: linear-gradient(90deg, #6a3dd1, #a06bff);
  transition: width 0.15s linear;
}

#barra-folego-numero {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

#cartas {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

#mao-cartas {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
}

.carta {
  flex: 1 1 0;
  min-width: 0;
  background: #1c2e42;
  background-size: cover;
  background-position: center;
  border: 2px solid #2d4259;
  border-radius: 8px;
  padding: 4px 2px;
  text-align: center;
  font-size: 10px;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* a arte entra como background-image (via JS); o nome e o custo ficam sobre um filete escuro
   gradiente, para continuarem legíveis em qualquer arte (CA6) */
.carta .carta-nome,
.carta .carta-custo {
  position: relative;
  z-index: 1;
  width: 100%;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 4px rgba(0, 0, 0, 0.9);
}

.carta.com-arte .carta-nome {
  background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

.carta.com-arte .carta-custo {
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6));
}

.carta .carta-nome {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carta .carta-custo {
  margin-top: 2px;
  font-weight: 700;
  color: #c9b3ff;
}

.carta.paga { border-color: #4fa8ff; }
.carta.selecionada { background: #2a4a73; border-color: #ffd34f; }
.carta.cara { opacity: 0.55; }

#proxima-carta {
  flex: 0 0 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  opacity: 0.8;
}

#proxima-carta .carta {
  width: 100%;
  transform: scale(0.9);
}

/* ---- Aviso ---- */
#aviso {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  background: rgba(20, 20, 20, 0.92);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s linear;
  z-index: 20;
  max-width: 80%;
  text-align: center;
}

#aviso.visivel { opacity: 1; }

/* ---- Telas inicial e final ---- */
.tela-sobreposta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(13, 27, 42, 0.96);
  z-index: 30;
  text-align: center;
  padding: 16px;
}

.tela-sobreposta.escondida { display: none; }

/* a capa entra como background-image (via JS, quando carrega) por cima de um gradiente escuro
   fixo, para o título e o texto continuarem legíveis (CA6, CA7: sem a arte, fica só o
   gradiente — o background-image completo, gradiente + url(), é montado em interface.js) */
.tela-com-capa {
  background-color: #0d1b2a;
  background-size: cover;
  background-position: center;
}

.tela-sobreposta h1 {
  font-size: 22px;
  margin: 0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.tela-sobreposta p {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
  max-width: 280px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

#resultado-final {
  font-size: 26px;
  font-weight: 800;
}

#coroas-final {
  font-size: 15px;
}

button.botao-principal {
  appearance: none;
  border: none;
  background: linear-gradient(135deg, #4fa8ff, #2d6fe0);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 999px;
  touch-action: manipulation;
}

button.botao-principal:active {
  transform: scale(0.97);
}
