/* ============================================================
   KANAL (Uwe Rosenberg) - Companion & Reglas Oficiales
   Estilo Visual: Industrial Óxido, Hierro Forjado, Cobre y Pergamino
   Optimizado para Pantalla de Escritorio y iPhone / Móvil
   ============================================================ */

:root {
  /* Paleta de Óxido y Hierro Industrial */
  --bg-dark: #16120f;
  --bg-steel: #201a15;
  --bg-surface: #2b221b;
  --bg-surface-elevated: #362b23;
  --rust-dark: #4e2210;
  --rust-mid: #7e381b;
  --rust-light: #9e4622;
  --rust-bright: #bc5527;
  --copper-patina: #26756d;
  --copper-light: #3ca399;
  --brass-gold: #c88f3a;
  --brass-light: #e6b25e;

  /* Pergamino y Papel Envejecido */
  --parchment-light: #fbf6ec;
  --parchment-base: #f3e9d2;
  --parchment-dark: #e1d2b1;
  --parchment-border: #bfa882;
  --text-dark: #221c17;
  --text-muted: #5e5246;

  /* Texto sobre fondo oscuro */
  --text-light: #f5ede2;
  --text-dim: #b8a896;
  --text-accent: #e5b061;

  /* Colores de Fases de Juego */
  --phase-green: #2e7d32;
  --phase-green-bg: #e8f5e9;
  --phase-brown: #5d4037;
  --phase-brown-bg: #efebe9;
  --phase-blue: #1565c0;
  --phase-blue-bg: #e3f2fd;

  /* Fuentes del sistema y decorativas */
  --font-title: 'Cinzel', 'Playfair Display', 'Georgia', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Medidas y bordes */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 2px 5px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
  --border-rivet: 1px solid #5a4232;
}

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  width: 100%;
  overflow: visible;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(ellipse at top, #2f2218 0%, #16120f 80%),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 2px, transparent 2px, transparent 4px);
  color: var(--text-light);
  font-family: var(--font-ui);
  line-height: 1.5;
  min-height: 100vh;
  width: 100%;
  overflow: visible;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
  }
}

/* ============================================================
   CABECERA PRINCIPAL (HEADER INDUSTRIAL CON RELIEVE Y ÓXIDO)
   ============================================================ */
.app-header {
  background: linear-gradient(180deg, #3a2519 0%, #261912 60%, #170f0b 100%);
  border-bottom: 3px solid #583321;
  box-shadow: 0 4px 15px rgba(0,0,0,0.7);
  position: relative;
  z-index: 100;
  width: 100%;
}

@media (min-width: 768px) {
  .app-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
  }
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  text-decoration: none;
  min-width: 0;
}

.brand-logo-gear {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  animation: slowGear 40s linear infinite;
}

@keyframes slowGear {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-family: var(--font-title);
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffd79e 0%, #d89647 40%, #874719 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.8));
  line-height: 1.1;
  white-space: nowrap;
}

.brand-text .author-tag {
  font-size: 0.68rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--brass-gold);
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Navegación Desktop */
.desktop-nav {
  display: none;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
  }
}

.nav-btn {
  background: linear-gradient(180deg, #3d2f24 0%, #291e16 100%);
  border: 1px solid #5d4432;
  color: var(--text-dim);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}

.nav-btn:hover {
  background: linear-gradient(180deg, #4f3b2e 0%, #35271d 100%);
  color: var(--brass-light);
  border-color: var(--brass-gold);
}

.nav-btn.active {
  background: linear-gradient(180deg, var(--rust-light) 0%, var(--rust-dark) 100%);
  color: #fff;
  border-color: var(--brass-gold);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 10px rgba(188, 85, 39, 0.4);
}

/* ============================================================
   NAVEGACIÓN MÓVIL INFERIOR (COMPATIBLE CON IPHONE / HOME BAR)
   ============================================================ */
.mobile-nav-bar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 58px;
  height: auto;
  background: rgba(18, 14, 11, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 2px solid #583321;
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
  padding-top: 5px;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.7);
}

@media (min-width: 768px) {
  .mobile-nav-bar {
    display: none;
  }
}

.m-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
  min-height: 48px;
  color: var(--text-dim);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s ease;
}

