/* ==========================================================================
   TAPX - MINIMALIST HUMAN-DESIGNED STYLES
   ========================================================================== */

:root {
  /* Superficies oscuras (fijas; no cambian con el tema) */
  --background: #0d0f14;
  --surface: #171b23;
  --surface-secondary: #1c212b;

  --bg-main: var(--background);
  --bg-surface: var(--surface);
  --bg-surface-subtle: var(--surface-secondary);
  --border-subtle: rgba(255, 255, 255, 0.08);

  --text-primary: #f4f6fb;
  --text-secondary: #8b95a7;
  --text-muted: #6b7385;

  /* Acento predeterminado: azul */
  --accent: #6366f1;
  --accent-hover: #7477f5;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-border: rgba(99, 102, 241, 0.55);
  --accent-focus-ring: rgba(99, 102, 241, 0.22);
  --accent-wash: rgba(99, 102, 241, 0.08);

  /* Alias de compatibilidad con selectores existentes */
  --border-highlight: var(--accent-border);
  --accent-violet: var(--accent);
  --accent-violet-soft: var(--accent);
  --accent-violet-hover: var(--accent-hover);
  --accent-violet-muted: var(--accent-border);
  --accent-green: #22c55e;

  --radius-container: 16px;
  --radius-control: 12px;
  --radius-button: 10px;
  --radius-pill: 999px;

  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Temas de acento (solo variables; no duplicar estilos) */
html[data-theme="blue"] {
  --accent: #6366f1;
  --accent-hover: #7477f5;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-border: rgba(99, 102, 241, 0.55);
  --accent-focus-ring: rgba(99, 102, 241, 0.22);
  --accent-wash: rgba(99, 102, 241, 0.08);
}

html[data-theme="red"] {
  --accent: #ef4444;
  --accent-hover: #f05252;
  --accent-soft: rgba(239, 68, 68, 0.14);
  --accent-border: rgba(239, 68, 68, 0.55);
  --accent-focus-ring: rgba(239, 68, 68, 0.22);
  --accent-wash: rgba(239, 68, 68, 0.08);
}

html[data-theme="pink"] {
  --accent: #ec4899;
  --accent-hover: #f05da5;
  --accent-soft: rgba(236, 72, 153, 0.14);
  --accent-border: rgba(236, 72, 153, 0.55);
  --accent-focus-ring: rgba(236, 72, 153, 0.22);
  --accent-wash: rgba(236, 72, 153, 0.08);
}

html[data-theme="orange"] {
  --accent: #f97316;
  --accent-hover: #fb8533;
  --accent-soft: rgba(249, 115, 22, 0.14);
  --accent-border: rgba(249, 115, 22, 0.55);
  --accent-focus-ring: rgba(249, 115, 22, 0.22);
  --accent-wash: rgba(249, 115, 22, 0.08);
}

html[data-theme="green"] {
  --accent: #22c55e;
  --accent-hover: #32d46c;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --accent-border: rgba(34, 197, 94, 0.55);
  --accent-focus-ring: rgba(34, 197, 94, 0.22);
  --accent-wash: rgba(34, 197, 94, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar Integrado */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ==========================================================================
   MODAL DE REGISTRO
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-container);
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-title-group h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.modal-title-group p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 24px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-focus-ring);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field-error {
  font-size: 0.8rem;
  color: #ef4444;
  min-height: 18px;
}

.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-control);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, transform 0.08s ease, border-color 150ms ease, color 150ms ease;
}

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

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-surface-subtle);
  border-color: rgba(255, 255, 255, 0.15);
}

.modal-panel-sm {
  max-width: 380px;
  padding: 28px 24px;
  max-height: min(90vh, 640px);
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  flex: 1;
  width: auto;
}

.modal-actions-end {
  justify-content: flex-end;
}

.modal-actions-end .btn-primary {
  flex: 0 1 auto;
  min-width: 120px;
}

