/* Base Reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #000;
  color: #fff;
}

:root {
  --bg: #000;
  --fg: #fff;
  --muted: #bfbfbf;
  --accent: #fff;
  --card-black: #111;
  --card-white: #fff;
  --card-white-text: #000;
  --border: #222;
  --green: #21d07a;
}

.container { max-width: 1100px; margin: 0 auto; padding: 28px; }
.site-header { text-align: center; margin-bottom: 20px; }
.logo { font-size: 40px; margin: 8px 0 0; font-weight: 800; }
.tagline { color: var(--muted); margin: 8px 0; }
.site-footer { text-align: center; color: var(--muted); margin-top: 28px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Menu */
.menu-card { display: grid; gap: 12px; justify-content: center; margin: 48px auto; max-width: 480px; }

/* Buttons */
.btn {
  appearance: none;
  border: 2px solid var(--fg);
  background: transparent;
  color: var(--fg);
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .05s ease, background .2s ease, color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-secondary { border-color: var(--muted); color: var(--muted); }
.btn-disabled { opacity: .5; cursor: not-allowed; border-color: #555; color: #555; }
.btn.small { padding: 6px 10px; font-size: 14px; border-width: 1px; }
#btn-local { margin-bottom: 8px;}
#btn-next-round {
  margin-top: 24px;
}

.actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Forms */
.setup-form { display: grid; gap: 32px }
.field-row { display: grid; gap: 12px; margin-bottom: 36px;}
.names-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.text-input, input[type="number"] {
  width: 100%;
  border: 2px solid var(--border);
  background: #0a0a0a;
  color: var(--fg);
  padding: 10px 12px;
  border-radius: 8px;
}
.text-input::placeholder { color: #777; }

/* Topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 16px; }
.round-info { text-align: center; color: var(--muted); }
.czar-info { text-align: right; color: var(--muted); }

/* Board */
.board { display: grid; gap: 16px; }
.board.board-spaced { gap: 24px; }
.black-card {
  background: var(--card-black);
  color: var(--fg);
  border-radius: 12px;
  padding: 24px;
  font-size: 24px;
  font-weight: 800;
  border: 2px solid var(--border);
}

.white-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.white-card {
  background: var(--card-white);
  color: var(--card-white-text);
  border-radius: 12px;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  min-height: 110px;
  display: flex;
  align-items: center;
  border: 3px solid #000;
  cursor: pointer;
}
.white-card:hover { outline: 3px solid #fff; }
.white-card.disabled { opacity: .6; cursor: default; }
.white-card.selected { outline: 3px solid var(--green); box-shadow: 0 0 0 3px rgba(33,208,122,0.3) inset; }

.prompt { padding-top: 24px; padding-bottom: 24px; }
.stage .prompt { font-size: 18px; color: var(--muted); }
.submission-form { display: flex; gap: 8px; margin-top: 12px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 16px; }

/* Status & Scoreboard */
.status { display: grid; gap: 14px; }
.status-text { padding-top: 36px; color: var(--muted); }
.scoreboard { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { /* legacy */
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
}
.badge.win { border-color: var(--fg); color: var(--fg); }

#player-names {
  margin-top: 16px;
  margin-bottom: 16px;
}

/* Player tiles */
.player-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}
.player-tile {
  background: #0a0a0a;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "avatar name"
    "avatar score"
    "avatar meta";
  gap: 8px 10px;
  align-items: center;
  min-height: 110px;
}
.setup-avatar, .setup-avatar, .player-tile .avatar {
  grid-area: avatar;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #222;
  background: #111;
}
.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Prevent setup avatar from shrinking in flex rows */
.setup-avatar {
  flex: 0 0 56px;
}
.player-tile .name { grid-area: name; font-weight: 800; }
.player-tile .meta { grid-area: meta; color: var(--muted); font-size: 14px; }
.player-tile .score { grid-area: score; font-size: 22px; font-weight: 800; }
.player-tiles.compact { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
.player-tiles.compact .player-tile { padding: 10px; min-height: 90px; }
.player-tiles.compact .player-tile .avatar { width: 44px; height: 44px; }

/* Results podium winner flair remains */
.player-tiles.podium .player-tile.winner {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15) inset;
  transform: translateY(-4px);
}

/* Hand grid modifier */
.hand-grid .white-card { min-height: 90px; }

/* Modal */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }
.modal-card {
  position: relative;
  background: #0a0a0a;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  width: min(820px, 94vw);
  z-index: 1;
  display: grid;
  gap: 14px;
}
.modal-header { display: grid; gap: 4px; }
.custom-deck-form textarea,
.custom-deck-form input[type="text"] {
  width: 100%;
  background: #0f0f0f;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: #fff;
  font-family: inherit;
}
.custom-deck-form textarea { min-height: 120px; }
#custom-deck-title { margin-bottom: -6px; }
#round-modal-title { font-size: 32px; text-align: center;}
.round-winner { font-size: 20px; font-weight: 800; margin-top: 36px; margin-bottom: 4px; }
.vote-breakdown { list-style: none; padding: 0; margin: 4px 0 8px; display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr);
}
.vote-breakdown.tiles li {
  background: #0a0a0a;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 6px;
}
.vote-breakdown .title { font-weight: 800; }
.vote-breakdown .vote-meta { color: var(--muted); font-size: 14px; }