.m-nav-item .m-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 2px;
  display: block;
}

.m-nav-item .m-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1;
}

.m-nav-item.active {
  color: var(--brass-light);
}

.m-nav-item.active .m-icon {
  filter: drop-shadow(0 0 4px rgba(230, 178, 94, 0.6));
}

/* ============================================================
   CONTENEDOR PRINCIPAL Y PESTAÑAS (TABS)
   ============================================================ */
.main-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 0.75rem;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
}

@media (min-width: 600px) {
  .main-container {
    padding: 1.25rem 1rem;
  }
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease;
  min-width: 0;
  width: 100%;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================================
   SECCIÓN 1: REGLAS TRADUCIDAS (RESPONSIVE SIN OVERFLOW)
   ============================================================ */
.rules-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  width: 100%;
  min-width: 0;
}

@media (min-width: 992px) {
  .rules-layout {
    grid-template-columns: 290px minmax(0, 1fr);
    align-items: start;
  }
}

/* Menú lateral de reglas (TOC) */
.rules-sidebar {
  background: var(--bg-surface);
  border: 1px solid #4a3626;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-md);
  width: 100%;
  min-width: 0;
}

@media (min-width: 992px) {
  .rules-sidebar {
    position: sticky;
    top: 75px;
    max-height: calc(100vh - 95px);
    overflow-y: auto;
  }
}

.sidebar-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  color: var(--brass-light);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 0.65rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #4a3626;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
}

.sidebar-toggle-arrow {
  font-size: 0.72rem;
  color: var(--brass-gold);
}

@media (min-width: 992px) {
  .sidebar-toggle-arrow {
    display: none;
  }
}

.rules-toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

@media (max-width: 991px) {
  .rules-toc-list {
    display: none;
    margin-top: 0.5rem;
  }
  .rules-toc-list.open {
    display: flex;
  }
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.86rem;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  word-break: break-word;
}

.toc-link:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-light);
  border-color: #5d4432;
}

.toc-link.active {
  background: linear-gradient(90deg, rgba(126, 56, 27, 0.4) 0%, transparent 100%);
  color: var(--brass-light);
  border-left: 3px solid var(--brass-gold);
  font-weight: 600;
}

/* Cuerpo de las reglas */
.rules-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
  width: 100%;
}

.rule-section-card {
  background: var(--bg-surface);
  border: 1px solid #4a3626;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  width: 100%;
  min-width: 0;
}

.rule-section-header {
  background: linear-gradient(180deg, #3a2a1e 0%, #2a1e15 100%);
  padding: 0.85rem 1rem;
  border-bottom: 2px solid #583822;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.rule-section-header h2 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--brass-light);
  letter-spacing: 0.5px;
  line-height: 1.25;
}

.rule-section-content {
  padding: 1rem 0.9rem;
  color: #dfd4c5;
  font-size: 0.94rem;
  line-height: 1.6;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

@media (min-width: 600px) {
  .rule-section-content {
    padding: 1.25rem;
    font-size: 0.98rem;
  }
}

.rule-section-content h3 {
  font-family: var(--font-title);
  color: var(--brass-gold);
  font-size: 1.12rem;
  margin: 1.25rem 0 0.5rem 0;
  border-bottom: 1px solid #473223;
  padding-bottom: 0.35rem;
}

.rule-section-content h3:first-child {
  margin-top: 0;
}

.rule-section-content h4 {
  color: var(--text-light);
  font-size: 1rem;
  margin: 1rem 0 0.4rem 0;
}

.rule-section-content p {
  margin-bottom: 0.85rem;
}

.rule-section-content ul, .rule-section-content ol {
  margin: 0.5rem 0 1rem 1.2rem;
}

.rule-section-content li {
  margin-bottom: 0.4rem;
}

/* Cajas de llamada (Callouts) */
.rule-callout {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  border-left: 4px solid;
  font-size: 0.92rem;
  line-height: 1.55;
}

.rule-callout.tip {
  background: rgba(38, 117, 109, 0.15);
  border-color: var(--copper-patina);
  color: #c9ede8;
}

.rule-callout.warning {
  background: rgba(188, 85, 39, 0.15);
  border-color: var(--rust-light);
  color: #ffd8c7;
}

/* Tarjetas de componentes en rejilla */
.components-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
  width: 100%;
}

@media (min-width: 480px) {
  .components-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

.component-card {
  background: rgba(0,0,0,0.25);
  border: 1px solid #4a3626;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
}

.comp-qty {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brass-light);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.comp-name {
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.comp-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Pasos de Setup */
.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
  width: 100%;
}

.step-card {
  display: flex;
  gap: 0.85rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid #4a3626;
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  align-items: flex-start;
  min-width: 0;
}

.step-num {
  font-family: var(--font-title);
  background: linear-gradient(180deg, var(--rust-mid) 0%, var(--rust-dark) 100%);
  color: #fff;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  border: 1px solid var(--brass-gold);
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  font-size: 0.88rem;
}

.step-body {
  font-size: 0.92rem;
  min-width: 0;
}

/* Espacios de acción */
.action-spaces-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 1rem 0;
  width: 100%;
}

.action-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: rgba(0,0,0,0.25);
  border: 1px solid #4a3626;
  border-left: 4px solid var(--rust-mid);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
}

