:root {
  --bg-color: #030712;
  --card-bg: rgba(15, 23, 42, 0.8);
  --accent-active: #38bdf8;
  --accent-dim: #0ea5e9;
  --accent-cyan: #22d3ee;
  --accent-red: #f43f5e;
  --accent-gold: #fbbf24;
  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --vh: 1vh;
}

/* TEMA CÓMICO */
body.mode-comico {
  --accent-active: #d946ef; /* Magenta */
  --accent-dim: #a21caf;
  --accent-cyan: #fbbf24; /* Amarillo */
  --accent-gold: #f59e0b;
  --card-bg: rgba(46, 16, 101, 0.4);
}

/* RESET & BASE */
/* RESET & BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, select { user-select: auto; }

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow: hidden;
  height: 100dvh;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1); /* Transición de tema */
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(var(--accent-rgb, 56, 189, 248), 0.08) 0%, transparent 50%);
}

body.mode-detective {
  --accent-active: #38bdf8;
  --accent-rgb: 56, 189, 248;
}

body.mode-comico {
  --bg-color: #1e0b36;
  --card-bg: rgba(88, 28, 135, 0.2);
  --accent-active: #f472b6; /* Rosa */
  --accent-cyan: #fbbf24;   /* Oro */
  --accent-rgb: 244, 114, 182;
}

/* APP CONTAINER */
.app-container {
  max-width: 500px;
  margin: 0 auto;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  box-shadow: 0 0 100px rgba(0,0,0,0.5);
}

/* HEADER */
.app-header {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(3, 7, 18, 0.9);
  backdrop-filter: blur(15px);
  z-index: 100;
}

.app-title-header {
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 3px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-tag {
  background: var(--accent-active);
  color: #000;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 900;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.menu-btn {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* VIEWS & LAYOUT */
.view {
  flex: 1;
  display: none;
  flex-direction: column;
  padding: 0 20px;
  position: relative;
  animation: fadeIn 0.4s ease-out;
}

.view.active { display: flex; }

.view-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 30px 0 160px 0; /* Espacio extra para que el botón no se tape en móvil */
  scrollbar-width: none;
}

.view-scroll-content::-webkit-scrollbar { display: none; }

.view-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-color) 80%, transparent);
  z-index: 50;
}

/* TYPOGRAPHY */
h1 {
  font-size: 2.4rem;
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 8px;
  letter-spacing: -1.5px;
  line-height: 0.9;
  background: linear-gradient(to bottom, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.view-subtitle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-active);
  text-transform: uppercase;
  letter-spacing: 4px;
  margin-bottom: 35px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-subtitle::before {
  content: '';
  width: 20px;
  height: 1px;
  background: var(--accent-active);
}

/* CARDS & BLOCKS */
.card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 25px;
  border: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.4);
}

.setup-block {
  margin-bottom: 30px;
}

.rules-section-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-active);
  letter-spacing: 2px;
  margin-bottom: 15px;
  opacity: 0.7;
  text-transform: uppercase;
}

/* BUTTONS */
.btn-primary {
  width: 100%;
  padding: 20px;
  background: none;
  border: 1px solid var(--accent-active);
  color: var(--accent-active);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-primary:active {
  background: var(--accent-active);
  color: #000;
  transform: scale(0.98);
}

.btn-secondary {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-main);
  padding: 16px;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-secondary.mode-btn.active {
  background: var(--accent-active);
  color: #fff !important;
  border-color: #fff;
  box-shadow: 0 0 25px var(--accent-active), inset 0 0 10px rgba(255,255,255,0.5);
  font-weight: 900;
  transform: translateY(-2px);
  opacity: 1 !important;
}

/* INPUTS */
.name-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 18px;
  color: var(--text-main);
  border-radius: 16px;
  font-family: var(--font-main);
  font-size: 1.1rem;
  margin-bottom: 15px;
  outline: none;
  transition: all 0.3s;
}

.name-input:focus {
  border-color: var(--accent-active);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}

select.name-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2338bdf8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 20px;
}

/* PLAYERS GRID (LOBBY) */
.players-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.player-tag {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  padding: 15px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  transition: all 0.3s;
}

.player-tag.is-me {
  border-color: var(--accent-active);
  background: rgba(56, 189, 248, 0.05);
}

.player-tag .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #334155;
}

.player-tag.ready .status-dot {
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
}

.x-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(244, 63, 94, 0.2);
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 900;
  cursor: pointer;
}

/* NEWS REPORT */
.news-report {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-main);
  background: rgba(56, 189, 248, 0.03);
  padding: 25px;
  border-radius: 20px;
  border-left: 2px solid var(--accent-active);
  position: relative;
  overflow: hidden;
}

.news-report::before {
  content: 'OFFICIAL_BULLETIN';
  position: absolute;
  top: 5px;
  right: 10px;
  font-size: 0.5rem;
  opacity: 0.2;
}

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#scanner-overlay {
  position: fixed;
  top:0; left:0; right:0; bottom:0;
  background: rgba(3, 7, 18, 0.95);
  z-index: 2000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
}

.scanner-line {
  width: 100%;
  height: 1px;
  background: var(--accent-active);
  box-shadow: 0 0 30px var(--accent-active);
  position: absolute;
  animation: scan 2.5s ease-in-out infinite;
}

@keyframes scan {
  0% { top: 10%; opacity: 0; }
  50% { opacity: 1; }
  100% { top: 90%; opacity: 0; }
}

/* SIDE MENU */
.side-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100%;
  background: #0f172a;
  z-index: 1000;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 40px 30px;
  border-left: 1px solid rgba(255,255,255,0.05);
}

.side-menu.active { right: 0; }

.side-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.close-menu-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-item {
  padding: 20px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s;
}

.menu-item:active { color: var(--accent-active); }

/* CLUE BOX */
.clue-box {
  margin-top: 20px;
  padding: 15px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  border: 1px dashed rgba(56, 189, 248, 0.3);
}

/* INFO TERMINAL */
.info-terminal-btn {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
  transition: all 0.3s ease;
}

.info-terminal-btn:active {
  background: var(--accent-cyan);
  color: var(--bg-dark);
  box-shadow: 0 0 20px var(--accent-cyan);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 6, 23, 0.95);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  padding: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* TRUTH DISPLAY (RESULT) */
.truth-display {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-cyan);
  padding: 15px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 20px;
}
