*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black: #111;
  --white: #f9f9f9;
  --gray-dark: #1e1e1e;
  --gray-mid: #2a2a2a;
  --gray-border: #333;
  --gray-text: #888;
  --gold: #f0c040;
  --green: #4caf50;
  --red: #cc3333;
  --radius: 12px;
  --font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  min-height: 100vh;
  padding: 20px;
}

/* ── Screens ── */
.screen { display: none; max-width: 820px; margin: 0 auto; }
.screen.active { display: block; }
.hidden { display: none !important; }
.phase { margin-top: 16px; }

/* ── Home ── */
#screen-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90vh;
  gap: 28px;
}
#screen-home.active { display: flex; }

.logo { text-align: center; }
.logo h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1.1;
}
.subtitle { color: var(--gray-text); font-style: italic; margin-top: 10px; font-size: 1rem; }

.card-form {
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

input[type="text"],
input[type="password"] {
  background: var(--gray-mid);
  border: 1px solid #444;
  border-radius: 8px;
  color: var(--white);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  padding: 12px 16px;
  transition: border-color 0.2s;
  width: 100%;
}
input[type="text"]:focus,
input[type="password"]:focus { border-color: #888; }
input[type="text"]::placeholder,
input[type="password"]::placeholder { color: #555; }

.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 12px 24px;
  text-transform: uppercase;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--white); color: var(--black); }
.btn-secondary { background: #2a2a2a; border: 1px solid #555; color: var(--white); }
.btn-large { font-size: 1.05rem; padding: 15px 32px; width: 100%; }

.divider {
  align-items: center;
  color: #444;
  display: flex;
  font-size: 0.8rem;
  gap: 10px;
}
.divider::before, .divider::after { background: var(--gray-border); content: ''; flex: 1; height: 1px; }

.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 3px; }
.join-row .btn { flex-shrink: 0; }

.error-msg { color: var(--red); font-size: 0.85rem; min-height: 1.1em; }

.btn-manage-link {
  background: none;
  border: 1px solid #333;
  border-radius: 8px;
  color: #666;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 8px 18px;
  transition: color 0.2s, border-color 0.2s;
}
.btn-manage-link:hover { border-color: #555; color: #aaa; }

/* ── Lobby ── */
#screen-lobby { padding-top: 16px; }

.lobby-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 6px;
}
.lobby-header h2 { font-size: 1.5rem; }

.room-code-display {
  align-items: center;
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 8px 16px;
}
.room-code-display strong { color: var(--gold); font-size: 1.4rem; letter-spacing: 4px; }

.btn-copy {
  background: none;
  border: 1px solid #444;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 3px 8px;
}
.btn-copy:hover { background: #333; }

.lobby-hint { color: #555; font-size: 0.85rem; margin-bottom: 20px; }

.player-list-container { margin-bottom: 20px; }
.player-list-container h3 {
  color: #aaa;
  font-size: 0.85rem;
  letter-spacing: 1px;
  margin-bottom: 10px;
  text-transform: uppercase;
}
#player-list { display: flex; flex-direction: column; gap: 8px; list-style: none; }
#player-list li {
  align-items: center;
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
}
.player-badge {
  background: #2a2a2a;
  border-radius: 4px;
  color: #777;
  font-size: 0.75rem;
  padding: 2px 8px;
}
.player-badge.host { background: #2a2a14; color: var(--gold); }

.rounds-label { color: #aaa; font-size: 0.9rem; margin-bottom: 8px; }
.round-options { display: flex; gap: 10px; margin-bottom: 12px; }
.btn-round {
  background: var(--gray-mid);
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  color: #777;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 10px 22px;
  transition: all 0.15s;
}
.btn-round.active { border-color: var(--white); color: var(--white); }
.hint { color: #555; font-size: 0.82rem; margin-top: 8px; text-align: center; }
.guest-waiting { color: #666; font-size: 0.95rem; margin-top: 32px; text-align: center; }

/* ── Game Header ── */
.game-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 14px;
}
.round-info {
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 6px 14px;
  text-transform: uppercase;
}
.czar-badge {
  background: #2a2a14;
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 14px;
}
.scores-mini { display: flex; flex-wrap: wrap; gap: 6px; }
.score-chip {
  background: #222;
  border-radius: 4px;
  font-size: 0.75rem;
  padding: 4px 10px;
  white-space: nowrap;
}
.score-chip.leading { background: #2a2a14; color: var(--gold); }

/* ── Black Card ── */
.black-card {
  background: var(--black);
  border: 2px solid var(--white);
  border-radius: var(--radius);
  margin-bottom: 16px;
  min-height: 120px;
  padding: 20px 24px 40px;
  position: relative;
}
.black-card-text { font-size: 1.15rem; font-weight: 700; line-height: 1.6; }
.black-card-text .blank {
  border-bottom: 2px solid var(--white);
  display: inline-block;
  min-width: 80px;
  text-align: center;
}
.card-pick-label {
  bottom: 12px;
  color: #666;
  font-size: 0.7rem;
  letter-spacing: 1px;
  position: absolute;
  right: 16px;
  text-transform: uppercase;
}

/* ── Progress Bar ── */
.progress-bar {
  align-items: center;
  background: var(--gray-dark);
  border-radius: 8px;
  color: #888;
  display: flex;
  font-size: 0.85rem;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 10px 16px;
}
.progress-dots { display: flex; gap: 6px; }
.progress-dot {
  background: #333;
  border-radius: 50%;
  height: 10px;
  transition: background 0.3s;
  width: 10px;
}
.progress-dot.done { background: var(--green); }

/* ── Hand Cards ── */
.hand-title { color: #bbb; font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; }
.white-cards-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  margin-bottom: 14px;
}
.white-card {
  background: var(--white);
  border: 3px solid transparent;
  border-radius: 10px;
  color: var(--black);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  min-height: 88px;
  padding: 12px;
  position: relative;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.white-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.6); transform: translateY(-3px); }
.white-card.selected { background: #fffbe6; border-color: var(--gold); }
.white-card.selected::after {
  color: var(--gold);
  content: '✓';
  font-size: 1.1rem;
  font-weight: 900;
  position: absolute;
  right: 9px;
  top: 6px;
}
.white-card.disabled { cursor: not-allowed; opacity: 0.4; }

/* ── Waiting Box ── */
.waiting-box {
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
}
.waiting-title { color: var(--white); font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.waiting-sub { color: #888; font-size: 0.9rem; margin-bottom: 20px; }
.small { color: #666; font-size: 0.82rem; margin-top: 10px; }

.spinner {
  animation: spin 1s linear infinite;
  border: 3px solid #333;
  border-radius: 50%;
  border-top-color: var(--white);
  height: 40px;
  margin: 16px auto 0;
  width: 40px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Voting ── */
.vote-title { color: #bbb; font-size: 0.9rem; font-weight: 600; margin-bottom: 12px; }
.submissions-list { display: flex; flex-direction: column; gap: 10px; }
.submission-card {
  background: var(--white);
  border: 3px solid transparent;
  border-radius: 10px;
  color: var(--black);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.95rem;
  font-weight: 600;
  gap: 8px;
  padding: 14px 16px;
  transition: border-color 0.15s, transform 0.12s;
}
.submission-card.votable {
  cursor: pointer;
}
.submission-card.votable:hover { border-color: var(--gold); transform: translateX(4px); }
.submission-card.face-down {
  align-items: center;
  background: #1a1a1a;
  border: 3px dashed #333;
  color: #555;
  cursor: default;
  justify-content: center;
  min-height: 54px;
}
.submission-card.face-down.flippable {
  border-color: #555;
  cursor: pointer;
}
.submission-card.face-down.flippable:hover {
  background: #222;
  border-color: #aaa;
  color: #aaa;
}
.flip-hint { font-size: 0.88rem; letter-spacing: 0.5px; pointer-events: none; user-select: none; }
.sub-text { background: #efefef; border-radius: 6px; padding: 3px 10px; }

/* ── Round Result ── */
.result-box {
  background: var(--gray-dark);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 24px;
  text-align: center;
}
.result-label { color: #666; font-size: 0.75rem; letter-spacing: 2px; margin-bottom: 6px; text-transform: uppercase; }
.result-box h2 { color: var(--gold); font-size: 1.6rem; margin-bottom: 16px; }
.result-cards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.result-white-card {
  background: var(--white);
  border-radius: 8px;
  color: var(--black);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
}

.scores-table {
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.score-row {
  align-items: center;
  border-bottom: 1px solid #252525;
  display: flex;
  font-size: 0.92rem;
  justify-content: space-between;
  padding: 10px 16px;
}
.score-row:last-child { border-bottom: none; }
.score-row.winner { background: #222214; color: var(--gold); }
.score-medal { font-size: 1rem; margin-right: 8px; }
.score-pts { font-weight: 700; }

.result-actions { text-align: center; }
.waiting-host { color: #555; font-size: 0.9rem; margin-top: 10px; }

/* ── Game Over ── */
#screen-gameover { padding: 40px 0; text-align: center; }
#screen-gameover h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 6px; }
.gameover-sub { color: var(--gray-text); margin-bottom: 32px; }
.final-scores {
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  margin: 0 auto 28px;
  max-width: 440px;
  overflow: hidden;
}
.final-row {
  align-items: center;
  border-bottom: 1px solid #252525;
  display: flex;
  justify-content: space-between;
  padding: 14px 20px;
}
.final-row:first-child { background: #222214; }
.final-row:last-child { border-bottom: none; }
.final-left { align-items: center; display: flex; }
.final-medal { font-size: 1.3rem; margin-right: 10px; width: 28px; }
.final-name { font-size: 1rem; font-weight: 700; }
.final-row:first-child .final-name { color: var(--gold); font-size: 1.1rem; }
.final-pts { color: #aaa; font-size: 0.9rem; font-weight: 700; }

/* ── Gestor de Cartas ── */
#screen-cards { padding-top: 8px; }

.manager-header {
  align-items: center;
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.manager-header h2 { font-size: 1.4rem; flex: 1; }

.btn-back {
  background: none;
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  color: #aaa;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 8px 14px;
  transition: background 0.15s;
}
.btn-back:hover { background: #222; }

.card-counts {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  color: #666;
}
.card-counts span { background: #1e1e1e; border: 1px solid #333; border-radius: 6px; padding: 4px 10px; }

/* Pestañas */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--gray-border);
  padding-bottom: 0;
}
.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #666;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 20px;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #aaa; }
.tab.active { border-bottom-color: var(--white); color: var(--white); }

.tab-content { display: block; }
.tab-content.hidden { display: none !important; }

/* Formulario agregar */
.add-form {
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 16px;
}
.add-form-row { display: flex; gap: 10px; margin-bottom: 8px; }
.add-form-row input { flex: 1; }
.add-form-row .btn { flex-shrink: 0; padding: 12px 20px; }
.add-hint { color: #555; font-size: 0.82rem; }

/* Lista de cartas */
.cards-list { display: flex; flex-direction: column; gap: 8px; }

.card-item {
  align-items: center;
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: 10px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 14px;
  transition: border-color 0.15s;
}
.card-item:hover { border-color: #444; }

.card-item-text { flex: 1; font-size: 0.92rem; line-height: 1.4; }
.card-item-text.black { color: var(--white); }
.card-item-text.white { color: #ccc; }

.card-item-right { align-items: center; display: flex; gap: 8px; flex-shrink: 0; }

.pick-badge {
  background: #333;
  border-radius: 4px;
  color: #888;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 7px;
  text-transform: uppercase;
}
.pick-badge.pick2 { background: #2a1a2a; color: #c080d0; }

.btn-delete {
  background: none;
  border: 1px solid #3a2020;
  border-radius: 6px;
  color: #664444;
  cursor: pointer;
  font-size: 0.95rem;
  height: 30px;
  line-height: 1;
  padding: 0 10px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-delete:hover { background: #3a1010; border-color: var(--red); color: var(--red); }

.empty-state {
  color: #555;
  font-size: 0.9rem;
  padding: 30px;
  text-align: center;
}

/* ── Login Admin ── */
#screen-login {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 90vh;
}
#screen-login.active { display: flex; }

.login-box {
  background: var(--gray-dark);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.login-box h2 { font-size: 1.4rem; }
.login-sub { color: var(--gray-text); font-size: 0.88rem; line-height: 1.5; }

.admin-bar {
  align-items: center;
  background: #142014;
  border: 1px solid #2a4a2a;
  border-radius: 8px;
  color: var(--green);
  display: flex;
  font-size: 0.85rem;
  font-weight: 700;
  gap: 12px;
  justify-content: space-between;
  max-width: 400px;
  padding: 8px 16px;
  width: 100%;
}
.admin-bar.hidden { display: none !important; }

.btn-logout {
  background: none;
  border: 1px solid #2a4a2a;
  border-radius: 6px;
  color: #777;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── Responsive ── */
@media (max-width: 520px) {
  body { padding: 12px; }
  .white-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .black-card-text { font-size: 1rem; }
  .lobby-header { flex-direction: column; align-items: flex-start; }
  .card-form { padding: 24px 18px; }
  .add-form-row { flex-direction: column; }
  .add-form-row .btn { width: 100%; }
}