@media (min-width: 550px) {
  .action-item {
    flex-direction: row;
    gap: 1rem;
    align-items: baseline;
  }
}

.action-tag {
  font-weight: 800;
  color: var(--brass-light);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.unlocked-text {
  color: #e0b674;
  display: block;
  margin-top: 0.25rem;
}

/* Tablas de reglas responsivas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border: 1px solid #4a3626;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.25);
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 440px;
}

.rules-table th {
  background: #38281d;
  color: var(--brass-light);
  font-weight: 700;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 2px solid #583b26;
}

.rules-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid #3d2b1f;
  color: #dfd4c5;
}

.rules-table tr:last-child td {
  border-bottom: none;
}

.solo-table .highlight-row td {
  background: rgba(188, 85, 39, 0.2);
  color: #fff;
  border-top: 1px solid var(--brass-gold);
  border-bottom: 1px solid var(--brass-gold);
}

/* ============================================================
   SECCIÓN 9: ICONOGRAFÍA Y SIMBOLOGÍA (REDISEÑO VISUAL)
   ============================================================ */
.symbols-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 0.85rem 0 1.5rem 0;
  width: 100%;
}

@media (min-width: 650px) {
  .symbols-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .symbols-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.sym-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: rgba(0,0,0,0.3);
  border: 1px solid #453224;
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  min-width: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.sym-card:hover {
  background: rgba(0,0,0,0.45);
  border-color: var(--brass-gold);
}

.sym-visual-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
}

.sym-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: #fff;
  white-space: nowrap;
}