.text-button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.text-button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-control);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.hidden {
  display: none;
}

/* ==========================================================================
   LAYOUT PRINCIPAL Y NAVBAR
   ========================================================================== */

.app-layout {
  width: 100%;
  max-width: 1160px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 32px;
}

.app-layout.hidden {
  display: none;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
  gap: 16px;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  padding: 3px 10px 3px 4px;
  border-radius: var(--radius-pill);
  margin-right: 4px;
}

.avatar-initials {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.rank-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}

.icon-button {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-button);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.icon-button:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.14);
  background: var(--bg-surface-subtle);
}

.mobile-only {
  display: none;
}

/* ==========================================================================
   CUERPO Y DISTRIBUCIÓN
   ========================================================================== */

.content-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
  width: 100%;
  min-width: 0;
}

/* Fila superior: contador (~65%) + ranking (~35%) */
.play-row {
  display: flex;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  min-width: 0;
}

/* Área del contador — una sola zona visual */
.main-clicker-area {
  flex: 1 1 65%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-container);
  padding: 28px 24px 24px;
  gap: 0;
}

/* Barra Delgado de Racha */
.streak-bar-wrapper {
  width: 100%;
  max-width: 280px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.streak-bar-wrapper.hidden {
  display: none;
}

.streak-bar-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.streak-mult-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--accent-soft);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  transition: background-color 150ms ease;
}

.streak-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.streak-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.streak-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-border);
  border-radius: var(--radius-pill);
  transition: width 0.08s linear, background-color 150ms ease;
}

/* Contador */
.counter-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.counter-number {
  font-size: 4.75rem; /* ~76px */
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}

.counter-number.tick-up {
  animation: counterTick 0.18s ease-out;
}

.counter-number.tick-down {
  animation: counterTickDown 0.2s ease-out;
}

.counter-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

/* Botón de clic circular */
.click-button-zone {
  position: relative;
  margin-bottom: 24px;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}

.tap-action-btn {
  width: 180px;
  height: 180px;
  aspect-ratio: 1 / 1;
  background: var(--accent);
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s cubic-bezier(0.16, 1, 0.3, 1), background-color 150ms ease, box-shadow 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  user-select: none;
}

.tap-action-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.34);
}

.tap-action-btn:active,
.tap-action-btn.pressed {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.22);
}

.tap-action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Floating +X */
.floating-pop-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.subtle-pop {
  position: absolute;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  opacity: 0.85;
  animation: fadeUp 0.45s ease-out forwards;
  pointer-events: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.subtle-pop.is-critical {
  color: var(--accent);
  font-size: 0.95rem;
  animation: fadeUpCrit 0.55s ease-out forwards;
}

@keyframes fadeUp {
  0% { opacity: 0.85; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-24px); }
}

@keyframes fadeUpCrit {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-28px) scale(1.04); }
}

@keyframes counterTick {
  0% { transform: scale(1); }
  40% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

@keyframes counterTickDown {
  0% { transform: scale(1); }
  40% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

@keyframes upgradeFlash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* Estadísticas rápidas — fila compacta dentro del panel */
.stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  max-width: 420px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: 16px 4px 0;
  margin-top: 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 0 8px;
}

.stat-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-value.is-positive {
  color: var(--text-primary);
}

.stat-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

/* ==========================================================================
   PANEL DE MEJORAS (ancho completo, 2 columnas)
   ========================================================================== */

.upgrades-panel {
  width: 100%;
  max-width: none;
  margin-top: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-container);
  padding: 16px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upgrades-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.upgrades-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upgrades-title-group h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.extra-stats-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 12px;
  padding: 12px;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
}

.extra-stats-panel.hidden {
  display: none;
}

.extra-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.extra-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.extra-stat-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.upgrades-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.upgrade-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  min-width: 0;
  transition: background-color 0.15s ease;
}

/* Cuadrícula 2 columnas: quitar bordes exteriores sobrantes */
.upgrade-row:nth-child(2n) {
  border-right: none;
}

