/* ═══════════════════════════════════════════════════════
   MAGIC LIFE COUNTER — CSS COMPLETO
   Cole todo este conteúdo dentro do <style> da página
═══════════════════════════════════════════════════════ */

@media (orientation: portrait) and (max-width: 900px) {
  #rotate-warning {
    display: flex !important;
  }
  #game-screen.active,
  #setup-screen:not(.hidden) {
    filter: blur(2px);
    pointer-events: none;
  }
}

/* ── SETUP SCREEN ── */
#setup-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at 50% 0%, #1a0a2e 0%, var(--bg) 70%);
}

.setup-title {
  font-family: "Cinzel Decorative", serif;
  font-size: clamp(1.6rem, 5vw, 3rem);
  text-align: center;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #f0d060, #c89020, #f0d060);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4rem;
  text-shadow: none;
}

.setup-sub {
  color: var(--muted);
  font-family: "IM Fell English", serif;
  font-style: italic;
  font-size: 1rem;
  margin-bottom: 3rem;
  text-align: center;
}

.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.setup-section label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 0.8rem;
  text-transform: uppercase;
}

.player-count-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.count-btn {
  padding: 0.75rem 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.18s;
}

.count-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
}

.count-btn.active {
  border-color: #c89020;
  background: rgba(200, 144, 32, 0.15);
  color: #f0d060;
}

.life-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.life-btn {
  padding: 0.6rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: "Cinzel", serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.18s;
}

.life-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
}

.life-btn.active {
  border-color: #c89020;
  background: rgba(200, 144, 32, 0.15);
  color: #f0d060;
}

.start-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #8b6914, #c89020, #8b6914);
  border: none;
  border-radius: 12px;
  color: #0a0a0f;
  font-family: "Cinzel", serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-transform: uppercase;
  transition:
    opacity 0.2s,
    transform 0.1s;
}

.start-btn:hover {
  opacity: 0.9;
}
.start-btn:active {
  transform: scale(0.98);
}

/* ── GAME SCREEN ── */
/* Quando ativo, cobre 100% da tela por cima do header do site */
#game-screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
  background: var(--bg, #0a0a0f);
}

#game-screen.active {
  display: flex;
}
#setup-screen.hidden {
  display: none;
}

/* Esconde o header do site quando o jogo está ativo */
body.game-active #navbar,
body.game-active header,
body.game-active .navbar {
  display: none !important;
}

/* ── TOPBAR ── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 4px;
  height: 44px;
}

.topbar-title {
  font-family: "Cinzel Decorative", serif;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #f0d060, #c89020);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
  text-align: center;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: "Cinzel", serif;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: all 0.18s;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Landscape mobile ou tela estreita: esconde título, encolhe botões */
@media (max-height: 500px), (max-width: 480px) {
  .topbar-title {
    display: none;
  }
  #topbar {
    gap: 3px;
    padding: 0.3rem 0.4rem;
  }
  .topbar-btn {
    font-size: 0.55rem;
    padding: 0.25rem 0.4rem;
    letter-spacing: 0.02em;
  }
}

/* ── PLAYERS GRID ── */
#players-grid {
  flex: 1;
  display: grid;
  padding: 5px;
  gap: 5px;
  min-height: 0;
}