.badge-route { background: #7b1fa2; border: 1px solid #ba68c8; }
.badge-rail { background: #263238; border: 1px solid #90a4ae; color: #eceff1; }
.badge-path { background: #d78b27; color: #1c0e05; border: 1px solid #ffd54f; font-weight: 900; }
.badge-road { background: #455a64; border: 1px solid #78909c; }
.badge-canal { background: #0277bd; border: 1px solid #4fc3f7; }
.badge-bridge { background: #5d4037; border: 1px solid #8d6e63; }
.badge-struct { background: #4a148c; border: 1px solid #ab47bc; }

/* Muestras de color 1 2 3... */
.sym-color-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 0.95rem;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
  white-space: nowrap;
}

.sym-color-black {
  background: #111;
  border: 1px solid #777;
  color: #fff;
  box-shadow: 0 0 6px rgba(255,255,255,0.15);
}

.sym-color-red {
  background: #3e1212;
  border: 1px solid #d32f2f;
  color: #ff5252;
  box-shadow: 0 0 6px rgba(211,47,47,0.35);
}

.sym-color-blue {
  background: #0d2745;
  border: 1px solid #0288d1;
  color: #40c4ff;
  box-shadow: 0 0 6px rgba(2,136,209,0.35);
}

/* Símbolos especiales en código */
.sym-code-box {
  background: #1c140e;
  border: 1px solid #63432d;
  color: var(--brass-light);
  font-family: monospace, sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  padding: 4px 9px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  text-align: center;
  white-space: nowrap;
}

.sym-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}

.sym-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brass-light);
  line-height: 1.3;
}

.sym-desc {
  font-size: 0.84rem;
  color: #ded1c1;
  line-height: 1.45;
}

/* Semáforos demo */
.traffic-lights-demo {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 1rem 0;
  background: rgba(0,0,0,0.3);
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
}

@media (min-width: 500px) {
  .traffic-lights-demo {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.25rem;
  }
}

.tl-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tl-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.tl-dot.off {
  background: #424242;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
}

.tl-dot.on {
  background: #00e676;
  box-shadow: 0 0 8px #00e676;
}

/* ============================================================
   SECCIÓN 2: GLOSARIO DE EDIFICIOS (324 CARTAS)
   ============================================================ */
.glossary-controls-panel {
  background: var(--bg-surface);
  border: 1px solid #4a3626;
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

@media (min-width: 600px) {
  .glossary-controls-panel {
    padding: 1rem 1.25rem;
    gap: 0.85rem;
  }
}

/* Barra de búsqueda */
.search-bar-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background: #17120e;
  border: 1px solid #583e2b;
  color: var(--text-light);
  padding: 0.7rem 1rem 0.7rem 2.6rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.search-input:focus {
  border-color: var(--brass-gold);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 12px rgba(200, 143, 58, 0.3);
}

.search-icon-pos {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brass-gold);
  pointer-events: none;
  font-size: 1rem;
}

.search-clear-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  display: none;
}

.search-clear-btn.visible {
  display: block;
}

/* Filtros por mazo y color */
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}

@media (min-width: 768px) {
  .filter-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

@media (min-width: 768px) {
  .filter-group {
    width: auto;
  }
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brass-gold);
  margin-right: 0.2rem;
}

.filter-chip {
  background: #201812;
  border: 1px solid #4a3423;
  color: var(--text-dim);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  background: #33241b;
  color: #fff;
  border-color: var(--brass-gold);
}

.filter-chip.active {
  background: linear-gradient(180deg, var(--rust-light) 0%, var(--rust-dark) 100%);
  color: #fff;
  border-color: var(--brass-light);
  box-shadow: 0 0 8px rgba(188, 85, 39, 0.4);
}

.filter-chip.chip-green.active {
  background: var(--phase-green);
  border-color: #81c784;
}

.filter-chip.chip-brown.active {
  background: var(--phase-brown);
  border-color: #bcaaa4;
}

.filter-chip.chip-blue.active {
  background: var(--phase-blue);
  border-color: #90caf9;
}

/* Barra de resultados */
.glossary-results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0.2rem 0.1rem 0.65rem 0.1rem;
}

.results-count strong {
  color: var(--brass-light);
}

/* Cuadrícula de Cartas (Cards Grid) */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: 100%;
}

@media (min-width: 650px) {
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1050px) {
  .cards-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Tarjeta de Edificio */
.building-card {
  background: var(--parchment-base);
  border: 2px solid #5a3c26;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  min-width: 0;
}

.building-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.7), 0 0 10px rgba(200, 143, 58, 0.3);
}

.card-header-bar {
  padding: 0.45rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-weight: 700;
  border-bottom: 2px solid rgba(0,0,0,0.25);
}

.building-card.card-green .card-header-bar {
  background: linear-gradient(180deg, #388e3c 0%, #1b5e20 100%);
}

.building-card.card-brown .card-header-bar {
  background: linear-gradient(180deg, #6d4c41 0%, #3e2723 100%);
}

.building-card.card-blue .card-header-bar {
  background: linear-gradient(180deg, #1976d2 0%, #0d47a1 100%);
}

.card-ref-badge {
  font-family: var(--font-title);
  background: rgba(0,0,0,0.35);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.85rem;
  letter-spacing: 1px;
  border: 1px solid rgba(255,255,255,0.3);
}

.card-phase-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.2);
  padding: 2px 5px;
  border-radius: 3px;
}

.card-content-body {
  padding: 0.75rem 0.85rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  color: var(--text-dark);
  min-width: 0;
}

.card-title-es {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 800;
  color: #2a1608;
  line-height: 1.25;
  margin-bottom: 0.15rem;
  word-break: break-word;
}

.card-title-en {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--parchment-border);
}

.card-effect-text {
  font-size: 0.88rem;
  line-height: 1.45;
  flex: 1;
  color: #211c18;
  word-break: break-word;
}

