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

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-input: #1a1a1a;
  --accent: #fff;
  --accent-dim: #888;
  --danger: #e53935;
  --success: #4caf50;
  --border: #2a2a2a;
  --radius: 8px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--accent);
  -webkit-tap-highlight-color: transparent;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 20px;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3 {
  font-weight: 500;
  letter-spacing: -0.02em;
}

.logo {
  font-size: 1.75rem;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 600;
}

.tagline {
  text-align: center;
  color: var(--accent-dim);
  font-size: 0.9rem;
  margin-bottom: 60px;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.8;
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.buttons-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent-dim);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 24px;
  text-align: left;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  transition: border-color 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.form-group input::placeholder {
  color: #444;
}

.code-input {
  text-transform: uppercase;
  text-align: center;
  font-size: 1.5rem !important;
  letter-spacing: 12px;
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* Game Code Display */
.game-code-display {
  text-align: center;
  padding: 32px 20px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.game-code-display .label {
  display: block;
  color: var(--accent-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.game-code-display .code {
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: 12px;
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* Section titles */
h2 {
  font-size: 1rem;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

h3 {
  font-size: 0.85rem;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Player List */
.player-list {
  list-style: none;
  margin-bottom: 32px;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.player-list li:last-child {
  border-bottom: none;
}

.player-list li.host::after {
  content: 'HOST';
  font-size: 0.65rem;
  padding: 4px 8px;
  background: var(--bg-input);
  border-radius: 4px;
  color: var(--accent-dim);
  letter-spacing: 0.05em;
}

.player-list li.eliminated {
  display: none;
}

.player-list li.disconnected {
  opacity: 0.4;
}

.player-list li.disconnected::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  margin-right: 10px;
}

.player-list li.connected::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 10px;
}

/* Impostor Selection */
.impostor-selection {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.impostor-selection label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 0.95rem;
}

.impostor-selection label:has(input:checked) {
  border-color: var(--danger);
  background: rgba(229, 57, 53, 0.1);
}

.impostor-selection input {
  width: 18px;
  height: 18px;
  accent-color: var(--danger);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 32px 0;
}

/* Waiting Message */
.waiting-message {
  text-align: center;
  padding: 48px 20px;
  color: var(--accent-dim);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.waiting-message p {
  font-size: 0.9rem;
}

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Role Display */
.role-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 20px 0;
}

.role-display .category {
  color: var(--accent-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 32px;
}

.role-display .word {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.role-display .role-card {
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.15s;
  text-align: center;
}

.role-display .role-card .tap-hint {
  color: var(--accent-dim);
  font-size: 0.9rem;
}

.role-display .role-card .role-content {
  display: none;
}

.role-display .role-card.revealed {
  background: var(--bg-input);
  border-color: var(--accent-dim);
}

.role-display .role-card.revealed .tap-hint {
  display: none;
}

.role-display .role-card.revealed .role-content {
  display: block;
}

.role-display .role-card .role-content .the-word {
  font-size: 2rem;
  font-weight: 600;
}

.role-display .role-card.revealed.impostor {
  border-color: var(--danger);
}

.role-display .role-card .role-content .impostor-label {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--danger);
}

.role-display .hint {
  color: var(--accent-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

.role-display .eliminated-notice {
  text-align: center;
}

.role-display .eliminated-notice h2 {
  font-size: 1.25rem;
  color: var(--accent);
  margin-bottom: 16px;
  text-transform: none;
}

/* Palabra oculta - mantener pulsado */
.role-display .word-hidden {
  font-size: 1.5rem;
  font-weight: 500;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.15s;
}

.role-display .word-hidden .hidden-text {
  color: var(--accent-dim);
  font-size: 0.9rem;
}

.role-display .word-hidden.revealed {
  background: var(--bg-input);
  border-color: var(--accent-dim);
}

.role-display .word-hidden.revealed .hidden-text {
  display: none;
}

.role-display .word-hidden.revealed .actual-word {
  display: block;
}

.role-display .word-hidden .actual-word {
  display: none;
  font-size: 2rem;
  font-weight: 600;
}

/* Host game info */
.host-game-info {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.host-game-info p {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--accent-dim);
}

.host-game-info p:last-child {
  margin-bottom: 0;
}

.host-game-info span {
  color: var(--accent);
  font-weight: 500;
}

.host-game-info .impostors-display span {
  color: var(--danger);
}

/* Live votes */
.live-votes {
  margin-bottom: 24px;
}

.live-votes .vote-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.live-votes .vote-entry:last-child {
  border-bottom: none;
}

.live-votes .vote-entry .voter {
  color: var(--accent-dim);
}

.live-votes .vote-entry .voted-for {
  color: var(--accent);
}

.live-votes .vote-entry .pending {
  color: var(--accent-dim);
  font-style: italic;
}

.live-votes .vote-count {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.live-votes .vote-count-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9rem;
}

.live-votes .vote-count-item .name {
  color: var(--accent);
}

.live-votes .vote-count-item .count {
  color: var(--accent-dim);
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* Voting players section */
.voting-players-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.voting-players-section h4 {
  font-size: 0.75rem;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.player-list.compact li {
  padding: 10px 0;
  font-size: 0.85rem;
}

.player-list li.voted::after {
  content: 'votó';
  font-size: 0.65rem;
  padding: 3px 6px;
  background: var(--bg-input);
  border-radius: 4px;
  color: var(--success);
  letter-spacing: 0.02em;
  margin-left: auto;
}

.player-list li.pending::after {
  content: 'pendiente';
  font-size: 0.65rem;
  padding: 3px 6px;
  background: var(--bg-input);
  border-radius: 4px;
  color: var(--accent-dim);
  letter-spacing: 0.02em;
  margin-left: auto;
}

.eliminated-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.eliminated-section h4 {
  font-size: 0.7rem;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  opacity: 0.6;
}

.eliminated-section .player-list li {
  opacity: 0.4;
  text-decoration: line-through;
}

/* Puntuación */
.player-list li .score {
  margin-left: auto;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  color: var(--accent-dim);
}

.scoreboard {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.scoreboard h4 {
  font-size: 0.75rem;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.scoreboard-list {
  list-style: none;
}

.scoreboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.scoreboard-list li:last-child {
  border-bottom: none;
}

.scoreboard-list li .player-name {
  color: var(--accent);
}

.scoreboard-list li .player-score {
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--accent-dim);
}

.scoreboard-list li.top-score .player-score {
  color: var(--success);
}

.points-breakdown {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.points-breakdown .point-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: var(--accent-dim);
}

.points-breakdown .point-item .pts {
  color: var(--success);
}

.points-breakdown .point-item .pts.negative {
  color: var(--danger);
}

/* Host Controls */
.host-controls {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.host-controls.hidden {
  display: none;
}

/* Voting */
.voting-header {
  text-align: center;
  margin-bottom: 32px;
}

.voting-header h2 {
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 8px;
}

.voting-instruction {
  color: var(--accent-dim);
  font-size: 0.85rem;
}

.voting-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.voting-options button {
  padding: 16px;
  font-size: 0.95rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.voting-options button:active {
  opacity: 0.8;
}

.voting-options button.selected {
  border-color: var(--accent);
  background: var(--bg-card);
}

.voting-options button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.vote-status {
  text-align: center;
  padding: 24px;
  color: var(--accent-dim);
}

.vote-status.hidden {
  display: none;
}

#vote-progress {
  text-align: center;
  color: var(--accent-dim);
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* Results */
.results-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.results-content .result-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.results-content .eliminated-player {
  font-size: 1.5rem;
  font-weight: 500;
  margin: 24px 0;
  padding: 24px;
  border-radius: var(--radius);
}

.results-content .eliminated-player.impostor {
  background: rgba(229, 57, 53, 0.1);
  border: 1px solid rgba(229, 57, 53, 0.3);
}

.results-content .eliminated-player.innocent {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.results-content .eliminated-player small {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--accent-dim);
}

.results-content .vote-breakdown {
  margin-top: 32px;
}

.results-content .vote-breakdown h4 {
  color: var(--accent-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.results-content .vote-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.results-content .vote-item:last-child {
  border-bottom: none;
}

.results-content .vote-item .count {
  color: var(--accent-dim);
  font-family: 'SF Mono', 'Consolas', monospace;
}

.revealed-info {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.revealed-info.hidden {
  display: none;
}

.revealed-info h4 {
  color: var(--accent-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.revealed-info .revealed-word {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.revealed-info .revealed-impostors {
  color: var(--danger);
  font-size: 0.85rem;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 20px;
  right: 20px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 0.9rem;
  z-index: 1000;
  text-align: center;
  animation: slideUp 0.2s ease;
}

.toast.hidden {
  display: none;
}

.toast.error {
  border-color: var(--danger);
  background: rgba(229, 57, 53, 0.1);
}

.toast.success {
  border-color: var(--success);
  background: rgba(76, 175, 80, 0.1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Game End */
.game-end-overlay {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 24px;
}

.game-end-overlay h2 {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 16px;
  text-transform: none;
}

.game-end-overlay.impostors-win h2 {
  color: var(--danger);
}

.game-end-overlay.innocents-win h2 {
  color: var(--success);
}

.game-end-overlay > p {
  color: var(--accent-dim);
  font-size: 0.9rem;
}

.game-end-overlay .game-end-details {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.game-end-overlay .game-end-details p {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--accent-dim);
}

.game-end-overlay .game-end-details strong {
  color: var(--accent);
}

.game-end-overlay .game-end-details .impostors-reveal strong {
  color: var(--danger);
}

/* Voting player status */
.voting-options button.disconnected {
  opacity: 0.4;
  position: relative;
}

.voting-options button.disconnected::after {
  content: 'desconectado';
  position: absolute;
  right: 16px;
  font-size: 0.7rem;
  color: var(--danger);
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .screen {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