/* ── GRID LAYOUTS: 2 linhas, players frente a frente ── */
.grid-1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.grid-2 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid-3 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid-5 {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid-6 {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid-7 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.grid-8 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* 3 jogadores: 2 em cima invertidos, 1 embaixo centralizado */
.grid-3 .player-card:nth-child(3) {
  grid-column: 1 / -1;
}

/* ── ROTAÇÃO: cada jogador enfrenta quem está do outro lado ── */
.grid-2 .player-card:nth-child(1) {
  transform: rotate(180deg);
}

.grid-3 .player-card:nth-child(1),
.grid-3 .player-card:nth-child(2) {
  transform: rotate(180deg);
}

.grid-4 .player-card:nth-child(1),
.grid-4 .player-card:nth-child(2) {
  transform: rotate(180deg);
}

.grid-5 .player-card:nth-child(1),
.grid-5 .player-card:nth-child(2),
.grid-5 .player-card:nth-child(3) {
  transform: rotate(180deg);
}

.grid-6 .player-card:nth-child(1),
.grid-6 .player-card:nth-child(2),
.grid-6 .player-card:nth-child(3) {
  transform: rotate(180deg);
}

.grid-7 .player-card:nth-child(1),
.grid-7 .player-card:nth-child(2),
.grid-7 .player-card:nth-child(3),
.grid-7 .player-card:nth-child(4) {
  transform: rotate(180deg);
}

.grid-8 .player-card:nth-child(1),
.grid-8 .player-card:nth-child(2),
.grid-8 .player-card:nth-child(3),
.grid-8 .player-card:nth-child(4) {
  transform: rotate(180deg);
}

/* ── PLAYER CARD ── */
.player-card {
  border-radius: 1rem !important;
  border: 2px solid;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
  transition: opacity 0.3s;
}

.player-card.dead {
  opacity: 0.45;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.player-name-input {
  background: transparent;
  border: none;
  color: inherit;
  font-family: "Cinzel", serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  width: 110px;
  outline: none;
  cursor: pointer;
}

.player-name-input:focus {
  border-bottom: 1px solid currentColor;
  cursor: text;
}

.dead-badge {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  display: none;
}

.player-card.dead .dead-badge {
  display: block;
}

/* ── LIFE SECTION ── */
.life-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
  min-height: 0;
}

.life-tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.life-tap-zone:active {
  background: rgba(0, 0, 0, 0.15);
}
.tap-left {
  left: 0;
}
.tap-right {
  right: 0;
}

.tap-hint {
  font-size: 1.4rem;
  opacity: 0.15;
  pointer-events: none;
}

.life-display {
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.life-number {
  font-size: clamp(1.8rem, 5vw, 5rem);
  font-weight: 900;
  line-height: 1;
}

.life-number.bump {
  animation: bump 0.18s ease;
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.life-label {
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  opacity: 0.5;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── COUNTERS ROW ── */
.counters-row {
  display: flex;
  gap: 6px;
  padding: 0.4rem 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.mini-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 3px 6px;
}

.mini-counter-label {
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  opacity: 0.6;
  text-transform: uppercase;
}

.mini-counter-val {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.mini-counter-btn {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
}

.mini-counter-btn:hover {
  opacity: 1;
}

/* ── COMMANDER DAMAGE ── */
.cmd-section {
  padding: 0.35rem 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  text-align: center;
}

.cmd-label {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  opacity: 0.5;
  text-transform: uppercase;
  margin-bottom: 4px;
  text-align: center;
}

.cmd-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.cmd-entry {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 0.7rem;
}

.cmd-entry-name {
  font-size: 1rem;
  letter-spacing: 0.05em;
  /* opacity: 0.55; */
}

/* ── HISTORY PANEL ── */
#history-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100vw);
  background: #0f0f16;
  border-left: 1px solid var(--border);
  z-index: 200;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
}

#history-panel.open {
  display: flex;
}

.hist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.hist-title {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hist-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.hist-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hist-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid;
  font-size: 0.8rem;
}

.hist-time {
  font-size: 0.6rem;
  opacity: 0.4;
  min-width: 40px;
}
.hist-player {
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}
.hist-action {
  opacity: 0.75;
  flex: 1;
}

.hist-delta {
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 36px;
  text-align: right;
}

.hist-delta.pos {
  color: #4ade80;
}
.hist-delta.neg {
  color: #f87171;
}

.hist-clear {
  margin: 0.6rem 0.8rem;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: "Cinzel", serif;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
  width: calc(100% - 1.6rem);
}

.hist-clear:hover {
  color: #f87171;
  border-color: #f87171;
}

/* ── DRAW PANEL ── */
#draw-panel {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#draw-panel.open {
  display: flex;
}

.dice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  min-width: 280px;
}

.dice-title {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.dice-result {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #f0d060, #c89020);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: transform 0.15s;
}

.dice-result.spin {
  animation: dicespin 0.4s ease-out;
}

@keyframes dicespin {
  0% {
    transform: rotate(-15deg) scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

.dice-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.dice-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 1rem;
}

.dice-roll-btn {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: "Cinzel", serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s;
}

.dice-roll-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.dice-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: "Cinzel", serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.4rem 1rem;
}

/* ── FLOATING DELTA ── */
.float-delta {
  position: fixed;
  pointer-events: none;
  font-family: "Cinzel", serif;
  font-size: 1.8rem;
  font-weight: 900;
  z-index: 500;
  animation: floatUp 0.9s ease-out forwards;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-80px) scale(0.7);
    opacity: 0;
  }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