.card-effect-text p {
  margin-bottom: 0.45rem;
}

.card-effect-text ul {
  margin: 0.35rem 0 0.5rem 1rem;
  list-style-type: square;
}

.card-effect-text li {
  margin-bottom: 0.25rem;
}

.card-icons-footer {
  margin-top: 0.75rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--parchment-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-icon-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.icon-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 2px 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #3e2723;
}

/* ============================================================
   SECCIÓN 3: CALCULADORA DE PUNTUACIÓN FINAL (COMPANION)
   ============================================================ */
.calc-layout {
  max-width: 950px;
  width: 100%;
  margin: 0 auto;
  display: block;
  min-width: 0;
}

/* Marcador Principal Superior (Sticky) */
.calc-scoreboard-card {
  background: linear-gradient(135deg, rgba(61, 34, 20, 0.98) 0%, rgba(34, 20, 11, 0.98) 100%);
  border: 2px solid var(--brass-gold);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.7);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 150;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

@media (min-width: 768px) {
  .calc-scoreboard-card {
    top: 60px;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .calc-scoreboard-card {
    top: 0;
    padding: 0.45rem 0.65rem;
    gap: 0.45rem;
  }

  .calc-score-main {
    gap: 0.6rem;
    min-width: 0;
  }

  .calc-score-badge-wrap {
    padding: 0.25rem 0.5rem;
    min-width: 58px;
  }

  .calc-score-val {
    font-size: 1.85rem;
  }

  .calc-score-label {
    font-size: 0.58rem;
  }

  .solo-rank-badge {
    font-size: 0.76rem;
    padding: 0.2rem 0.45rem;
  }

  .bd-pill {
    font-size: 0.68rem;
    padding: 1px 4px;
  }

  .calc-reset-action {
    padding: 0.35rem 0.55rem;
    font-size: 0.75rem;
  }
}

.calc-score-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 250px;
}

.calc-score-badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(200, 143, 58, 0.5);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  min-width: 72px;
  flex-shrink: 0;
}

.calc-score-val {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--brass-light);
  line-height: 1;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.calc-score-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--brass-gold);
  font-weight: 700;
  margin-top: 2px;
}

.calc-score-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.solo-rank-badge {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,0.35);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  border-left: 3px solid var(--brass-gold);
  line-height: 1.3;
}

.calc-breakdown-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.bd-pill {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 1px 6px;
  border-radius: 3px;
  color: #ded1c1;
  white-space: nowrap;
}

.bd-pill span {
  color: var(--brass-light);
  font-weight: 700;
}

.bd-pill-neg {
  border-color: rgba(216, 67, 21, 0.4);
  background: rgba(216, 67, 21, 0.15);
}

.bd-pill-neg span {
  color: #ffab91;
}

.calc-reset-action {
  background: #4a2312;
  border: 1px solid #8e3d1c;
  color: var(--brass-light);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.calc-reset-action:hover {
  background: #682f16;
  border-color: var(--brass-gold);
}

.calc-reset-action:active {
  transform: scale(0.96);
}

/* Bloques de Secciones */
.calc-sections-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  width: 100%;
}