.upgrade-row:nth-last-child(-n+2):not(.is-wide) {
  border-bottom: none;
}

.upgrade-row.is-wide {
  grid-column: 1 / -1;
  border-right: none;
  border-bottom: none;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 12px 10px;
}

.upgrade-row.is-wide .upgrade-info {
  flex: 1;
}

.upgrade-row.is-wide .upgrade-actions {
  width: 100%;
  max-width: 280px;
  align-self: flex-end;
}

.upgrade-row.just-bought {
  animation: upgradeFlash 0.25s ease-out;
}

.upgrade-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.upgrade-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.upgrade-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.upgrade-level {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.upgrade-desc {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  margin: 0;
}

.upgrade-level-bar {
  width: 100%;
  max-width: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 2px;
}

.upgrade-level-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.2s ease, background-color 150ms ease;
}

.upgrade-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  margin-top: 2px;
}

.btn-upgrade {
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-button);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease, opacity 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.btn-upgrade:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-upgrade:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-upgrade.is-max {
  color: var(--text-muted);
}

/* ==========================================================================
   RANKING (~35%)
   ========================================================================== */

.ranking-panel {
  flex: 0 0 35%;
  width: 35%;
  max-width: 380px;
  min-width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-container);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: none;
}

.ranking-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.ranking-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ranking-title-group h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  max-height: min(420px, 55vh);
  overflow-y: auto;
}

.ranking-empty {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 24px 12px;
  line-height: 1.4;
}

.ranking-separator {
  height: 1px;
  background: var(--border-subtle);
  margin: 10px 4px 8px;
}

.ranking-self-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 8px 4px;
  text-transform: none;
  letter-spacing: 0;
}

/* Filas compactas del ranking */
.ranking-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  transition: background-color 0.15s ease;
  gap: 8px;
}

.ranking-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ranking-row.is-me {
  border-color: var(--accent-border);
  background: var(--accent-wash);
  transition: background-color 150ms ease, border-color 150ms ease;
}