/* Confetti */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute;
  width: 8px; height: 12px;
  background: #fff;
  top: -20px;
  animation: fall 2.2s linear forwards;
  transform: rotate(0deg);
}
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(120vh) rotate(360deg); opacity: 0; }
}

/* Results */
.results-banner {
  margin: 14px 0 14px;
  padding: 14px 16px;
  background: #0a0a0a;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}
.player-tiles.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 12px;
}
/* Make the winner pop a bit more */
.player-tiles.podium .player-tile.winner {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15) inset;
  transform: translateY(-4px);
}
.player-tiles.podium .player-tile .place {
  color: var(--muted);
  font-size: 13px;
}

.results-list { list-style: decimal; padding-left: 20px; }
.results-list li { margin: 6px 0; }

#results-tiles {
 margin-top: 24px;
 margin-bottom: 32px;
}

/* Deck selection */
.deck-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.deck-tile {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #0a0a0a;
  cursor: pointer;
  display: grid;
  gap: 6px;
  height: 5rem;
}
.deck-tile .deck-title { font-weight: 800; }
.deck-tile .deck-meta { color: var(--muted); font-size: 14px; }
.deck-tile .deck-custom-create { 
  color: var(--bg); 
  background-color: var(--accent); 
  padding: 12px; 
  border-radius: 12px; 
  font-size: 14px; 
  text-align: center;
}
.deck-tile.selected { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.12) inset; }
.deck-tile.create {
  border-style: dashed;
  background: #0d0d0d;
  text-align: left;
}
.deck-tile .deck-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.deck-tile .tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 12px;
}
.deck-edit-btn, .deck-delete-btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  width: 20%; 
  justify-self: center;
  margin: 0 auto;
}
.deck-edit-btn:hover, .deck-edit-btn:hover { background: rgba(255,255,255,0.12); }

/* Disabled Start button visual when no deck chosen */
#btn-start-menu:disabled { opacity: .5; cursor: not-allowed; }

/* Turn gate overlay */
.turn-gate[hidden] { display: none; }
.turn-gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1100;
}
.turn-gate::before {
  content: "";
  position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(2px);
}
.turn-card {
  position: relative;
  z-index: 1;
  background: #0a0a0a;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: min(520px, 92vw);
  text-align: center;
  display: grid;
  gap: 12px;
}
.turn-text { font-size: 20px; font-weight: 800; }

/* Responsive */
@media (max-width: 520px) {
  .logo { font-size: 32px; }
  .black-card { font-size: 20px; }
}