@media (min-width: 768px) {
  .calc-sections-container {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.calc-group-card {
  background: var(--bg-surface);
  border: 1px solid #453224;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.calc-group-header {
  background: linear-gradient(180deg, #382417 0%, #26160e 100%);
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #4a3626;
}

.calc-group-header h3 {
  font-family: var(--font-title);
  font-size: 0.92rem;
  color: var(--brass-light);
  letter-spacing: 0.5px;
}

.calc-group-body {
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Filas Compactas */
.calc-compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 4px;
}

.calc-row-penalty {
  border-color: rgba(216, 67, 21, 0.25);
  background: rgba(216, 67, 21, 0.08);
}

.calc-row-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 1;
}

.calc-row-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.calc-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.calc-row-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: #ede0d4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-row-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stepper (- input +) */
.calc-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.stepper-btn {
  width: 34px;
  height: 32px;
  background: #3b2416;
  border: 1px solid #5d3a22;
  border-radius: 4px;
  color: var(--brass-light);
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.stepper-btn:hover {
  background: #52311c;
  border-color: var(--brass-gold);
}

.stepper-btn:active {
  background: #221309;
  transform: scale(0.92);
}

.calc-num-input {
  width: 44px;
  height: 32px;
  background: #140d08;
  border: 1px solid #583e2b;
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  padding: 0;
  margin: 0;
  -moz-appearance: textfield;
}

.calc-num-input::-webkit-outer-spin-button,
.calc-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.calc-num-input:focus {
  outline: none;
  border-color: var(--brass-gold);
  background: #1f140c;
  box-shadow: 0 0 5px rgba(200, 143, 58, 0.5);
}

.calc-num-input.input-penalty {
  color: #ffab91;
  border-color: #7a3219;
}

/* ============================================================
   SECCIÓN 4: HOJA DE AYUDA Y REFERENCIA RÁPIDA (REDISEÑO VISUAL)
   ============================================================ */
.ref-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.ref-section {
  background: var(--bg-surface);
  border: 1px solid #4a3626;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  width: 100%;
}

.ref-section-header {
  background: linear-gradient(180deg, #3a281c 0%, #271a12 100%);
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #583822;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.ref-section-header h2 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--brass-light);
  letter-spacing: 0.5px;
}

.ref-section-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 1. Tarjetas de Rutas y Puentes */
.routes-ref-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  width: 100%;
}

@media (min-width: 650px) {
  .routes-ref-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 950px) {
  .routes-ref-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.route-ref-card {
  background: rgba(0,0,0,0.25);
  border: 1px solid #453224;
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

.route-ref-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.route-name-title {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brass-light);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.route-cost-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(216, 67, 21, 0.2);
  border: 1px solid #d84315;
  color: #ffab91;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 700;
}

.route-ref-desc {
  font-size: 0.82rem;
  color: #ded1c1;
  line-height: 1.4;
}

.route-tag-pill {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0,0,0,0.4);
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: 3px;
  align-self: flex-start;
  border: 1px solid rgba(255,255,255,0.08);
}

/* 2. Bloque Acciones En Cualquier Momento */
.anytime-ref-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: 100%;
}

@media (min-width: 700px) {
  .anytime-ref-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.anytime-card {
  background: rgba(0,0,0,0.25);
  border: 1px solid #4a3626;
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.anytime-card h3 {
  font-family: var(--font-title);
  font-size: 1.05rem;
  color: var(--brass-light);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-bottom: 1px solid #4a3626;
  padding-bottom: 0.35rem;
}

.anytime-formula-banner {
  background: linear-gradient(90deg, rgba(200, 143, 58, 0.2) 0%, rgba(126, 56, 27, 0.2) 100%);
  border: 1px solid var(--brass-gold);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.anytime-scale-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.scale-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem;
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

.scale-step strong {
  color: var(--brass-light);
}

/* 3. Semáforos de Activación */
.traffic-steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  width: 100%;
}

@media (min-width: 750px) {
  .traffic-steps-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.traffic-step-card {
  background: rgba(0,0,0,0.25);
  border: 1px solid #4a3626;
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.traffic-step-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.84rem;
  color: #ded1c1;
}

.traffic-step-title {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--brass-light);
  font-size: 0.95rem;
}

/* 4. Resumen de Puntuación */
.scoring-ref-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  width: 100%;
}

@media (min-width: 600px) {
  .scoring-ref-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.score-ref-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.25);
  border: 1px solid #4a3626;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.86rem;
  color: #ded1c1;
}

.score-ref-item .pts-badge {
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.pts-badge.pts-plus {
  background: rgba(38, 117, 109, 0.3);
  border: 1px solid var(--copper-patina);
  color: #80cbc4;
}

.pts-badge.pts-minus {
  background: rgba(188, 85, 39, 0.3);
  border: 1px solid var(--rust-light);
  color: #ffab91;
}

.pts-badge.pts-zero {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text-dim);
}

/* ============================================================
   UTILIDADES Y RESPONSIVE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--brass-gold);
}

.empty-state h3 {
  color: var(--text-light);
  margin-bottom: 0.35rem;
}

/* Pie de página */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid #2d2017;
  margin-top: 1.5rem;
}

.app-footer a {
  color: var(--brass-gold);
  text-decoration: none;
}