.row-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.row-rank {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.row-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ranking-row.is-me .row-avatar {
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.row-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.you-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.row-clicks {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  flex-shrink: 0;
  min-width: 3.5em;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablets */
@media (max-width: 980px) {
  .app-layout {
    max-width: 100%;
    padding: 16px 16px 28px;
  }

  .ranking-panel {
    flex: 0 0 32%;
    width: 32%;
    min-width: 210px;
  }

  .extra-stats-panel {
    grid-template-columns: 1fr 1fr;
  }
}

/* Móvil */
@media (max-width: 820px) {
  .mobile-only {
    display: flex;
  }

  .app-layout {
    padding: 16px 16px 28px;
  }

  .navbar {
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .user-name {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .content-body {
    gap: 16px;
  }

  .play-row {
    flex-direction: column;
    gap: 16px;
  }

  .main-clicker-area {
    width: 100%;
    flex: none;
    padding: 24px 16px 20px;
  }

  .counter-number {
    font-size: 3.5rem;
  }

  .click-button-zone {
    width: 158px;
    height: 158px;
  }

  .tap-action-btn {
    width: 158px;
    height: 158px;
    max-width: none;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    font-size: 0.98rem;
  }

  .stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 0;
    width: 100%;
    max-width: none;
    padding-top: 14px;
  }

  .stat-divider {
    display: none;
  }

  .stat-item {
    padding: 8px;
    background: var(--bg-main);
    border-radius: var(--radius-button);
  }

  .upgrades-list {
    grid-template-columns: 1fr;
  }

  .upgrade-row {
    border-right: none;
    padding: 14px 4px;
  }

  .upgrade-row:not(:last-child) {
    border-bottom: 1px solid var(--border-subtle);
  }

  .upgrade-row.is-wide {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 4px 8px;
  }

  .upgrade-row.is-wide .upgrade-actions {
    width: 100%;
  }

  .btn-upgrade {
    min-height: 44px;
  }

  .extra-stats-panel {
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn-primary,
  .modal-actions .btn-secondary {
    width: 100%;
  }

  /* Ranking como drawer en móvil */
  .ranking-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    min-width: 0;
    height: 100vh;
    flex: none;
    border-radius: 0;
    border-left: 1px solid var(--border-subtle);
    border-top: none;
    border-right: none;
    border-bottom: none;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 16px;
  }

  .ranking-panel.open {
    transform: translateX(0);
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ==========================================================================
   SELECTOR DE MODO DE ACCESO (pestañas integradas al panel)
   ========================================================================== */

.auth-shell {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  isolation: isolate;
}

.auth-tabs {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  align-self: flex-start;
  position: relative;
  z-index: 2;
  margin: 0;
  gap: 0;
}

.auth-tabs .auth-tab,
.auth-tabs .mode-btn {
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--border-subtle);
  border-bottom: 0;
  border-radius: var(--radius-control) var(--radius-control) 0 0;
  background: var(--bg-main);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  margin: 0;
  box-shadow: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Pestañas contiguas: solapan el borde compartido sin hueco */
.auth-tabs .auth-tab + .auth-tab,
.auth-tabs .mode-btn + .mode-btn {
  margin-left: -1px;
}

.auth-tabs .auth-tab:hover,
.auth-tabs .mode-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-subtle);
}

.auth-tabs .auth-tab:focus-visible,
.auth-tabs .mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 4;
}

/* Activa: mismo fondo que el panel, cubre el borde superior y se fusiona */
.auth-tabs .auth-tab.active,
.auth-tabs .mode-btn.active {
  z-index: 3;
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  border-bottom-color: transparent;
  color: var(--accent);
  margin-bottom: -1px;
  box-shadow: none;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.auth-tabs .auth-tab.active:hover,
.auth-tabs .mode-btn.active:hover {
  background: var(--bg-surface);
  color: var(--accent-hover);
}

.auth-tabs.hidden {
  display: none;
}

.auth-panel {
  width: 100%;
  position: relative;
  z-index: 1;
  margin-top: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  /* Esquina superior izquierda recta bajo las pestañas; resto redondeado */
  border-radius: 0 var(--radius-container) var(--radius-container) var(--radius-container);
  padding: 32px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Sin pestañas (usuario recordado): panel con las 4 esquinas redondeadas */
.auth-shell:has(.auth-tabs.hidden) .auth-panel {
  border-radius: var(--radius-container);
}

/* ==========================================================================
   PIN INPUT
   ========================================================================== */

.pin-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.pin-input-wrapper input {
  padding-right: 44px;
}

.pin-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.pin-toggle:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.pin-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   SELECTOR DE TEMA (MENÚ FLOTANTE EN NAVBAR)
   ========================================================================== */

.theme-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  padding: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  min-width: 0;
}

.theme-menu.hidden {
  display: none;
}

.theme-swatches {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  padding: 0;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: none;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.theme-swatch:hover {
  transform: scale(1.06);
  border-color: rgba(255, 255, 255, 0.28);
}

.theme-swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.theme-swatch[aria-pressed="true"],
.theme-swatch[aria-checked="true"] {
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 2px var(--background), 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.theme-swatch .theme-check {
  width: 14px;
  height: 14px;
  color: #fff;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

.theme-swatch .theme-check.hidden {
  display: none;
}

.theme-swatch[data-theme-option="blue"] { background: #6366f1; }
.theme-swatch[data-theme-option="red"] { background: #ef4444; }
.theme-swatch[data-theme-option="pink"] { background: #ec4899; }
.theme-swatch[data-theme-option="orange"] { background: #f97316; }
.theme-swatch[data-theme-option="green"] { background: #22c55e; }

.pin-toggle svg {
  display: block;
}

.pin-toggle svg.hidden {
  display: none;
}

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

/* Reduced Motion Respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
